[cfe-commits] r166269 - in /cfe/trunk: lib/AST/Decl.cpp test/CodeGenCXX/const-global-linkage.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Thu Oct 18 23:37:48 PDT 2012
Author: rsmith
Date: Fri Oct 19 01:37:48 2012
New Revision: 166269
URL: http://llvm.org/viewvc/llvm-project?rev=166269&view=rev
Log:
DR1511: A const volatile global does not implicitly get internal linkage like a
const non-volatile global does.
Modified:
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/test/CodeGenCXX/const-global-linkage.cpp
Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=166269&r1=166268&r2=166269&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Fri Oct 19 01:37:48 2012
@@ -213,12 +213,12 @@
if (Var->getStorageClass() == SC_Static)
return LinkageInfo::internal();
- // - an object or reference that is explicitly declared const
- // and neither explicitly declared extern nor previously
- // declared to have external linkage; or
- // (there is no equivalent in C99)
+ // - a non-volatile object or reference that is explicitly declared const
+ // or constexpr and neither explicitly declared extern nor previously
+ // declared to have external linkage; or (there is no equivalent in C99)
if (Context.getLangOpts().CPlusPlus &&
- Var->getType().isConstant(Context) &&
+ Var->getType().isConstQualified() &&
+ !Var->getType().isVolatileQualified() &&
Var->getStorageClass() != SC_Extern &&
Var->getStorageClass() != SC_PrivateExtern) {
bool FoundExtern = false;
Modified: cfe/trunk/test/CodeGenCXX/const-global-linkage.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/const-global-linkage.cpp?rev=166269&r1=166268&r2=166269&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/const-global-linkage.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/const-global-linkage.cpp Fri Oct 19 01:37:48 2012
@@ -2,12 +2,16 @@
const int x = 10;
const int y = 20;
+const volatile int z = 30;
// CHECK-NOT: @x
+// CHECK: @z = constant i32 30
// CHECK: @_ZL1y = internal constant i32 20
const int& b() { return y; }
const char z1[] = "asdf";
const char z2[] = "zxcv";
+const volatile char z3[] = "zxcv";
// CHECK-NOT: @z1
+// CHECK: @z3 = constant
// CHECK: @_ZL2z2 = internal constant
const char* b2() { return z2; }
More information about the cfe-commits
mailing list