diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-10-08 21:26:03 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-10-08 21:26:03 +0000 |
commit | 54b0fb8af38294b3571b798ce0053f79bb6e0d27 (patch) | |
tree | 6f8edd0b21c3c9e81043e2d505b66403ed71097f /test | |
parent | 9558f9dcee80e526443ab99aa0a399df4194f60b (diff) | |
download | clang-54b0fb8af38294b3571b798ce0053f79bb6e0d27.tar.gz |
Fix crash or wrong code bug if a lifetime-extended temporary contains a
"non-constant" value.
If the constant evaluator evaluates part of a variable initializer,
including the initializer for some lifetime-extended temporary, but
fails to fully evaluate the initializer, it can leave behind wrong
values for temporaries encountered in that initialization. Don't try to
emit those from CodeGen! Instead, look at the values that constant
evaluation produced if (and only if) it actually succeeds and we're
emitting the lifetime-extending declaration's initializer as a constant.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374119 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/CodeGenCXX/no-const-init-cxx2a.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/CodeGenCXX/no-const-init-cxx2a.cpp b/test/CodeGenCXX/no-const-init-cxx2a.cpp new file mode 100644 index 0000000000..a945c066e3 --- /dev/null +++ b/test/CodeGenCXX/no-const-init-cxx2a.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s -std=c++2a | FileCheck %s + +// CHECK-DAG: @p = {{.*}} null +// CHECK-DAG: @_ZGR1p_ = {{.*}} null +int *const &p = new int; + +struct d { + constexpr d(int &&f) : e(f) {} + int &e; +}; + +// CHECK-DAG: @g = {{.*}} null +// CHECK-DAG: @_ZGR1g_ = {{.*}} zeroinitializer +d &&g{{0}}; + +// CHECK: define {{.*}} @__cxx_global_var_init +// CHECK: define {{.*}} @__cxx_global_var_init +// CHECK-NOT: define {{.*}} @__cxx_global_var_init |