diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-02-23 22:41:47 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-02-23 22:41:47 +0000 |
| commit | 382bc51fddbfb010b2e068bbdf94ab99811b2768 (patch) | |
| tree | a3e11869468d7db13f7c46708c3a9d85f26b8bb9 /clang/test | |
| parent | 620db1f3dd08ebbba71b0e16f83c11323e04bc05 (diff) | |
| download | bcm5719-llvm-382bc51fddbfb010b2e068bbdf94ab99811b2768.tar.gz bcm5719-llvm-382bc51fddbfb010b2e068bbdf94ab99811b2768.zip | |
PR32044: Fix some cases where we would confuse a transparent init-list expression with an aggregate init.
llvm-svn: 296033
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/CodeGenCXX/cxx11-initializer-aggregate.cpp | 15 | ||||
| -rw-r--r-- | clang/test/CodeGenCXX/reference-init.cpp | 13 |
2 files changed, 24 insertions, 4 deletions
diff --git a/clang/test/CodeGenCXX/cxx11-initializer-aggregate.cpp b/clang/test/CodeGenCXX/cxx11-initializer-aggregate.cpp index be4fd73e6c2..8bf35966f5b 100644 --- a/clang/test/CodeGenCXX/cxx11-initializer-aggregate.cpp +++ b/clang/test/CodeGenCXX/cxx11-initializer-aggregate.cpp @@ -2,7 +2,16 @@ struct A { int a, b; int f(); }; -// CHECK: define {{.*}}@_Z3fn1i( +namespace NonAggregateCopyInAggregateInit { // PR32044 + struct A { constexpr A(int n) : x(n), y() {} int x, y; } extern a; + // CHECK-DAG: @_ZN31NonAggregateCopyInAggregateInit1bE = global %{{.*}} { %[[A:.*]]* @_ZN31NonAggregateCopyInAggregateInit1aE } + struct B { A &p; } b{{a}}; + // CHECK-DAG: @_ZGRN31NonAggregateCopyInAggregateInit1cE_ = internal global %[[A]] { i32 1, i32 0 } + // CHECK-DAG: @_ZN31NonAggregateCopyInAggregateInit1cE = global %{{.*}} { %{{.*}}* @_ZGRN31NonAggregateCopyInAggregateInit1cE_ } + struct C { A &&p; } c{{1}}; +} + +// CHECK-LABEL: define {{.*}}@_Z3fn1i( int fn1(int x) { // CHECK: %[[INITLIST:.*]] = alloca %struct.A // CHECK: %[[A:.*]] = getelementptr inbounds %struct.A, %struct.A* %[[INITLIST]], i32 0, i32 0 @@ -15,7 +24,7 @@ int fn1(int x) { struct B { int &r; int &f() { return r; } }; -// CHECK: define {{.*}}@_Z3fn2Ri( +// CHECK-LABEL: define {{.*}}@_Z3fn2Ri( int &fn2(int &v) { // CHECK: %[[INITLIST2:.*]] = alloca %struct.B, align 8 // CHECK: %[[R:.*]] = getelementptr inbounds %struct.B, %struct.B* %[[INITLIST2:.*]], i32 0, i32 0 @@ -24,7 +33,7 @@ int &fn2(int &v) { return B{v}.f(); } -// CHECK: define {{.*}}@__cxx_global_var_init( +// CHECK-LABEL: define {{.*}}@__cxx_global_var_init( // // CHECK: call {{.*}}@_ZN14NonTrivialInit1AC1Ev( // CHECK: getelementptr inbounds {{.*}}, i64 1 diff --git a/clang/test/CodeGenCXX/reference-init.cpp b/clang/test/CodeGenCXX/reference-init.cpp index 3a3eaeee78f..ba7b282028c 100644 --- a/clang/test/CodeGenCXX/reference-init.cpp +++ b/clang/test/CodeGenCXX/reference-init.cpp @@ -1,4 +1,6 @@ -// RUN: %clang_cc1 -emit-llvm-only -triple %itanium_abi_triple -verify %s +// RUN: %clang_cc1 -triple %itanium_abi_triple -verify %s +// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - -std=c++98 | FileCheck %s --check-prefix=CHECK-CXX98 +// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - -std=c++11 | FileCheck %s --check-prefix=CHECK-CXX11 // expected-no-diagnostics struct XPTParamDescriptor {}; @@ -23,3 +25,12 @@ Foo& ignoreSetMutex = *(new Foo); // Binding to a bit-field that requires a temporary. struct { int bitfield : 3; } s = { 3 }; const int &s2 = s.bitfield; + +// In C++98, this forms a reference to itself. In C++11 onwards, this performs +// copy-construction. +struct SelfReference { SelfReference &r; }; +extern SelfReference self_reference_1; +SelfReference self_reference_2 = {self_reference_1}; +// CHECK-CXX98: @self_reference_2 = global %[[SELF_REF:.*]] { %[[SELF_REF]]* @self_reference_1 } +// CHECK-CXX11: @self_reference_2 = global %[[SELF_REF:.*]] zeroinitializer +// CHECK-CXX11: call {{.*}}memcpy{{.*}} @self_reference_2 {{.*}} @self_reference_1 |

