Placeholder fix for part of #1870.
authorJohn Kessenich <cepheus@frii.com>
Fri, 30 Aug 2019 15:53:35 +0000 (09:53 -0600)
committerJohn Kessenich <cepheus@frii.com>
Fri, 30 Aug 2019 16:06:16 +0000 (10:06 -0600)
Also fixes, in practice, https://github.com/KhronosGroup/GLSL/issues/83.
When the specification language is correctly created, glslang can be
revisited for correctness.  In the meantime, this seems like the best
"bug" to have relative to the specification.

Memory qualifiers are only relevant to parameters when they apply
to what the argument points to, as otherwise the argument is copied.

This leaves the fix from #1870 in place, and then more correctly
ignores memory qualifiers when something will be passed by copy.

Test/baseResults/310.inheritMemory.frag.out
glslang/MachineIndependent/ParseHelper.cpp

index 769a096..6d5528b 100644 (file)
@@ -1,14 +1,6 @@
 310.inheritMemory.frag
-ERROR: 0:38: 'readonly' : argument cannot drop memory qualifier when passed to formal parameter 
-ERROR: 0:39: 'readonly' : argument cannot drop memory qualifier when passed to formal parameter 
-ERROR: 0:40: 'readonly' : argument cannot drop memory qualifier when passed to formal parameter 
-ERROR: 0:41: 'readonly' : argument cannot drop memory qualifier when passed to formal parameter 
-ERROR: 0:42: 'readonly' : argument cannot drop memory qualifier when passed to formal parameter 
-ERROR: 5 compilation errors.  No code generated.
-
-
 Shader version: 310
-ERROR: node is still EOpNull!
+0:? Sequence
 0:18  Function Definition: non_ro_fun(f1[10]; ( global void)
 0:18    Function Parameters: 
 0:18      'buff' ( in 10-element array of mediump float)
@@ -120,7 +112,7 @@ Linked fragment stage:
 
 
 Shader version: 310
-ERROR: node is still EOpNull!
+0:? Sequence
 0:18  Function Definition: non_ro_fun(f1[10]; ( global void)
 0:18    Function Parameters: 
 0:18      'buff' ( in 10-element array of mediump float)
index 0b0f94c..33a1664 100644 (file)
@@ -1152,8 +1152,9 @@ TIntermTyped* TParseContext::handleFunctionCall(const TSourceLoc& loc, TFunction
                         if (lValueErrorCheck(arguments->getLoc(), "assign", arg->getAsTyped()))
                             error(arguments->getLoc(), "Non-L-value cannot be passed for 'out' or 'inout' parameters.", "out", "");
                     }
-                    TQualifier& argQualifier = arg->getAsTyped()->getQualifier();
-                    if (argQualifier.isMemory()) {
+                    const TType& argType = arg->getAsTyped()->getType();
+                    const TQualifier& argQualifier = argType.getQualifier();
+                    if (argQualifier.isMemory() && (argType.containsOpaque() || argType.isReference())) {
                         const char* message = "argument cannot drop memory qualifier when passed to formal parameter";
                         if (argQualifier.volatil && ! formalQualifier.volatil)
                             error(arguments->getLoc(), message, "volatile", "");