r201537 - PR18839: 'extern "C++"' also adds an implicit 'extern', not just 'extern "C"'.

Richard Smith richard-llvm at metafoo.co.uk
Mon Feb 17 15:34:47 PST 2014


Author: rsmith
Date: Mon Feb 17 17:34:47 2014
New Revision: 201537

URL: http://llvm.org/viewvc/llvm-project?rev=201537&view=rev
Log:
PR18839: 'extern "C++"' also adds an implicit 'extern', not just 'extern "C"'.

Modified:
    cfe/trunk/lib/AST/Decl.cpp
    cfe/trunk/test/CodeGenCXX/extern-c.cpp

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=201537&r1=201536&r2=201537&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Mon Feb 17 17:34:47 2014
@@ -512,9 +512,9 @@ template <typename T> static bool isFirs
   return First->isInExternCContext();
 }
 
-static bool isSingleLineExternC(const Decl &D) {
+static bool isSingleLineLanguageLinkage(const Decl &D) {
   if (const LinkageSpecDecl *SD = dyn_cast<LinkageSpecDecl>(D.getDeclContext()))
-    if (SD->getLanguage() == LinkageSpecDecl::lang_c && !SD->hasBraces())
+    if (!SD->hasBraces())
       return true;
   return false;
 }
@@ -548,7 +548,7 @@ static LinkageInfo getLVForNamespaceScop
 
       if (Var->getStorageClass() != SC_Extern &&
           Var->getStorageClass() != SC_PrivateExtern &&
-          !isSingleLineExternC(*Var))
+          !isSingleLineLanguageLinkage(*Var))
         return LinkageInfo::internal();
     }
 
@@ -1771,7 +1771,7 @@ VarDecl::DefinitionKind VarDecl::isThisD
   //   A declaration directly contained in a linkage-specification is treated
   //   as if it contains the extern specifier for the purpose of determining
   //   the linkage of the declared name and whether it is a definition.
-  if (isSingleLineExternC(*this))
+  if (isSingleLineLanguageLinkage(*this))
     return DeclarationOnly;
 
   // C99 6.9.2p2:

Modified: cfe/trunk/test/CodeGenCXX/extern-c.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/extern-c.cpp?rev=201537&r1=201536&r2=201537&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/extern-c.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/extern-c.cpp Mon Feb 17 17:34:47 2014
@@ -1,18 +1,22 @@
 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck %s
 namespace foo {
 
-// CHECK-NOT: @a = global i32
+// CHECK-NOT: @a = global
 extern "C" int a;
 
-// CHECK-NOT: @_ZN3foo1bE = global i32
+// CHECK-NOT: @_ZN3foo1bE = global
 extern int b;
 
-// CHECK: @_ZN3foo1cE = global i32
+// CHECK: @_ZN3foo1cE = global
 int c = 5;
 
 // CHECK-NOT: @_ZN3foo1dE
 extern "C" struct d;
 
+// CHECK-NOT: @e = global
+// CHECK-NOT: @_ZN3foo1eE = global
+extern "C++" int a2;
+
 }
 
 namespace test1 {





More information about the cfe-commits mailing list