Fix line-continuation bug.
authorJohn Kessenich <cepheus@frii.com>
Tue, 12 Nov 2013 22:01:32 +0000 (22:01 +0000)
committerJohn Kessenich <cepheus@frii.com>
Tue, 12 Nov 2013 22:01:32 +0000 (22:01 +0000)
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@24021 e7fa87d3-cd2b-0410-9028-fcbf551c1848

Test/baseResults/lineContinuation.vert.out
Test/baseResults/lineContinuation100.vert.out
Test/lineContinuation.vert
Test/lineContinuation100.vert
glslang/MachineIndependent/Scan.cpp
glslang/MachineIndependent/preprocessor/PpScanner.cpp

index b66a25f..6c61ad8 100644 (file)
@@ -11,6 +11,16 @@ ERROR: node is still EOpNull!
 0:20        'gl_Position' (gl_Position highp 4-component vector of float)\r
 0:20        Construct vec4 (highp 4-component vector of float)\r
 0:20          'foo' (highp float)\r
+0:22  Function Definition: foo2(vf4; (highp 4-component vector of float)\r
+0:22    Function Parameters: \r
+0:22      'a' (in highp 4-component vector of float)\r
+0:24    Sequence\r
+0:24      Sequence\r
+0:24        move second child to first child (highp 4-component vector of float)\r
+0:24          'b' (highp 4-component vector of float)\r
+0:24          'a' (in highp 4-component vector of float)\r
+0:25      Branch: Return with expression\r
+0:25        'b' (highp 4-component vector of float)\r
 0:?   Linker Objects\r
 0:?     'foo' (highp float)\r
 0:?     'gl_VertexID' (gl_VertexId highp int)\r
index 640dbee..9b890c5 100644 (file)
@@ -6,7 +6,8 @@ ERROR: 0:13: 'line continuation' : not supported for this version or the enabled
 ERROR: 0:14: 'line continuation' : not supported for this version or the enabled extensions \r
 ERROR: 0:15: 'line continuation' : not supported for this version or the enabled extensions \r
 ERROR: 0:18: '#error' : e3  \r
-ERROR: 8 compilation errors.  No code generated.\r
+ERROR: 0:24: 'line continuation' : not supported for this version or the enabled extensions \r
+ERROR: 9 compilation errors.  No code generated.\r
 \r
 ERROR: node is still EOpNull!\r
 0:20  Function Definition: main( (void)\r
@@ -16,6 +17,16 @@ ERROR: node is still EOpNull!
 0:20        'gl_Position' (gl_Position highp 4-component vector of float)\r
 0:20        Construct vec4 (highp 4-component vector of float)\r
 0:20          'foo' (highp float)\r
+0:22  Function Definition: foo2(vf4; (highp 4-component vector of float)\r
+0:22    Function Parameters: \r
+0:22      'a' (in highp 4-component vector of float)\r
+0:24    Sequence\r
+0:24      Sequence\r
+0:24        move second child to first child (highp 4-component vector of float)\r
+0:24          'b' (highp 4-component vector of float)\r
+0:24          'a' (in highp 4-component vector of float)\r
+0:25      Branch: Return with expression\r
+0:25        'b' (highp 4-component vector of float)\r
 0:?   Linker Objects\r
 0:?     'foo' (highp float)\r
 \r
index eb2f819..1115027 100644 (file)
@@ -11,10 +11,16 @@ oo;  // same as 'float foo;'
 #error e2
 
 #define MAIN void main() \
-{                        \
+   {                     \
 gl_Position = vec4(foo); \
 } 
 
 #error e3
 
 MAIN
+
+vec4 foo2(vec4 a)
+{                                
+  vec4 b = a;       \
+  return b;                   
+}
index 0b0cc30..ec1d862 100644 (file)
@@ -11,10 +11,16 @@ oo;  // same as 'float foo;'
 #error e2\r
 \r
 #define MAIN void main() \\r
-{                        \\r
+   {                     \\r
 gl_Position = vec4(foo); \\r
 } \r
 \r
 #error e3\r
 \r
 MAIN\r
+\r
+vec4 foo2(vec4 a)\r
+{                                \r
+  vec4 b = a;       \\r
+  return b;                   \r
+}\r
index 2f6fd24..dc1692b 100644 (file)
@@ -90,7 +90,7 @@ bool TInputScanner::consumeComment()
                 break;
             } else {
                 // it's a '\', so we need to keep going, after skipping what's escaped
-                    
+
                 // read the skipped character
                 c = get();
 
index aed147c..0b9a09c 100644 (file)
@@ -256,10 +256,9 @@ int TPpContext::sourceScan(TPpContext* pp, InputSrc*, TPpToken* ppToken)
     int len, ch, ii;
     unsigned ival = 0;
 
+    ppToken->ival = 0;
+    ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
     for (;;) {
-        ppToken->ival = 0;
-        ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
-
         while (ch == ' ' || ch == '\t' || ch == '\r') {
             ppToken->ival = 1;
             ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
@@ -281,7 +280,7 @@ int TPpContext::sourceScan(TPpContext* pp, InputSrc*, TPpToken* ppToken)
         case 'k': case 'l': case 'm': case 'n': case 'o':
         case 'p': case 'q': case 'r': case 's': case 't':
         case 'u': case 'v': case 'w': case 'x': case 'y':
-        case 'z':            
+        case 'z': case '\\' :
             do {
                 if (ch == '\\') {
                     // escaped character
@@ -311,6 +310,10 @@ int TPpContext::sourceScan(TPpContext* pp, InputSrc*, TPpToken* ppToken)
                 ch == '_' ||
                 ch == '\\');
 
+            // line continuation with no token before or after makes len == 0, and need to start over skipping white space, etc.
+            if (len == 0)
+                continue;
+
             tokenText[len] = '\0';
             pp->currentInput->ungetch(pp, pp->currentInput, ch, ppToken);
             ppToken->atom = pp->LookUpAddString(tokenText);
@@ -706,6 +709,9 @@ int TPpContext::sourceScan(TPpContext* pp, InputSrc*, TPpToken* ppToken)
                 return CPP_ERROR_SY;
             }
         }
+
+        ppToken->ival = 0;
+        ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
     }
 }