summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/const-init.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-03-14 22:24:38 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-03-14 22:24:38 +0000
commit8062eb6bede3bb92e8c2e119cc0985ab336247a1 (patch)
tree4b40a67175db996484046991d25e367c5032b501 /clang/test/CodeGenCXX/const-init.cpp
parentb344ac9afe6a2a270cceeea14926873ed58ee507 (diff)
downloadbcm5719-llvm-8062eb6bede3bb92e8c2e119cc0985ab336247a1.tar.gz
bcm5719-llvm-8062eb6bede3bb92e8c2e119cc0985ab336247a1.zip
CodeGen: Correctly initialize bitfields with non-constant initializers
It is possible to construct an initializer for a bitfield which is not constant. Instead of emitting code to initialize the field before the execution of main, clang would crash. llvm-svn: 232285
Diffstat (limited to 'clang/test/CodeGenCXX/const-init.cpp')
-rw-r--r--clang/test/CodeGenCXX/const-init.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/clang/test/CodeGenCXX/const-init.cpp b/clang/test/CodeGenCXX/const-init.cpp
index 3dc8f673030..deb923a7089 100644
--- a/clang/test/CodeGenCXX/const-init.cpp
+++ b/clang/test/CodeGenCXX/const-init.cpp
@@ -1,4 +1,4 @@
-// RUN: not %clang_cc1 -verify -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s
// CHECK: @a = global i32 10
int a = 10;
@@ -76,3 +76,10 @@ int &i = reinterpret_cast<int&>(PR9558);
int arr[2];
// CHECK: @pastEnd = constant i32* bitcast (i8* getelementptr (i8, i8* bitcast ([2 x i32]* @arr to i8*), i64 8) to i32*)
int &pastEnd = arr[2];
+
+struct X {
+ long n : 8;
+};
+long k;
+X x = {(long)&k};
+// CHECK: store i8 ptrtoint (i64* @k to i8), i8* getelementptr inbounds (%struct.X, %struct.X* @x, i32 0, i32 0)
OpenPOWER on IntegriCloud