diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-12-21 03:17:28 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-12-21 03:17:28 +0000 |
commit | d82a2ce3a08f1f67143e68547828f0963b333e7a (patch) | |
tree | 15f97880e137ec749ac74b6bb26086dfa3dea26d /clang/test | |
parent | 59421aee3dc819081097ccbc65c97ee3a7b8bdaa (diff) | |
download | bcm5719-llvm-d82a2ce3a08f1f67143e68547828f0963b333e7a.tar.gz bcm5719-llvm-d82a2ce3a08f1f67143e68547828f0963b333e7a.zip |
Reinstate r170806, reverted in r170835, with a fix use i1 instead of i8 for a value-initialized bool!
llvm-svn: 170837
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/CodeGenCXX/cxx0x-initializer-array.cpp | 40 | ||||
-rw-r--r-- | clang/test/CodeGenCXX/value-init.cpp | 6 |
2 files changed, 46 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/cxx0x-initializer-array.cpp b/clang/test/CodeGenCXX/cxx0x-initializer-array.cpp index df689978a88..5e81ba1ff9d 100644 --- a/clang/test/CodeGenCXX/cxx0x-initializer-array.cpp +++ b/clang/test/CodeGenCXX/cxx0x-initializer-array.cpp @@ -1,5 +1,7 @@ // RUN: %clang_cc1 -triple i386-unknown-unknown -std=c++11 -S -emit-llvm -o - %s | FileCheck %s +// CHECK: @[[THREE_NULL_MEMPTRS:.*]] = private constant [3 x i32] [i32 -1, i32 -1, i32 -1] + struct A { int a[1]; }; typedef A x[]; int f() { @@ -7,4 +9,42 @@ int f() { // CHECK: define i32 @_Z1fv // CHECK: store i32 1 // (It's okay if the output changes here, as long as we don't crash.) + return 0; +} + +namespace ValueInitArrayOfMemPtr { + struct S {}; + typedef int (S::*p); + typedef p a[3]; + void f(const a &); + + struct Agg1 { + int n; + p x; + }; + + struct Agg2 { + int n; + a x; + }; + + struct S1 { + p x; + S1(); + }; + + // CHECK: define void @_ZN22ValueInitArrayOfMemPtr1fEi + void f(int n) { + Agg1 a = { n }; + // CHECK: store i32 -1, + + Agg2 b = { n }; + // CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %{{.*}}, i8* bitcast ([3 x i32]* @[[THREE_NULL_MEMPTRS]] to i8*), i32 12, i32 4, i1 false) + } + + // CHECK: define void @_ZN22ValueInitArrayOfMemPtr1gEv + void g() { + // CHECK: store i32 -1, + f(a{}); + } } diff --git a/clang/test/CodeGenCXX/value-init.cpp b/clang/test/CodeGenCXX/value-init.cpp index 6e60f801105..60dca99045f 100644 --- a/clang/test/CodeGenCXX/value-init.cpp +++ b/clang/test/CodeGenCXX/value-init.cpp @@ -256,6 +256,12 @@ namespace PR11124 { // CHECK-NEXT: call void @_ZN7PR111242B2C2Ev } +// Ensure we produce an i1 here, and don't assert. +// CHECK: define void @_Z9r170806_bv( +// CHECK: call void @_Z9r170806_ab(i1 zeroext false) +void r170806_a(bool b = bool()); +void r170806_b() { r170806_a(); } + // CHECK: define linkonce_odr void @_ZN8zeroinit2X3IiEC2Ev(%"struct.zeroinit::X3"* %this) unnamed_addr // CHECK: call void @llvm.memset.p0i8.i64 // CHECK-NEXT: call void @_ZN8zeroinit2X2IiEC2Ev |