[Mesa-dev] fixing GLSL NEW_IDENTIFIER error messages

Brian Paul brianp at vmware.com
Wed Aug 5 15:41:30 PDT 2015

If a shader contains a declaration such as:

uniform sampler2DMS tex;

but it doesn't specify "#extension GL_ARB_texture_multisample: enable" 
we get a GLSL error saying something like "0:2(21): error: syntax error, 
unexpected NEW_IDENTIFIER, expecting '{'"

There are other cases where the error "unexpected NEW_IDENTIFIER" pops 
up.  In my experience it's often somewhere deep down inside a large shader.

In this example, it would be nice if the compiler said "unexpected 
sampler2DMS identifier" instead of "unexpected NEW_IDENTIFIER".

The error message comes directly from bison via the yyerror() function 
and I don't see an obvious way to get at the "sampler2DMS" string here.

The YYLTYPE passed to yyerror() has useful info such as the identifier's 
line and location within the line:

(gdb) p *loc
$1 = {first_line = 10, first_column = 21, last_line = 10, last_column = 
25, source = 0}

but I don't see a way to get the actual string from the lexer.

Anyone have some ideas?  Fixing this would be a nice time saver for me 
when I'm investigating application shader issues.


More information about the mesa-dev mailing list