Make the "switch-label not followed by statement" warning an error, depending on...
authorJohn Kessenich <cepheus@frii.com>
Fri, 26 Jun 2015 18:24:28 +0000 (12:24 -0600)
committerJohn Kessenich <cepheus@frii.com>
Fri, 26 Jun 2015 18:24:28 +0000 (12:24 -0600)
Test/baseResults/spv.switch.frag.out
Test/baseResults/switch.frag.out
Test/spv.switch.frag
glslang/MachineIndependent/ParseHelper.cpp

index 9ae9790..6f3f865 100644 (file)
@@ -1,4 +1,5 @@
 spv.switch.frag\r
+Warning, version 310 is not yet complete; most version-specific features are present, but some are missing.\r
 WARNING: 0:121: 'switch' : last case/default label not followed by statements \r
 WARNING: 0:134: 'switch' : last case/default label not followed by statements \r
 WARNING: 0:139: 'switch' : last case/default label not followed by statements \r
@@ -11,7 +12,7 @@ Linked fragment stage:
 // Generated by (magic number): 51a00bb\r
 // Id's are bound by 261\r
 \r
-                              Source ESSL 300\r
+                              Source ESSL 310\r
                1:             ExtInstImport  "GLSL.std.450"\r
                               MemoryModel Logical GLSL450\r
                               EntryPoint Fragment 4\r
index ff42d88..a500270 100644 (file)
@@ -1,7 +1,7 @@
 switch.frag\r
 ERROR: 0:11: 'switch' : condition must be a scalar integer expression \r
 ERROR: 0:14: 'switch' : condition must be a scalar integer expression \r
-WARNING: 0:21: 'switch' : last case/default label not followed by statements \r
+ERROR: 0:21: 'switch' : last case/default label not followed by statements \r
 ERROR: 0:28: 'switch' : cannot have statements before first case/default label \r
 ERROR: 0:43: 'default' : duplicate label \r
 ERROR: 0:63: 'case' : duplicated value \r
@@ -15,10 +15,10 @@ ERROR: 0:115: 'default' : cannot be nested inside control flow
 ERROR: 0:119: 'case' : cannot appear outside switch statement \r
 ERROR: 0:120: 'default' : cannot appear outside switch statement \r
 ERROR: 0:126: 'onlyInSwitch' : undeclared identifier \r
-WARNING: 0:128: 'switch' : last case/default label not followed by statements \r
+ERROR: 0:128: 'switch' : last case/default label not followed by statements \r
 ERROR: 0:140: 'nestedX' : undeclared identifier \r
 ERROR: 0:157: 'nestedZ' : undeclared identifier \r
-ERROR: 17 compilation errors.  No code generated.\r
+ERROR: 19 compilation errors.  No code generated.\r
 \r
 \r
 Shader version: 300\r
index c131c91..828b069 100644 (file)
@@ -1,4 +1,4 @@
-#version 300 es\r
+#version 310 es\r
 precision mediump float;\r
 uniform int c, d;\r
 in float x;\r
index 0e76adf..28d8792 100644 (file)
@@ -5186,8 +5186,16 @@ TIntermNode* TParseContext::addSwitch(TSourceLoc loc, TIntermTyped* expression,
     if (switchSequence->size() == 0)
         return expression;
 
-    if (lastStatements == 0)
-        warn(loc, "last case/default label not followed by statements", "switch", "");
+    if (lastStatements == 0) {
+        // This was originally an ERRROR, because early versions of the specification said
+        // "it is an error to have no statement between a label and the end of the switch statement."
+        // The specifications were updated to remove this (being ill-defined what a "statement" was),
+        // so, this became a warning.  However, 3.0 tests still check for the error.
+        if (profile == EEsProfile && version <= 300 && (messages & EShMsgRelaxedErrors) == 0)
+            error(loc, "last case/default label not followed by statements", "switch", "");
+        else
+            warn(loc, "last case/default label not followed by statements", "switch", "");
+    }
 
     TIntermAggregate* body = new TIntermAggregate(EOpSequence);
     body->getSequence() = *switchSequenceStack.back();