diff --git a/Install/Windows/glslangValidator.exe b/Install/Windows/glslangValidator.exe index 7f095f44cad4eb6bf95f549ffcb882c444ec1562..792c066a197e623d26101c08e13faba247bee5d7 100644 Binary files a/Install/Windows/glslangValidator.exe and b/Install/Windows/glslangValidator.exe differ diff --git a/Test/baseResults/300scope.vert.out b/Test/baseResults/300scope.vert.out index 27e07047f864f2b19a711f3bcc79d6c40a59f326..455cd327c656ff6e50d66f9f5b2b4178fc6cc8c5 100644 --- a/Test/baseResults/300scope.vert.out +++ b/Test/baseResults/300scope.vert.out @@ -6,13 +6,15 @@ ERROR: 0:21: 'redefinition of built-in function' : not supported with this profi ERROR: 0:21: 'sin' : redeclaration of existing name ERROR: 0:22: 'redefinition of built-in function' : not supported with this profile: es ERROR: 0:22: 'cos' : redeclaration of existing name +ERROR: 0:22: 'cos' : function already has a body +ERROR: 0:24: 'return' : void function cannot return a value ERROR: 0:26: 'radians' : redeclaration of existing name ERROR: 0:26: 'radians' : can't find function ERROR: 0:28: 'return' : void function cannot return a value ERROR: 0:35: 'local function declaration' : not supported with this profile: es ERROR: 0:54: 'z' : undeclared identifier ERROR: 0:54: 'z' : redefinition -ERROR: 14 compilation errors. No code generated. +ERROR: 16 compilation errors. No code generated. ERROR: node is still EOpNull! 0:3 Function Definition: f(i1;i1;i1; (highp int) diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index a983c05287c6f96c04a13011a15d7ca80b18e139..0af66b28ba882ff6693b84ef3303fe3870a93b55 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -751,6 +751,9 @@ TFunction* TParseContext::handleFunctionDeclarator(TSourceLoc loc, TFunction& fu } } + // All built-in functions are defined, even though they don't have a body. + if (symbolTable.atBuiltInLevel()) + function.setDefined(); if (! symbolTable.insert(function)) error(loc, "redeclaration of existing name", function.getName().c_str(), ""); @@ -764,12 +767,10 @@ TFunction* TParseContext::handleFunctionDeclarator(TSourceLoc loc, TFunction& fu } // -// Handle seeing a function prototype in the grammar. This includes what may -// become a full definition, as a full definition looks like a prototype -// followed by a body. The body is handled after this function -// returns, when present. +// Handle seeing the function prototype in front of a function definition in the grammar. +// The body is handled after this function returns. // -TIntermAggregate* TParseContext::handleFunctionPrototype(TSourceLoc loc, TFunction& function) +TIntermAggregate* TParseContext::handleFunctionDefinition(TSourceLoc loc, TFunction& function) { currentCaller = function.getMangledName(); TSymbol* symbol = symbolTable.find(function.getMangledName()); @@ -777,23 +778,18 @@ TIntermAggregate* TParseContext::handleFunctionPrototype(TSourceLoc loc, TFuncti if (! prevDec) error(loc, "can't find function", function.getName().c_str(), ""); - - // // Note: 'prevDec' could be 'function' if this is the first time we've seen function // as it would have just been put in the symbol table. Otherwise, we're looking up // an earlier occurance. - // + if (prevDec && prevDec->isDefined()) { - // // Then this function already has a body. - // error(loc, "function already has a body", function.getName().c_str(), ""); } - if (prevDec) { + if (prevDec && ! prevDec->isDefined()) { prevDec->setDefined(); - // + // Remember the return type for later checking for RETURN statements. - // currentFunctionType = &(prevDec->getType()); } else currentFunctionType = new TType(EbtVoid); diff --git a/glslang/MachineIndependent/ParseHelper.h b/glslang/MachineIndependent/ParseHelper.h index 2bade69eabae473cc0ea6afa9adabfe002263d65..8b310377bfc94b95e5bb9087a943a23edb1cb8cc 100644 --- a/glslang/MachineIndependent/ParseHelper.h +++ b/glslang/MachineIndependent/ParseHelper.h @@ -88,7 +88,7 @@ public: void checkInputArrayConsistency(TSourceLoc, TLayoutGeometry, TType&, const TString&); TIntermTyped* handleDotDereference(TSourceLoc, TIntermTyped* base, TString& field); TFunction* handleFunctionDeclarator(TSourceLoc loc, TFunction& function); - TIntermAggregate* handleFunctionPrototype(TSourceLoc, TFunction&); + TIntermAggregate* handleFunctionDefinition(TSourceLoc, TFunction&); TIntermTyped* handleFunctionCall(TSourceLoc, TFunction*, TIntermNode*, TIntermAggregate*); void nonOpBuiltInCheck(TSourceLoc, const TFunction&, TIntermAggregate*); TFunction* handleConstructorCall(TSourceLoc, TPublicType&); diff --git a/glslang/MachineIndependent/glslang.y b/glslang/MachineIndependent/glslang.y index bc7d0e278418fe8ba48806b613ee29260587690e..df91311ebf719e9c7ef40c48e33447295c9634dd 100644 --- a/glslang/MachineIndependent/glslang.y +++ b/glslang/MachineIndependent/glslang.y @@ -2389,7 +2389,7 @@ external_declaration function_definition : function_prototype { - $1.intermAggregate = parseContext.handleFunctionPrototype($1.loc, *$1.function); + $1.intermAggregate = parseContext.handleFunctionDefinition($1.loc, *$1.function); } compound_statement_no_new_scope { // May be best done as post process phase on intermediate code