Minor consistency fix: Define built-in functions to have bodies.

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@23985 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich 2013-11-11 04:59:32 +00:00
parent a4351c55e8
commit 359326b866
5 changed files with 14 additions and 16 deletions

Binary file not shown.

View File

@ -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)

View File

@ -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);

View File

@ -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&);

View File

@ -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