Implement ES-3.0-specific error semantics for redefining predefined macros.

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@29353 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich 2015-01-07 18:47:57 +00:00
parent 548ec2c12c
commit 50d542e6b9
4 changed files with 31 additions and 7 deletions

View File

@ -34,8 +34,16 @@ ERROR: 0:153: 'preprocessor evaluation' : undefined macro in expression not allo
ERROR: 0:156: 'preprocessor evaluation' : undefined macro in expression not allowed in es profile UNDEF2
ERROR: 0:159: 'preprocessor evaluation' : undefined macro in expression not allowed in es profile UNDEF2
ERROR: 0:3000: '#error' : line of this error should be 3000
ERROR: 0:3002: '#define' : predefined names can't be (un)defined: __LINE__
ERROR: 0:3003: '#define' : predefined names can't be (un)defined: __FILE__
ERROR: 0:3004: '#define' : predefined names can't be (un)defined: __VERSION__
ERROR: 0:3005: '#define' : names beginning with "GL_" can't be (un)defined: GL_SOME_EXTENSION
ERROR: 0:3006: '#undef' : predefined names can't be (un)defined: __LINE__
ERROR: 0:3007: '#undef' : predefined names can't be (un)defined: __FILE__
ERROR: 0:3008: '#undef' : predefined names can't be (un)defined: __VERSION__
ERROR: 0:3009: '#undef' : names beginning with "GL_" can't be (un)defined: GL_SOME_EXTENSION
ERROR: 0:10001: '' : missing #endif
ERROR: 36 compilation errors. No code generated.
ERROR: 44 compilation errors. No code generated.
Shader version: 300

View File

@ -25,8 +25,8 @@ ERROR: 0:136: 'length' : no matching overloaded function found
ERROR: 0:136: '=' : cannot convert from 'const float' to 'int'
ERROR: 0:138: ''' : character literals not supported
ERROR: 0:138: ''' : character literals not supported
ERROR: 0:141: '#define' : names beginning with "GL_" can't be defined: GL_
ERROR: 0:142: '#define' : names beginning with "GL_" can't be defined: GL_Macro
ERROR: 0:141: '#define' : names beginning with "GL_" can't be (un)defined: GL_
ERROR: 0:142: '#define' : names beginning with "GL_" can't be (un)defined: GL_Macro
WARNING: 0:143: '#define' : names containing consecutive underscores are reserved: __M
WARNING: 0:144: '#define' : names containing consecutive underscores are reserved: M__
WARNING: 0:145: '#define' : names containing consecutive underscores are reserved: ABC__DE
@ -43,7 +43,7 @@ ERROR: 0:185: '#define' : Macro redefined; different substitutions: m7
ERROR: 0:192: '#define' : Macro redefined; different substitutions: m8
ERROR: 0:196: '#define' : Macro redefined; different argument names: m9
WARNING: 0:204: '#undef' : names containing consecutive underscores are reserved: __VERSION__
ERROR: 0:205: '#undef' : names beginning with "GL_" can't be defined: GL_ARB_texture_rectangle
ERROR: 0:205: '#undef' : names beginning with "GL_" can't be (un)defined: GL_ARB_texture_rectangle
ERROR: 0:210: '#' : invalid directive
ERROR: 0:211: '#' : invalid directive
ERROR: 0:212: '#' : invalid directive

View File

@ -162,6 +162,15 @@ float c = foobar(1.1, 2.2
#line 3000
#error line of this error should be 3000
#define __LINE__ 30
#define __FILE__
#define __VERSION__
#define GL_SOME_EXTENSION
#undef __LINE__
#undef __FILE__
#undef __VERSION__
#undef GL_SOME_EXTENSION
#line 10000
#if 0
// ERROR, EOF

View File

@ -1783,10 +1783,17 @@ void TParseContext::reservedPpErrorCheck(TSourceLoc loc, const char* identifier,
// single underscore) are also reserved, and defining such a name results in a
// compile-time error."
if (strncmp(identifier, "GL_", 3) == 0)
error(loc, "names beginning with \"GL_\" can't be defined:", op, identifier);
else if (strstr(identifier, "__") != 0)
error(loc, "names beginning with \"GL_\" can't be (un)defined:", op, identifier);
else if (strstr(identifier, "__") != 0) {
if (profile == EEsProfile && version >= 300 &&
(strcmp(identifier, "__LINE__") == 0 ||
strcmp(identifier, "__FILE__") == 0 ||
strcmp(identifier, "__VERSION__") == 0))
error(loc, "predefined names can't be (un)defined:", op, identifier);
else
warn(loc, "names containing consecutive underscores are reserved:", op, identifier);
}
}
//
// See if this version/profile allows use of the line-continuation character '\'.