Bug 44764 - GLSL preprocessor doesn't replace defines ending with ":"
Summary: GLSL preprocessor doesn't replace defines ending with ":"
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: glsl-compiler (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: Carl Worth
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-13 15:51 UTC by Ian Romanick
Modified: 2012-02-02 13:34 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Ian Romanick 2012-01-13 15:51:06 UTC
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);
}
Comment 1 Carl Worth 2012-01-21 09:47:59 UTC
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
Comment 2 Carl Worth 2012-02-02 13:34:55 UTC
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.