Preprocessor: Allow '\' as a token, which gets actual use in #error, but should have...
authorJohn Kessenich <cepheus@frii.com>
Sat, 25 Jul 2015 23:34:32 +0000 (17:34 -0600)
committerJohn Kessenich <cepheus@frii.com>
Sat, 25 Jul 2015 23:34:32 +0000 (17:34 -0600)
This is just for '\' that's not before a new line.
Note the specification says it has no use other than as line continuation,
but #error is a grey area. (There are no escape sequences.)

Test/baseResults/cppSimple.vert.out
Test/cppSimple.vert
glslang/MachineIndependent/preprocessor/Pp.cpp
glslang/MachineIndependent/preprocessor/PpAtom.cpp

index f28e173..a8cd543 100644 (file)
@@ -82,8 +82,17 @@ ERROR: 12:9014: '=' :  cannot convert from 'temp float' to 'global int'
 ERROR: 12:9015: 'macro expansion' : expected '(' following FOOOM\r
 ERROR: 12:9016: 'preprocessor evaluation' : can't evaluate expression \r
 ERROR: 12:9016: 'preprocessor evaluation' : bad expression \r
+ERROR: 12:9500: 'preprocessor evaluation' : bad expression \r
+ERROR: 12:9500: '#if' : unexpected tokens following directive \r
+ERROR: 12:9502: 'preprocessor evaluation' : bad expression \r
+ERROR: 12:9502: '#if' : unexpected tokens following directive \r
+ERROR: 12:9504: 'preprocessor evaluation' : bad expression \r
+ERROR: 12:9504: '#if' : unexpected tokens following directive \r
+ERROR: 12:9506: '#error' : \ 377  \r
+ERROR: 12:9507: '#error' : \ 376  \r
+ERROR: 12:9508: '#error' : \ 377  \r
 ERROR: 12:10002: '' : missing #endif \r
-ERROR: 79 compilation errors.  No code generated.\r
+ERROR: 88 compilation errors.  No code generated.\r
 \r
 \r
 Shader version: 400\r
index 52d3cf7..198203a 100644 (file)
@@ -326,6 +326,17 @@ int aoeua = FOOOM;
 #if FOOOM
 #endif
 
+#line 9500
+#if\376
+#endif
+#if \376
+#endif
+#if \377
+#endif
+#error\377
+#error \ 376
+#error \377
+
 #line 10000
 #if 1
 #else
index 80f9d68..3968462 100644 (file)
@@ -462,8 +462,8 @@ int TPpContext::eval(int token, int precedence, bool shortCircuit, int& res, boo
             token = scanToken(ppToken);
         }
     } else {
-        int op;
-        for (op = NUM_ELEMENTS(unop) - 1; op >= 0; op--) {
+        int op = NUM_ELEMENTS(unop) - 1;
+        for (; op >= 0; op--) {
             if (unop[op].token == token)
                 break;
         }
index 58f6515..1ce3f49 100644 (file)
@@ -175,7 +175,7 @@ void TPpContext::AddAtomFixed(const char* s, int atom)
 void TPpContext::InitAtomTable()
 {
     // Add single character tokens to the atom table:
-    const char* s = "~!%^&*()-+=|,.<>/?;:[]{}#";
+    const char* s = "~!%^&*()-+=|,.<>/?;:[]{}#\\";
     char t[2];
 
     t[1] = '\0';