From d943455e1023cd2f1bbe977a3d43ca34ac2564f4 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 25 May 2012 10:28:01 -0700 Subject: [PATCH] Issue error on overloaded "export"ed functions. Issue #270. --- module.cpp | 12 ++++++++++++ tests_errors/export-multiple-name.ispc | 5 +++++ 2 files changed, 17 insertions(+) create mode 100644 tests_errors/export-multiple-name.ispc 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) { }