]> granicus.if.org Git - clang/commitdiff
PR18839: 'extern "C++"' also adds an implicit 'extern', not just 'extern "C"'.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 17 Feb 2014 23:34:47 +0000 (23:34 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 17 Feb 2014 23:34:47 +0000 (23:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201537 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Decl.cpp
test/CodeGenCXX/extern-c.cpp

index 1a7e8f7af8cc66c579fb9cafadf0b41b5aeecbe3..ee9f07278f213770372bb3d461bd0fdcd0e3962d 100644 (file)
@@ -512,9 +512,9 @@ template <typename T> static bool isFirstInExternCContext(T *D) {
   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 getLVForNamespaceScopeDecl(const NamedDecl *D,
 
       if (Var->getStorageClass() != SC_Extern &&
           Var->getStorageClass() != SC_PrivateExtern &&
-          !isSingleLineExternC(*Var))
+          !isSingleLineLanguageLinkage(*Var))
         return LinkageInfo::internal();
     }
 
@@ -1771,7 +1771,7 @@ VarDecl::DefinitionKind VarDecl::isThisDeclarationADefinition(
   //   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:
index bca86c6352cf312bd42cd835d0144d4df12ae43b..f8d334cc858f32fe250d466c72ac7fbca4f9bb7a 100644 (file)
@@ -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 {