[cfe-commits] r126400 - in /cfe/trunk: lib/AST/Decl.cpp test/SemaCXX/linkage.cpp
Chandler Carruth
chandlerc at gmail.com
Thu Feb 24 11:03:39 PST 2011
Author: chandlerc
Date: Thu Feb 24 13:03:39 2011
New Revision: 126400
URL: http://llvm.org/viewvc/llvm-project?rev=126400&view=rev
Log:
Likely fix for PR9316 and other unknown bugs: don't use the anonynmous
namespace blanket rule for variables and functions declared 'extern
"C"'.
Modified:
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/test/SemaCXX/linkage.cpp
Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=126400&r1=126399&r2=126400&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Thu Feb 24 13:03:39 2011
@@ -266,8 +266,12 @@
return LinkageInfo::internal();
}
- if (D->isInAnonymousNamespace())
- return LinkageInfo::uniqueExternal();
+ if (D->isInAnonymousNamespace()) {
+ const VarDecl *Var = dyn_cast<VarDecl>(D);
+ const FunctionDecl *Func = dyn_cast<FunctionDecl>(D);
+ if ((!Var || !Var->isExternC()) && (!Func || !Func->isExternC()))
+ return LinkageInfo::uniqueExternal();
+ }
// Set up the defaults.
Modified: cfe/trunk/test/SemaCXX/linkage.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/linkage.cpp?rev=126400&r1=126399&r2=126400&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/linkage.cpp (original)
+++ cfe/trunk/test/SemaCXX/linkage.cpp Thu Feb 24 13:03:39 2011
@@ -64,5 +64,10 @@
extern "C" void test3(A a) {}
}
+namespace {
+ // CHECK: define void @test4(
+ extern "C" void test4(void) {}
+}
+
// CHECK: define linkonce_odr i8* @_ZN5test21A1BILj0EE3fooEv(
// CHECK: define linkonce_odr i8* @_ZN5test11A3fooILj0EEEPvv(
More information about the cfe-commits
mailing list