aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGenCXX/static-data-member.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-02-16 20:41:22 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-02-16 20:41:22 +0000
commitb9c64d84ea3edd5e2fffb0a2e85ca1308be4f429 (patch)
tree12059791aa88a3a99c5af19ca92d1c2300c67519 /test/CodeGenCXX/static-data-member.cpp
parent437ee81e54f39c2363d5fe0ea155604c28adc615 (diff)
C++11 allows unions to have static data members. Remove the corresponding
restriction and add some tests. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150721 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/static-data-member.cpp')
-rw-r--r--test/CodeGenCXX/static-data-member.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/CodeGenCXX/static-data-member.cpp b/test/CodeGenCXX/static-data-member.cpp
index 4eeda3d428..4ad339db98 100644
--- a/test/CodeGenCXX/static-data-member.cpp
+++ b/test/CodeGenCXX/static-data-member.cpp
@@ -5,6 +5,12 @@
// CHECK: @_ZN5test31AIiE1xE = weak_odr global i32 0, align 4
// CHECK: @_ZGVN5test31AIiE1xE = weak_odr global i64 0
+// CHECK: _ZN5test51U2k0E = global i32 0
+// CHECK: _ZN5test51U2k1E = global i32 0
+// CHECK: _ZN5test51U2k2E = constant i32 76
+// CHECK-NOT: test51U2k3E
+// CHECK-NOT: test51U2k4E
+
// PR5564.
namespace test1 {
struct A {
@@ -78,3 +84,21 @@ namespace test4 {
return a->n;
}
}
+
+// Test that static data members in unions behave properly.
+namespace test5 {
+ union U {
+ static int k0;
+ static const int k1;
+ static const int k2 = 76;
+ static const int k3;
+ static const int k4 = 81;
+ };
+ int U::k0;
+ const int U::k1 = (k0 = 9, 42);
+ const int U::k2;
+
+ // CHECK: store i32 9, i32* @_ZN5test51U2k0E
+ // CHECK: store i32 {{.*}}, i32* @_ZN5test51U2k1E
+ // CHECK-NOT: store {{.*}} i32* @_ZN5test51U2k2E
+}