aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-02-17 06:48:11 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-02-17 06:48:11 +0000
commita9b21d22bb9337649723a8477b5cb15f83451e7d (patch)
treec6d90f7d3c162b2c7713add536ff8f1320ebc7ee /test
parente15c71236252c21a77c8a406246053e1cbb63ffa (diff)
Bug fix: do not emit static const local variables with mutable members
as constants. Refactor and simplify all the separate checks for whether a type can be emitted as a constant. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150793 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/CodeGenCXX/static-mutable.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/CodeGenCXX/static-mutable.cpp b/test/CodeGenCXX/static-mutable.cpp
new file mode 100644
index 0000000000..6d51f241d1
--- /dev/null
+++ b/test/CodeGenCXX/static-mutable.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -triple=i686-linux-gnu -emit-llvm -o - | FileCheck %s
+
+struct S {
+ mutable int n;
+};
+int f() {
+ // The purpose of this test is to ensure that this variable is a global
+ // not a constant.
+ // CHECK: @_ZZ1fvE1s = internal global {{.*}} { i32 12 }
+ static const S s = { 12 };
+ return ++s.n;
+}