Misc semantics fixes:
authorJohn Kessenich <cepheus@frii.com>
Tue, 12 Nov 2013 01:02:51 +0000 (01:02 +0000)
committerJohn Kessenich <cepheus@frii.com>
Tue, 12 Nov 2013 01:02:51 +0000 (01:02 +0000)
 - don't allow pre-array object versions to return a struct containing an array
 - special case -2147483648 / -1
 - include "~" in the full integer functionality checks
 - handle multiple function parameters having the same name

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@24010 e7fa87d3-cd2b-0410-9028-fcbf551c1848

Test/100.frag
Test/array100.frag
Test/baseResults/100.frag.out
Test/baseResults/array100.frag.out
Test/baseResults/constFold.frag.out
Test/constFold.frag
glslang/MachineIndependent/Constant.cpp
glslang/MachineIndependent/ParseHelper.cpp
glslang/MachineIndependent/glslang.y

index a4dc798..cb78f8b 100644 (file)
@@ -133,8 +133,17 @@ void foo246()
     texture2DProj(highExt, v[2]);\r
     texture3D(sExt, vec3(f13));   // ERROR\r
     texture2DProjLod(sExt, vec3(f13), f13);  // ERROR\r
+    int a;\r
+    ~a;    // ERROR\r
+    a | a; // ERROR\r
+    a & a; // ERROR\r
 }\r
 \r
 #extension GL_OES_EGL_image_external : disable\r
 \r
+int foo203940(int a, float b, float a)  // ERROR, a redefined\r
+{\r
+    return a;\r
+}\r
+\r
 uniform samplerExternalOES badExt;  // syntax ERROR\r
index 596e41b..beedfec 100644 (file)
@@ -39,3 +39,31 @@ void main()
     gl_FragData[-1] = vec4(1.0);   // ERROR
     gl_FragData[3] = vec4(1.0);
 }
+
+struct SA {
+    vec3 v3;
+    vec2 v2[4];
+};
+
+struct SB {
+    vec4 v4;
+    SA sa;
+};
+
+SB bar9()
+{
+    SB s;
+    return s;  // ERROR
+}
+
+void bar10(SB s)  // okay
+{
+}
+
+void bar11()
+{
+    SB s1, s2;
+    s1 = s2;   // ERROR
+    bar10(s1);
+    s2 = bar9(); // ERROR
+}
index 49a0847..2507e06 100644 (file)
@@ -53,8 +53,12 @@ ERROR: 0:104: 'gl_FragDepthEXT' : required extension not requested: GL_EXT_frag_
 ERROR: 0:111: 'gl_FragDepth' : undeclared identifier \r
 ERROR: 0:134: 'texture3D' : no matching overloaded function found \r
 ERROR: 0:135: 'texture2DProjLod' : no matching overloaded function found \r
-ERROR: 0:140: '' :  syntax error\r
-ERROR: 49 compilation errors.  No code generated.\r
+ERROR: 0:137: 'bitwise not' : not supported for this version or the enabled extensions \r
+ERROR: 0:138: 'bitwise inclusive or' : not supported for this version or the enabled extensions \r
+ERROR: 0:139: 'bitwise and' : not supported for this version or the enabled extensions \r
+ERROR: 0:144: 'a' : redefinition \r
+ERROR: 0:149: '' :  syntax error\r
+ERROR: 53 compilation errors.  No code generated.\r
 \r
 ERROR: node is still EOpNull!\r
 0:3  Sequence\r
@@ -226,6 +230,21 @@ ERROR: node is still EOpNull!
 0:134        0.000000\r
 0:135      Constant:\r
 0:135        0.000000\r
