summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/constant-expression-cxx1y.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-11-19 21:27:17 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-11-19 21:27:17 +0000
commitbe6dd818fbf1305c895038904396d20761d3f98c (patch)
tree942524d82ae6505ce58f494d10b0bb2fe87f69e2 /clang/test/SemaCXX/constant-expression-cxx1y.cpp
parent06839a536f39170f2ff6793ccbfa6ebb3468efe5 (diff)
downloadbcm5719-llvm-be6dd818fbf1305c895038904396d20761d3f98c.tar.gz
bcm5719-llvm-be6dd818fbf1305c895038904396d20761d3f98c.zip
Fix bug where a trivial constexpr copy/move operation couldn't copy from an
empty non-constexpr object. Such a copy doesn't break any of the constexpr rules. llvm-svn: 222387
Diffstat (limited to 'clang/test/SemaCXX/constant-expression-cxx1y.cpp')
-rw-r--r--clang/test/SemaCXX/constant-expression-cxx1y.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/constant-expression-cxx1y.cpp b/clang/test/SemaCXX/constant-expression-cxx1y.cpp
index e1929f76377..e8925f3f84a 100644
--- a/clang/test/SemaCXX/constant-expression-cxx1y.cpp
+++ b/clang/test/SemaCXX/constant-expression-cxx1y.cpp
@@ -910,3 +910,31 @@ namespace PR17331 {
constexpr int ARR[] = { 1, 2, 3, 4, 5 };
static_assert(sum(ARR) == 15, "");
}
+
+namespace EmptyClass {
+ struct E1 {} e1;
+ union E2 {} e2; // expected-note 4{{here}}
+ struct E3 : E1 {} e3;
+
+ template<typename E>
+ constexpr int f(E &a, int kind) {
+ switch (kind) {
+ case 0: { E e(a); return 0; } // expected-note {{read}} expected-note {{in call}}
+ case 1: { E e(static_cast<E&&>(a)); return 0; } // expected-note {{read}} expected-note {{in call}}
+ case 2: { E e; e = a; return 0; } // expected-note {{read}} expected-note {{in call}}
+ case 3: { E e; e = static_cast<E&&>(a); return 0; } // expected-note {{read}} expected-note {{in call}}
+ }
+ }
+ constexpr int test1 = f(e1, 0);
+ constexpr int test2 = f(e2, 0); // expected-error {{constant expression}} expected-note {{in call}}
+ constexpr int test3 = f(e3, 0);
+ constexpr int test4 = f(e1, 1);
+ constexpr int test5 = f(e2, 1); // expected-error {{constant expression}} expected-note {{in call}}
+ constexpr int test6 = f(e3, 1);
+ constexpr int test7 = f(e1, 2);
+ constexpr int test8 = f(e2, 2); // expected-error {{constant expression}} expected-note {{in call}}
+ constexpr int test9 = f(e3, 2);
+ constexpr int testa = f(e1, 3);
+ constexpr int testb = f(e2, 3); // expected-error {{constant expression}} expected-note {{in call}}
+ constexpr int testc = f(e3, 3);
+}
OpenPOWER on IntegriCloud