Fix several issues in the preprocessor:
- macro expansion of hexidecimal numbers - give errors instead of warnings/silence on extra tokens after #endif, #else, etc. - give errors on reserved macro name use, reuse of argument, and redefinition with different whitespace presence - detect and give error for all cases of #elif and #else after #else git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@23982 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#version 110
|
||||
#version 400
|
||||
|
||||
#define ON
|
||||
|
||||
@@ -119,7 +119,7 @@ sum += 0.05;
|
||||
|
||||
#if ((AA == BB || (AA == CC))))
|
||||
#error bad6
|
||||
#endif
|
||||
#endif extra tokens
|
||||
|
||||
int linenumber = __LINE__;
|
||||
int filenumber = __FILE__;
|
||||
@@ -129,5 +129,78 @@ int version = __VERSION__;
|
||||
#define TWOPI (2.0 * PI)
|
||||
float twoPi = TWOPI;
|
||||
|
||||
#define PASTE(a,b) a ## b
|
||||
float PASTE(tod, ay) = 17;
|
||||
//#define PASTE(a,b) a ## b
|
||||
//float PASTE(tod, ay) = 17;
|
||||
|
||||
"boo" // ERROR
|
||||
int a = length("aoenatuh"); // ERROR
|
||||
|
||||
'int'; // ERROR
|
||||
|
||||
// ERROR: all the following are reserved
|
||||
#define GL_
|
||||
#define GL_Macro 1
|
||||
#define __M
|
||||
#define M__
|
||||
#define ABC__DE abc
|
||||
|
||||
#if 4
|
||||
#else extra
|
||||
#elif
|
||||
// ERROR elif after else
|
||||
#endif
|
||||
|
||||
#if blah
|
||||
#if 0
|
||||
#else extra
|
||||
#ifdef M
|
||||
#else
|
||||
#else
|
||||
// ERROR else after else
|
||||
#endif extra
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define m1(a,a) // ERROR
|
||||
#define m2(a,b)
|
||||
|
||||
// okay
|
||||
#define m3 (a)
|
||||
#define m3 (a)
|
||||
|
||||
// ERROR
|
||||
#define m4(b)
|
||||
#define m4 (b)
|
||||
|
||||
// ERROR
|
||||
#define m5 (b)
|
||||
#define m5(b)
|
||||
|
||||
// ERROR
|
||||
#define m6(a)
|
||||
#define m6
|
||||
|
||||
// ERROR (whitespace)
|
||||
#define m7 (a)
|
||||
#define m7 ( a)
|
||||
|
||||
#define m80(a,b) is + exactly m3 the same
|
||||
#define m80(a,b) is + exactly m3 the same
|
||||
|
||||
// ERROR
|
||||
#define m8(a,b) almost + exactly m3 the same
|
||||
#define m8(a,b) almost + exactly m3 thee same
|
||||
|
||||
// ERROR
|
||||
#define m9(a,b,c) aoe
|
||||
#define m9(a,d,c) aoe
|
||||
|
||||
#define n1 0xf
|
||||
int n = n1;
|
||||
|
||||
#define f1 .08e-2Lf
|
||||
double f = f1;
|
||||
|
||||
#if 1
|
||||
#else
|
||||
// ERROR, missing #endif
|
||||
Reference in New Issue
Block a user