Reject shaders that invoke functions hidden by variable or struct name.
BUG=22
Review URL: http://codereview.appspot.com/1855057
git-svn-id: https://angleproject.googlecode.com/svn/trunk@375 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/ParseHelper.cpp b/src/compiler/ParseHelper.cpp
index e3d62f6..c52bcbb 100644
--- a/src/compiler/ParseHelper.cpp
+++ b/src/compiler/ParseHelper.cpp
@@ -913,21 +913,24 @@
//
const TFunction* TParseContext::findFunction(int line, TFunction* call, bool *builtIn)
{
- const TSymbol* symbol = symbolTable.find(call->getMangledName(), builtIn);
+ // First find by unmangled name to check whether the function name has been
+ // hidden by a variable name or struct typename.
+ const TSymbol* symbol = symbolTable.find(call->getName(), builtIn);
+ if (symbol == 0) {
+ symbol = symbolTable.find(call->getMangledName(), builtIn);
+ }
- if (symbol == 0) {
+ if (symbol == 0) {
error(line, "no matching overloaded function found", call->getName().c_str(), "");
return 0;
}
- if (! symbol->isFunction()) {
+ if (!symbol->isFunction()) {
error(line, "function name expected", call->getName().c_str(), "");
return 0;
}
-
- const TFunction* function = static_cast<const TFunction*>(symbol);
-
- return function;
+
+ return static_cast<const TFunction*>(symbol);
}
//