From a23a7006e352cc28132a9ba9a0ced518bbf20c73 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 15 Jun 2012 10:54:50 -0700 Subject: [PATCH] Don't issue error incorrectly with forward decl. of exported function. Issue #281. --- module.cpp | 16 +++++++++------- tests_errors/export-multiple-name.ispc | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/module.cpp b/module.cpp index e751f6ed..c8fbf3d7 100644 --- a/module.cpp +++ b/module.cpp @@ -634,16 +634,18 @@ Module::AddFunctionDeclaration(const std::string &name, 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 + // Check for a redeclaration of a function with the same name + // and type. This also hits when we have previously declared + // the function and are about to define it. if (Type::Equal(overloadFunc->type, functionType)) 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 // different, return an error--overloading by return type isn't // allowed. diff --git a/tests_errors/export-multiple-name.ispc b/tests_errors/export-multiple-name.ispc index 11a2c896..8abb2e43 100644 --- a/tests_errors/export-multiple-name.ispc +++ b/tests_errors/export-multiple-name.ispc @@ -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() { }