]> granicus.if.org Git - clang/commitdiff
Use isExternalLinkage instead of hasExternalLinkage.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 4 Apr 2013 17:16:12 +0000 (17:16 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 4 Apr 2013 17:16:12 +0000 (17:16 +0000)
Having these not be the same makes an easy to misuse API. We should audit the
uses and probably rename to something like

foo->hasExternalLinkage():
  The c++ standard one. That is UniqueExternalLinkage or ExternalLinkage.

foo->hasUniqueExternalLinkage():
  Is UniqueExternalLinkage.

foo->hasCogeGenExternalLinkage():
  Is ExternalLinkage.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178768 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/SemaCXX/linkage2.cpp

index af0b2bb72c2ffbe8a0baa3910de7b3f7c9aa2618..7a537f04e9dd4ccaa1693ffc766eeba81dbfccb8 100644 (file)
@@ -2328,7 +2328,7 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD, Scope *S) {
   // storage classes.
   if (!isa<CXXMethodDecl>(New) && !isa<CXXMethodDecl>(Old) &&
       New->getStorageClass() == SC_Static &&
-      Old->hasExternalLinkage() &&
+      isExternalLinkage(Old->getLinkage()) &&
       !New->getTemplateSpecializationInfo() &&
       !canRedefineFunction(Old, getLangOpts())) {
     if (getLangOpts().MicrosoftExt) {
index d1aee4e55d9438d8590bf910d5f61efd609c7eaf..8a91ca496096116eaaf456c77d435d8839490522 100644 (file)
@@ -140,3 +140,10 @@ namespace test13 {
   extern void a();
   static void a(void) {}
 }
+
+namespace test14 {
+  namespace {
+    void a(void); // expected-note {{previous declaration is here}}
+    static void a(void) {} // expected-error {{static declaration of 'a' follows non-static declaration}}
+  }
+}