From 78eeba8c7d53b6b2983c76b77b23b45b89ed939d Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 28 Dec 2012 14:21:58 +0000 Subject: Reject overloading of two static extern C functions. This patch moves hasCLanguageLinkage to be VarDecl and FunctionDecl methods so that they can be used from SemaOverload.cpp and then fixes the logic in Sema::IsOverload. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171193 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaOverload.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib/Sema/SemaOverload.cpp') diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 7ae6d9d5af..02584525c9 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -930,11 +930,19 @@ Sema::CheckOverload(Scope *S, FunctionDecl *New, const LookupResult &Old, return Ovl_Overload; } +static bool canBeOverloaded(const FunctionDecl &D) { + if (D.getAttr()) + return true; + if (D.hasCLanguageLinkage()) + return false; + return true; +} + bool Sema::IsOverload(FunctionDecl *New, FunctionDecl *Old, bool UseUsingDeclRules) { // If both of the functions are extern "C", then they are not // overloads. - if (Old->isExternC() && New->isExternC()) + if (!canBeOverloaded(*Old) && !canBeOverloaded(*New)) return false; FunctionTemplateDecl *OldTemplate = Old->getDescribedFunctionTemplate(); -- cgit v1.2.3-70-g09d2