Disallow redefinition of built-in functions.

TRAC #21173 Issue=343 Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@1206 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent fc0543f4
......@@ -298,6 +298,11 @@ public:
return symbol;
}
TSymbol *findBuiltIn(const TString &name)
{
return table[0]->find(name);
}
TSymbolTableLevel* getGlobalLevel() {
assert(table.size() >= 2);
return table[1];
......
......@@ -2034,6 +2034,15 @@ external_declaration
function_definition
: function_prototype {
TFunction* function = $1.function;
const TSymbol *builtIn = context->symbolTable.findBuiltIn(function->getMangledName());
if (builtIn)
{
context->error($1.line, "built-in functions cannot be redefined", function->getName().c_str());
context->recover();
}
TFunction* prevDec = static_cast<TFunction*>(context->symbolTable.find(function->getMangledName()));
//
// Note: 'prevDec' could be 'function' if this is the first time we've seen function
......
......@@ -4428,6 +4428,15 @@ yyreduce:
{
TFunction* function = (yyvsp[(1) - (1)].interm).function;
const TSymbol *builtIn = context->symbolTable.findBuiltIn(function->getMangledName());
if (builtIn)
{
context->error((yyvsp[(1) - (1)].interm).line, "built-in functions cannot be redefined", function->getName().c_str());
context->recover();
}
TFunction* prevDec = static_cast<TFunction*>(context->symbolTable.find(function->getMangledName()));
//
// Note: 'prevDec' could be 'function' if this is the first time we've seen function
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment