From 92f5afdee0ab2781718d568834f342a196ac5bd1 Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Fri, 30 Aug 2019 09:53:35 -0600 Subject: [PATCH] Placeholder fix for part of #1870. 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 | 12 ++---------- glslang/MachineIndependent/ParseHelper.cpp | 5 +++-- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/Test/baseResults/310.inheritMemory.frag.out b/Test/baseResults/310.inheritMemory.frag.out index 769a096c..6d5528b2 100644 --- a/Test/baseResults/310.inheritMemory.frag.out +++ b/Test/baseResults/310.inheritMemory.frag.out @@ -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) diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 0b0f94ce..33a16641 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -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", "");