diff --git a/module.cpp b/module.cpp index 47c21e34..b5afc875 100644 --- a/module.cpp +++ b/module.cpp @@ -613,6 +613,18 @@ Module::AddFunctionDeclaration(const std::string &name, for (unsigned int i = 0; i < overloadFuncs.size(); ++i) { Symbol *overloadFunc = overloadFuncs[i]; + const FunctionType *overloadType = + CastType(overloadFunc->type); + if (overloadType == NULL) { + Assert(m->errorCount == 0); + continue; + } + + if (functionType->isExported || overloadType->isExported) + Error(pos, "Illegal to have \"export\" function with same name " + "as previously declared function (%s:%d).", + 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)) diff --git a/tests_errors/export-multiple-name.ispc b/tests_errors/export-multiple-name.ispc new file mode 100644 index 00000000..11a2c896 --- /dev/null +++ b/tests_errors/export-multiple-name.ispc @@ -0,0 +1,5 @@ +// Illegal to have "export" function with same name as previously declared function + +export void foo() { } + +export void foo(uniform int x) { }