From a9b21d22bb9337649723a8477b5cb15f83451e7d Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 17 Feb 2012 06:48:11 +0000 Subject: 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 --- test/CodeGenCXX/static-mutable.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 test/CodeGenCXX/static-mutable.cpp (limited to 'test/CodeGenCXX/static-mutable.cpp') 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; +} -- cgit v1.2.3-18-g5258