+0:137      Bitwise not (mediump int)\r
+0:137        'a' (mediump int)\r
+0:138      inclusive-or (mediump int)\r
+0:138        'a' (mediump int)\r
+0:138        'a' (mediump int)\r
+0:139      bitwise and (mediump int)\r
+0:139        'a' (mediump int)\r
+0:139        'a' (mediump int)\r
+0:144  Function Definition: foo203940(i1;f1;f1; (mediump int)\r
+0:144    Function Parameters: \r
+0:144      'a' (in mediump int)\r
+0:144      'b' (in mediump float)\r
+0:146    Sequence\r
+0:146      Branch: Return with expression\r
+0:146        'a' (in mediump int)\r
 0:?   Linker Objects\r
 0:?     'a' (3-element array of mediump int)\r
 0:?     'uint' (mediump int)\r
index a7e0c5b..5302806 100644 (file)
@@ -2,6 +2,7 @@ ERROR: 0:3: 'float' : type requires declaration of default precision qualifier
 ERROR: 0:3: '' : array size required \r
 ERROR: 0:9: 'arrayed type' : not supported for this version or the enabled extensions \r
 ERROR: 0:9: 'arrayed type' : not supported for this version or the enabled extensions \r
+ERROR: 0:9: 'array in function return type' : not supported for this version or the enabled extensions \r
 ERROR: 0:11: 'arrayed constructor' : not supported for this version or the enabled extensions \r
 ERROR: 0:21: '[' :  array index out of range '2'\r
 ERROR: 0:24: 'array assignment' : not supported for this version or the enabled extensions \r
@@ -15,7 +16,10 @@ ERROR: 0:31: 'array comparison' : not supported for this version or the enabled
 ERROR: 0:35: '[' :  array index out of range '5'\r
 ERROR: 0:38: '[' :  array index out of range '1000'\r
 ERROR: 0:39: '[' :  index out of range '-1'\r
-ERROR: 17 compilation errors.  No code generated.\r
+ERROR: 0:53: 'array in function return type' : not supported for this version or the enabled extensions \r
+ERROR: 0:66: 'array assignment' : not supported for this version or the enabled extensions \r
+ERROR: 0:68: 'array assignment' : not supported for this version or the enabled extensions \r
+ERROR: 21 compilation errors.  No code generated.\r
 \r
 ERROR: node is still EOpNull!\r
 0:9  Function Definition: foo(f1[5]; (4-element array of mediump float)\r
@@ -120,6 +124,25 @@ ERROR: node is still EOpNull!
 0:40          1.000000\r
 0:40          1.000000\r
 0:40          1.000000\r
+0:53  Function Definition: bar9( (structure{v4,sa})\r
+0:53    Function Parameters: \r
+0:?     Sequence\r
+0:56      Branch: Return with expression\r
+0:56        's' (structure{v4,sa})\r
+0:59  Function Definition: bar10(struct-SB-vf4-struct-SA-vf3-vf2[4]11; (void)\r
+0:59    Function Parameters: \r
+0:59      's' (in structure{v4,sa})\r
+0:63  Function Definition: bar11( (void)\r
+0:63    Function Parameters: \r
+0:?     Sequence\r
+0:66      move second child to first child (structure{v4,sa})\r
+0:66        's1' (structure{v4,sa})\r
+0:66        's2' (structure{v4,sa})\r
+0:67      Function Call: bar10(struct-SB-vf4-struct-SA-vf3-vf2[4]11; (void)\r
+0:67        's1' (structure{v4,sa})\r
+0:68      move second child to first child (structure{v4,sa})\r
+0:68        's2' (structure{v4,sa})\r
+0:68        Function Call: bar9( (structure{v4,sa})\r
 0:?   Linker Objects\r
 0:?     'gu' (unsized array of mediump float)\r
 0:?     'g4' (4-element array of mediump float)\r
index ba751b3..0147f7c 100644 (file)
@@ -216,6 +216,18 @@ ERROR: node is still EOpNull!
 0:113        0.000000\r
 0:114      Constant:\r
 0:114        0.000000\r
+0:116      move second child to first child (int)\r
+0:116        'p' (int)\r
+0:116        Constant:\r
+0:116          2147483647 (const int)\r
+0:117      move second child to first child (int)\r
+0:117        'p' (int)\r
+0:117        Constant:\r
+0:117          -2147483648 (const int)\r
+0:118      move second child to first child (int)\r
+0:118        'p' (int)\r
+0:118        Constant:\r
+0:118          -2147483647 (const int)\r
 0:?   Linker Objects\r
 0:?     'a' (const int)\r
 0:?       1 (const int)\r
index 824d630..aa8a94b 100644 (file)
@@ -112,4 +112,8 @@ void foo2()
     m2[-1][1];  // ERROR
     m3[1][3];   // ERROR
     m3[3][1];   // ERROR
-}
\ No newline at end of file
+    int p;
+    p = -2147483647 / -1;
+    p = -2147483648 / -1;
+    p =  2147483647 / -1;
+}
index 1065345..8662d32 100644 (file)
@@ -165,9 +165,11 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
                 break;
 
             case EbtInt:
-                if (rightUnionArray[i] == 0) {
+                if (rightUnionArray[i] == 0)
                     newConstArray[i].setIConst(0x7FFFFFFF);
-                } else
+                else if (rightUnionArray[i].getIConst() == -1 && unionArray[i].getIConst() == 0x80000000)
+                    newConstArray[i].setIConst(0x80000000);
+                else
                     newConstArray[i].setIConst(unionArray[i].getIConst() / rightUnionArray[i].getIConst());
                 break;
 
index 29c2112..12fb3eb 100644 (file)
@@ -758,6 +758,8 @@ TFunction* TParseContext::handleFunctionDeclarator(TSourceLoc loc, TFunction& fu
         }
     }
 
+    arrayObjectCheck(loc, function.getType(), "array in function return type");
+
     // All built-in functions are defined, even though they don't have a body.
     if (symbolTable.atBuiltInLevel())
         function.setDefined();
@@ -831,26 +833,22 @@ TIntermAggregate* TParseContext::handleFunctionDefinition(TSourceLoc loc, TFunct
         TParameter& param = function[i];
         if (param.name != 0) {
             TVariable *variable = new TVariable(param.name, *param.type);
-            //
+
             // Insert the parameters with name in the symbol table.
-            //
             if (! symbolTable.insert(*variable)) {
                 error(loc, "redefinition", variable->getName().c_str(), "");
                 delete variable;
+            } else {
+                // Transfer ownership of name pointer to symbol table.
+                param.name = 0;
+
+                // Add the parameter to the HIL
+                paramNodes = intermediate.growAggregate(paramNodes,
+                                                        intermediate.addSymbol(variable->getUniqueId(),
+                                                                               variable->getName(),
+                                                                               variable->getType(), loc),
+                                                        loc);
             }
-            //
-            // Transfer ownership of name pointer to symbol table.
-            //
-            param.name = 0;
-
-            //
-            // Add the parameter to the HIL
-            //
-            paramNodes = intermediate.growAggregate(paramNodes,
-                                                    intermediate.addSymbol(variable->getUniqueId(),
-                                                                            variable->getName(),
-                                                                            variable->getType(), loc),
-                                                    loc);
         } else
             paramNodes = intermediate.growAggregate(paramNodes, intermediate.addSymbol(0, "", *param.type, loc), loc);
     }
index 1e9cef2..6767dd9 100644 (file)
@@ -441,7 +441,8 @@ unary_operator
     : PLUS  { $$.loc = $1.loc; $$.op = EOpNull; }\r
     | DASH  { $$.loc = $1.loc; $$.op = EOpNegative; }\r
     | BANG  { $$.loc = $1.loc; $$.op = EOpLogicalNot; }\r
-    | TILDE { $$.loc = $1.loc; $$.op = EOpBitwiseNot; }\r
+    | TILDE { $$.loc = $1.loc; $$.op = EOpBitwiseNot;\r
+              parseContext.fullIntegerCheck($1.loc, "bitwise not"); }\r
     ;\r
 // Grammar Note:  No '*' or '&' unary ops.  Pointers are not supported.\r
 \r