Give error for calling a user-defined function at global scope.

This commit is contained in:
John Kessenich 2015-10-06 13:11:38 -06:00
parent 894c1c109f
commit 820a22fcc8
5 changed files with 32 additions and 6 deletions

View file

@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits.
// For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "3.0.779"
#define GLSLANG_DATE "05-Oct-2015"
#define GLSLANG_REVISION "3.0.780"
#define GLSLANG_DATE "06-Oct-2015"

View file

@ -1124,7 +1124,10 @@ TIntermTyped* TParseContext::handleFunctionCall(const TSourceLoc& loc, TFunction
// if builtIn == true, it's definitely a built-in function with EOpNull
if (! builtIn) {
call->setUserDefined();
intermediate.addToCallGraph(infoSink, currentCaller, fnCandidate->getMangledName());
if (symbolTable.atGlobalLevel())
error(loc, "can't call user function from global scope", fnCandidate->getName().c_str(), "");
else
intermediate.addToCallGraph(infoSink, currentCaller, fnCandidate->getMangledName());
}
if (builtIn)

View file

@ -323,7 +323,7 @@ protected:
TQualifier globalInputDefaults;
TQualifier globalOutputDefaults;
int* atomicUintOffsets; // to become an array of the right size to hold an offset per binding point
TString currentCaller;
TString currentCaller; // name of last function body entered (not valid when at global scope)
TIdSetType inductiveLoopIds;
bool anyIndexLimits;
TVector<TIntermTyped*> needsIndexLimitationChecking;