diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-12-03 01:14:32 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-12-03 01:14:32 +0000 |
| commit | 4baaa5ab52870c3d2e1961aaa7758908ea69579e (patch) | |
| tree | d0b7a59ca83d21a73fbd5a907b01941e9199da31 /clang/test/CodeGenCXX | |
| parent | 05049bed027cb37ef4afcbc6b280603e767f7971 (diff) | |
| download | bcm5719-llvm-4baaa5ab52870c3d2e1961aaa7758908ea69579e.tar.gz bcm5719-llvm-4baaa5ab52870c3d2e1961aaa7758908ea69579e.zip | |
DR616, and part of P0135R1: member access (or pointer-to-member access) on a
temporary produces an xvalue, not a prvalue. Support this by materializing the
temporary prior to performing the member access.
llvm-svn: 288563
Diffstat (limited to 'clang/test/CodeGenCXX')
| -rw-r--r-- | clang/test/CodeGenCXX/compound-literals.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/clang/test/CodeGenCXX/compound-literals.cpp b/clang/test/CodeGenCXX/compound-literals.cpp index 1e525e237e9..0169d5be85a 100644 --- a/clang/test/CodeGenCXX/compound-literals.cpp +++ b/clang/test/CodeGenCXX/compound-literals.cpp @@ -38,23 +38,33 @@ int g() { return v[0]; } +// GCC's compound-literals-in-C++ extension lifetime-extends a compound literal +// (or a C++11 list-initialized temporary!) if: +// - it is at global scope +// - it has array type +// - it has a constant initializer + struct Z { int i[3]; }; int *p = (Z){ {1, 2, 3} }.i; // CHECK: define {{.*}}__cxx_global_var_init() -// CHECK: store i32* getelementptr inbounds (%struct.Z, %struct.Z* @.compoundliteral, i32 0, i32 0, i32 0), i32** @p +// CHECK: alloca %struct.Z +// CHECK: store i32* %{{.*}}, i32** @p +int *q = (int [5]){1, 2, 3, 4, 5}; +// CHECK-LABEL: define {{.*}}__cxx_global_var_init.1() +// CHECK: store i32* getelementptr inbounds ([5 x i32], [5 x i32]* @.compoundliteral, i32 0, i32 0), i32** @q int *PR21912_1 = (int []){}; -// CHECK-LABEL: define {{.*}}__cxx_global_var_init.1() -// CHECK: store i32* getelementptr inbounds ([0 x i32], [0 x i32]* @.compoundliteral.2, i32 0, i32 0), i32** @PR21912_1 +// CHECK-LABEL: define {{.*}}__cxx_global_var_init.2() +// CHECK: store i32* getelementptr inbounds ([0 x i32], [0 x i32]* @.compoundliteral.3, i32 0, i32 0), i32** @PR21912_1 union PR21912Ty { long long l; double d; }; union PR21912Ty *PR21912_2 = (union PR21912Ty[]){{.d = 2.0}, {.l = 3}}; -// CHECK-LABEL: define {{.*}}__cxx_global_var_init.3() -// CHECK: store %union.PR21912Ty* getelementptr inbounds ([2 x %union.PR21912Ty], [2 x %union.PR21912Ty]* bitcast (<{ { double }, %union.PR21912Ty }>* @.compoundliteral.4 to [2 x %union.PR21912Ty]*), i32 0, i32 0), %union.PR21912Ty** @PR21912_2 +// CHECK-LABEL: define {{.*}}__cxx_global_var_init.4() +// CHECK: store %union.PR21912Ty* getelementptr inbounds ([2 x %union.PR21912Ty], [2 x %union.PR21912Ty]* bitcast (<{ { double }, %union.PR21912Ty }>* @.compoundliteral.5 to [2 x %union.PR21912Ty]*), i32 0, i32 0), %union.PR21912Ty** @PR21912_2 // This compound literal should have local scope. int computed_with_lambda = [] { |

