Don't issue error incorrectly with forward decl. of exported function.

Issue #281.
This commit is contained in:
Matt Pharr
2012-06-15 10:54:50 -07:00
parent f47171a17c
commit a23a7006e3
2 changed files with 10 additions and 8 deletions

View File

@@ -634,16 +634,18 @@ Module::AddFunctionDeclaration(const std::string &name,
continue; continue;
} }
if (functionType->isExported || overloadType->isExported) // Check for a redeclaration of a function with the same name
Error(pos, "Illegal to have \"export\" function with same name " // and type. This also hits when we have previously declared
"as previously declared function (%s:%d).", // the function and are about to define it.
overloadFunc->pos.name, overloadFunc->pos.first_line);
// Check for a redeclaration of a function with the same
// name and type
if (Type::Equal(overloadFunc->type, functionType)) if (Type::Equal(overloadFunc->type, functionType))
return; return;
if (functionType->isExported || overloadType->isExported)
Error(pos, "Illegal to provide \"export\" qualifier for "
"functions with the same name but different types. "
"(Previous function declaration (%s:%d).)",
overloadFunc->pos.name, overloadFunc->pos.first_line);
// If all of the parameter types match but the return type is // If all of the parameter types match but the return type is
// different, return an error--overloading by return type isn't // different, return an error--overloading by return type isn't
// allowed. // allowed.

View File

@@ -1,4 +1,4 @@
// Illegal to have "export" function with same name as previously declared function // Illegal to provide "export" qualifier for functions with the same name but different types
export void foo() { } export void foo() { }