diff options
Diffstat (limited to 'test/CodeGenCXX')
-rw-r--r-- | test/CodeGenCXX/anonymous-union-member-initializer.cpp | 4 | ||||
-rw-r--r-- | test/CodeGenCXX/conditional-gnu-ext.cpp | 142 | ||||
-rw-r--r-- | test/CodeGenCXX/debug-info-limit.cpp | 14 | ||||
-rw-r--r-- | test/CodeGenCXX/exceptions.cpp | 12 | ||||
-rw-r--r-- | test/CodeGenCXX/gnu-conditional-scalar-ext.cpp | 62 | ||||
-rw-r--r-- | test/CodeGenCXX/mangle-exprs.cpp | 9 |
6 files changed, 178 insertions, 65 deletions
diff --git a/test/CodeGenCXX/anonymous-union-member-initializer.cpp b/test/CodeGenCXX/anonymous-union-member-initializer.cpp index d97a2ae..85e931b 100644 --- a/test/CodeGenCXX/anonymous-union-member-initializer.cpp +++ b/test/CodeGenCXX/anonymous-union-member-initializer.cpp @@ -84,11 +84,11 @@ namespace test3 { // CHECK: define void @_ZN5test31AC2Ev( // CHECK: [[THIS:%.*]] = load // CHECK-NEXT: [[UNION:%.*]] = getelementptr inbounds {{.*}} [[THIS]], i32 0, i32 0 - // CHECK-NEXT: [[STRUCT:%.*]] = getelementptr inbounds {{.*}} [[UNION]], i32 0, i32 0 + // CHECK-NEXT: [[STRUCT:%.*]] = bitcast {{.*}}* [[UNION]] to // CHECK-NEXT: [[CALLBACK:%.*]] = getelementptr inbounds {{.*}} [[STRUCT]], i32 0, i32 0 // CHECK-NEXT: store void (i8*)* null, void (i8*)** [[CALLBACK]] // CHECK-NEXT: [[UNION:%.*]] = getelementptr inbounds {{.*}} [[THIS]], i32 0, i32 0 - // CHECK-NEXT: [[STRUCT:%.*]] = getelementptr inbounds {{.*}} [[UNION]], i32 0, i32 0 + // CHECK-NEXT: [[STRUCT:%.*]] = bitcast {{.*}}* [[UNION]] to // CHECK-NEXT: [[CVALUE:%.*]] = getelementptr inbounds {{.*}} [[STRUCT]], i32 0, i32 1 // CHECK-NEXT: store i8* null, i8** [[CVALUE]] } diff --git a/test/CodeGenCXX/conditional-gnu-ext.cpp b/test/CodeGenCXX/conditional-gnu-ext.cpp new file mode 100644 index 0000000..46c5e7f --- /dev/null +++ b/test/CodeGenCXX/conditional-gnu-ext.cpp @@ -0,0 +1,142 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s +// rdar: // 8353567 +// pr7726 + +extern "C" int printf(...); + +void test0() { +// CHECK: call i32 (...)* @printf({{.*}}, i8* inttoptr (i64 3735928559 to i8*)) + printf("%p\n", (void *)0xdeadbeef ? : (void *)0xaaaaaa); +} + +// rdar://8446940 +namespace radar8446940 { +extern "C" void abort(); + +int main () { + char x[1]; + char *y = x ? : 0; + + if (x != y) + abort(); +} +} + +namespace radar8453812 { +extern "C" void abort(); +_Complex int getComplex(_Complex int val) { + static int count; + if (count++) + abort(); + return val; +} + +_Complex int cmplx() { + _Complex int cond; + _Complex int rhs; + + return getComplex(1+2i) ? : rhs; +} + +// lvalue test +void foo (int& lv) { + ++lv; +} + +int global = 1; + +int &cond() { + static int count; + if (count++) + abort(); + return global; +} + + +int main() { + cmplx(); + int rhs = 10; + foo (cond()? : rhs); + return global-2; +} +} + +namespace test3 { + struct A { + A(); + A(const A&); + ~A(); + }; + + struct B { + B(); + B(const B&); + ~B(); + operator bool(); + operator A(); + }; + + B test0(B &x) { + // CHECK: define void @_ZN5test35test0ERNS_1BE( + // CHECK: [[X:%.*]] = alloca [[B:%.*]]*, + // CHECK-NEXT: store [[B]]* {{%.*}}, [[B]]** [[X]] + // CHECK-NEXT: [[T0:%.*]] = load [[B]]** [[X]] + // CHECK-NEXT: [[BOOL:%.*]] = call zeroext i1 @_ZN5test31BcvbEv([[B]]* [[T0]]) + // CHECK-NEXT: br i1 [[BOOL]] + // CHECK: call void @_ZN5test31BC1ERKS0_([[B]]* [[RESULT:%.*]], [[B]]* [[T0]]) + // CHECK-NEXT: br label + // CHECK: call void @_ZN5test31BC1Ev([[B]]* [[RESULT]]) + // CHECK-NEXT: br label + // CHECK: ret void + return x ?: B(); + } + + B test1() { + // CHECK: define void @_ZN5test35test1Ev( + // CHECK: [[TEMP:%.*]] = alloca [[B]], + // CHECK-NEXT: call void @_ZN5test312test1_helperEv([[B]]* sret [[TEMP]]) + // CHECK-NEXT: [[BOOL:%.*]] = call zeroext i1 @_ZN5test31BcvbEv([[B]]* [[TEMP]]) + // CHECK-NEXT: br i1 [[BOOL]] + // CHECK: call void @_ZN5test31BC1ERKS0_([[B]]* [[RESULT:%.*]], [[B]]* [[TEMP]]) + // CHECK-NEXT: br label + // CHECK: call void @_ZN5test31BC1Ev([[B]]* [[RESULT]]) + // CHECK-NEXT: br label + // CHECK: call void @_ZN5test31BD1Ev([[B]]* [[TEMP]]) + // CHECK-NEXT: ret void + extern B test1_helper(); + return test1_helper() ?: B(); + } + + + A test2(B &x) { + // CHECK: define void @_ZN5test35test2ERNS_1BE( + // CHECK: [[X:%.*]] = alloca [[B]]*, + // CHECK-NEXT: store [[B]]* {{%.*}}, [[B]]** [[X]] + // CHECK-NEXT: [[T0:%.*]] = load [[B]]** [[X]] + // CHECK-NEXT: [[BOOL:%.*]] = call zeroext i1 @_ZN5test31BcvbEv([[B]]* [[T0]]) + // CHECK-NEXT: br i1 [[BOOL]] + // CHECK: call void @_ZN5test31BcvNS_1AEEv([[A:%.*]]* sret [[RESULT:%.*]], [[B]]* [[T0]]) + // CHECK-NEXT: br label + // CHECK: call void @_ZN5test31AC1Ev([[A]]* [[RESULT]]) + // CHECK-NEXT: br label + // CHECK: ret void + return x ?: A(); + } + + A test3() { + // CHECK: define void @_ZN5test35test3Ev( + // CHECK: [[TEMP:%.*]] = alloca [[B]], + // CHECK-NEXT: call void @_ZN5test312test3_helperEv([[B]]* sret [[TEMP]]) + // CHECK-NEXT: [[BOOL:%.*]] = call zeroext i1 @_ZN5test31BcvbEv([[B]]* [[TEMP]]) + // CHECK-NEXT: br i1 [[BOOL]] + // CHECK: call void @_ZN5test31BcvNS_1AEEv([[A]]* sret [[RESULT:%.*]], [[B]]* [[TEMP]]) + // CHECK-NEXT: br label + // CHECK: call void @_ZN5test31AC1Ev([[A]]* [[RESULT]]) + // CHECK-NEXT: br label + // CHECK: call void @_ZN5test31BD1Ev([[B]]* [[TEMP]]) + // CHECK-NEXT: ret void + extern B test3_helper(); + return test3_helper() ?: A(); + } + +} diff --git a/test/CodeGenCXX/debug-info-limit.cpp b/test/CodeGenCXX/debug-info-limit.cpp new file mode 100644 index 0000000..75f9271 --- /dev/null +++ b/test/CodeGenCXX/debug-info-limit.cpp @@ -0,0 +1,14 @@ +// RUN: %clang -emit-llvm -g -S %s -o - | FileCheck %s + +// TAG_member is used to encode debug info for class constructor. +// CHECK: TAG_member +class A { +public: + int z; +}; + +A *foo () { + A *a = new A(); + return a; +} + diff --git a/test/CodeGenCXX/exceptions.cpp b/test/CodeGenCXX/exceptions.cpp index 84d55c8..8081818 100644 --- a/test/CodeGenCXX/exceptions.cpp +++ b/test/CodeGenCXX/exceptions.cpp @@ -293,3 +293,15 @@ namespace test5 { } } } + +// PR9303: invalid assert on this +namespace test6 { + bool cond(); + void test() { + try { + lbl: + if (cond()) goto lbl; + } catch (...) { + } + } +} diff --git a/test/CodeGenCXX/gnu-conditional-scalar-ext.cpp b/test/CodeGenCXX/gnu-conditional-scalar-ext.cpp deleted file mode 100644 index fea8364..0000000 --- a/test/CodeGenCXX/gnu-conditional-scalar-ext.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s -// rdar: // 8353567 -// pr7726 - -extern "C" int printf(...); - -void test0() { -// CHECK: call i32 (...)* @printf({{.*}}, i8* inttoptr (i64 3735928559 to i8*)) - printf("%p\n", (void *)0xdeadbeef ? : (void *)0xaaaaaa); -} - -// rdar://8446940 -namespace radar8446940 { -extern "C" void abort(); - -int main () { - char x[1]; - char *y = x ? : 0; - - if (x != y) - abort(); -} -} - -namespace radar8453812 { -extern "C" void abort(); -_Complex int getComplex(_Complex int val) { - static int count; - if (count++) - abort(); - return val; -} - -_Complex int cmplx() { - _Complex int cond; - _Complex int rhs; - - return getComplex(1+2i) ? : rhs; -} - -// lvalue test -void foo (int& lv) { - ++lv; -} - -int global = 1; - -int &cond() { - static int count; - if (count++) - abort(); - return global; -} - - -int main() { - cmplx(); - int rhs = 10; - foo (cond()? : rhs); - return global-2; -} -} diff --git a/test/CodeGenCXX/mangle-exprs.cpp b/test/CodeGenCXX/mangle-exprs.cpp index 73221718..e5f26e5 100644 --- a/test/CodeGenCXX/mangle-exprs.cpp +++ b/test/CodeGenCXX/mangle-exprs.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s +// RUN: %clang_cc1 -std=c++0x -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s template < bool condition, typename T = void > struct enable_if { typedef T type; }; @@ -24,6 +24,10 @@ namespace Casts { void static_(typename enable_if< O <= static_cast<unsigned>(4) >::type* = 0) { } + template< typename T > + void auto_(decltype(new auto(T()))) { + } + // FIXME: Test const_cast, reinterpret_cast, dynamic_cast, which are // a bit harder to use in template arguments. template <unsigned N> struct T {}; @@ -41,4 +45,7 @@ namespace Casts { // CHECK: define weak_odr void @_ZN5Casts1fILi6EEENS_1TIXT_EEEv template T<6> f<6>(); + + // CHECK: define weak_odr void @_ZN5Casts5auto_IiEEvDTnw_DapicvT__EEE( + template void auto_<int>(int*); } |