summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/constant-expression-cxx1y.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-06-05 00:46:14 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-06-05 00:46:14 +0000
commite6c0144208a4352c7c50616508081278c2ee5f88 (patch)
treee0a9174e018e3f66e20d23282a1411af866c5f51 /clang/test/SemaCXX/constant-expression-cxx1y.cpp
parent23399d765cea1b0f7e3ec8e63c1390a1f992a950 (diff)
downloadbcm5719-llvm-e6c0144208a4352c7c50616508081278c2ee5f88.tar.gz
bcm5719-llvm-e6c0144208a4352c7c50616508081278c2ee5f88.zip
Model temporary lifetime-extension explicitly in the AST. Use this model to
handle temporaries which have been lifetime-extended to static storage duration within constant expressions. This correctly handles nested lifetime extension (through reference members of aggregates in aggregate initializers) but non-constant-expression emission hasn't yet been updated to do the same. llvm-svn: 183283
Diffstat (limited to 'clang/test/SemaCXX/constant-expression-cxx1y.cpp')
-rw-r--r--clang/test/SemaCXX/constant-expression-cxx1y.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/constant-expression-cxx1y.cpp b/clang/test/SemaCXX/constant-expression-cxx1y.cpp
index 23b5d0b460f..40a98d4ca9f 100644
--- a/clang/test/SemaCXX/constant-expression-cxx1y.cpp
+++ b/clang/test/SemaCXX/constant-expression-cxx1y.cpp
@@ -715,3 +715,13 @@ namespace deduced_return_type {
static_assert(f() == 0, "");
static_assert(g(true), "");
}
+
+namespace modify_temporary_during_construction {
+ struct A { int &&temporary; int x; int y; };
+ constexpr int f(int &r) { r *= 9; return r - 12; }
+ // FIXME: The 'uninitialized' warning here is bogus.
+ constexpr A a = { 6, f(a.temporary), a.temporary }; // expected-warning {{uninitialized}} expected-note {{temporary created here}}
+ static_assert(a.x == 42, "");
+ static_assert(a.y == 54, "");
+ constexpr int k = a.temporary++; // expected-error {{constant expression}} expected-note {{outside the expression that created the temporary}}
+}
OpenPOWER on IntegriCloud