For example, the following error message is generated for the piglit test tests/spec/glsl-1.30/compiler/switch-statement/switch-case-const-int-expression.vert (copied below). The compiler should never see 'two' because it should be replaced with the digit 2 by the preprocessor. 0:23(14): error: `two' undeclared 0:23(14): error: Operands to arithmetic operators must be numeric // [config] // expect_result: pass // glsl_version: 1.30 // [end config] // // From page 57 (page 63 of the PDF) of the GLSL 1.30 spec: // // "The type of init-expression in a switch statement must be a scalar // integer. If a case label has a constant- expression of equal value, // then execution will continue after that label." // // The spec doesn't actually say anything about the type of cases. It only // says "constant-expression". #version 130 #define one 1 #define two 2 void main() { int tmp = 0; switch (1) { case one + two: tmp = 1; } gl_Position = vec4(0.0); }
I've proposed a patch to fix this bug as seen on mesa-dev here: http://lists.freedesktop.org/archives/mesa-dev/2012-January/017872.html -Carl
This is fixed in mesa master as of: commit 7ab1c7f7926c75a07f33eb149d0fc17dcfaffd5e Author: Carl Worth <cworth@cworth.org> Date: Sat Jan 21 09:24:11 2012 -0800 glcpp: Fix so that trailing punctuation does not prevent macro expansion
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.