r176869 - Correctly compute linkage of decls forward declared extern C.
Rafael Espindola
rafael.espindola at gmail.com
Tue Mar 12 08:22:39 PDT 2013
Author: rafael
Date: Tue Mar 12 10:22:39 2013
New Revision: 176869
URL: http://llvm.org/viewvc/llvm-project?rev=176869&view=rev
Log:
Correctly compute linkage of decls forward declared extern C.
This fixes a crash in
namespace {
struct X {};
}
extern "C" X test2_b;
X test2_b
before we would assign different linkages to each of the test2_b decls.
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=176869&r1=176868&r2=176869&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Mar 12 10:22:39 2013
@@ -620,8 +620,7 @@ static LinkageInfo getLVForNamespaceScop
//
// Note that we don't want to make the variable non-external
// because of this, but unique-external linkage suits us.
- if (Context.getLangOpts().CPlusPlus &&
- !Var->getDeclContext()->isExternCContext()) {
+ if (Context.getLangOpts().CPlusPlus && !isInExternCContext(Var)) {
LinkageInfo TypeLV = Var->getType()->getLinkageAndVisibility();
if (TypeLV.getLinkage() != ExternalLinkage)
return LinkageInfo::uniqueExternal();
Modified: cfe/trunk/test/CodeGenCXX/extern-c.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/extern-c.cpp?rev=176869&r1=176868&r2=176869&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/extern-c.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/extern-c.cpp Tue Mar 12 10:22:39 2013
@@ -20,9 +20,19 @@ namespace test1 {
struct X {};
}
extern "C" {
- // CHECK: @b = global
- X b = X();
+ // CHECK: @test1_b = global
+ X test1_b = X();
}
- void *use = &b;
+ void *use = &test1_b;
// CHECK: @_ZN5test13useE = global
}
+
+namespace test2 {
+ namespace {
+ struct X {};
+ }
+
+ // CHECK: @test2_b = global
+ extern "C" X test2_b;
+ X test2_b;
+}
More information about the cfe-commits
mailing list