diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2012-12-28 14:21:58 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2012-12-28 14:21:58 +0000 |
commit | 78eeba8c7d53b6b2983c76b77b23b45b89ed939d (patch) | |
tree | aa97877589a2d614de6a73c771e1168b78f13909 /lib/Sema/SemaOverload.cpp | |
parent | ceb59d91b3a7def4297ec8468621805777741963 (diff) |
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
Diffstat (limited to 'lib/Sema/SemaOverload.cpp')
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
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<OverloadableAttr>()) + 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(); |