mesa/src
Kenneth Graunke 07ec67d85c glcpp: Implicitly resolve version after the first non-space/hash token.
We resolved the implicit version directive when processing control lines,
such as #ifdef, to ensure any built-in macros exist.  However, we failed
to resolve it when handling ordinary text.

For example,

        int x = __VERSION__;

should resolve __VERSION__ to 110, but since we never resolved the implicit
version, none of the built-in macros exist, so it was left as is.

This also meant we allowed the following shader to slop through:

        123
        #version 120

Nothing would cause the implicit version to take effect, so when we saw
the #version directive, we thought everything was peachy.

This patch makes the lexer's per-token action resolve the implicit
version on the first non-space/newline/hash token that isn't part of
a #version directive, fulfilling the GLSL language spec:

"The #version directive must occur in a shader before anything else,
 except for comments and white space."

Because we emit #version as HASH_TOKEN then VERSION_TOKEN, we have to
allow HASH_TOKEN to slop through as well, so we don't resolve the
implicit version as soon as we see the # character.  However, this is
fine, because the parser's HASH_TOKEN NEWLINE rule does resolve the
version, disallowing cases like:

        #
        #version 120

This patch also adds the above shaders as new glcpp tests.

Fixes dEQP-GLES2.functional.shaders.preprocessor.predefined_macros.
{gl_es_1_vertex,gl_es_1_fragment}.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2016-03-07 23:01:43 -08:00
..
compiler glcpp: Implicitly resolve version after the first non-space/hash token. 2016-03-07 23:01:43 -08:00
egl Android: clean-up and fix DRI module path handling 2016-02-29 10:51:44 +00:00
gallium gallium/swr: fix issues preventing a 32-bit build 2016-03-07 17:22:24 -06:00
gbm
getopt
glx glx: update to updated version of EXT_create_context_es2_profile 2016-02-03 15:44:51 -05:00
gtest
hgl
loader virtio_gpu: Add PCI ID to driver map 2016-01-23 12:35:24 +10:00
mapi mesa: Add dispatch and extension XML for GL_ARB_internalformat_query2 2016-03-03 15:14:06 +01:00
mesa mesa: Change GLboolean to bool in GenerateMipmap target checker. 2016-03-07 14:01:34 -08:00
util util: fix new gcc6 warnings 2016-02-18 17:10:55 -05:00
Makefile.am glsl: move to compiler/ 2016-01-26 16:08:33 +00:00
SConscript glsl: move to compiler/ 2016-01-26 16:08:33 +00:00