aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-07-07 22:48:24 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-07-07 22:48:24 +0000
commitde31aa7f0ef71f5c162372e319cbc03c0924f074 (patch)
tree2612888134d42a9a1c826548a89e4bfb012ba582 /test
parent254a8fb01cbd3dd5b91b97100f74cbe2c8842d54 (diff)
PR13290: Constant-evaluation support for CXXConstructExprs which construct a
multidimensional array of class type. Also, preserve zero-initialization when evaluating an initializer list for an array, in case the initializers refer to later elements (which have preceding zero-initialization). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159904 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/CodeGenCXX/const-init-cxx11.cpp7
-rw-r--r--test/SemaCXX/constant-expression-cxx11.cpp13
2 files changed, 20 insertions, 0 deletions
diff --git a/test/CodeGenCXX/const-init-cxx11.cpp b/test/CodeGenCXX/const-init-cxx11.cpp
index 07385eedba..d2504d78cd 100644
--- a/test/CodeGenCXX/const-init-cxx11.cpp
+++ b/test/CodeGenCXX/const-init-cxx11.cpp
@@ -121,6 +121,13 @@ namespace Array {
};
// CHECK: @_ZN5Array1eE = constant {{.*}} { [4 x i8] c"foo\00", [4 x i8] c"x\00\00\00" }
extern constexpr E e = E();
+
+ // PR13290
+ struct F { constexpr F() : n(4) {} int n; };
+ // CHECK: @_ZN5Array2f1E = global {{.*}} zeroinitializer
+ F f1[1][1][0] = { };
+ // CHECK: @_ZN5Array2f2E = global {{.* i32 4 .* i32 4 .* i32 4 .* i32 4 .* i32 4 .* i32 4 .* i32 4 .* i32 4}}
+ F f2[2][2][2] = { };
}
namespace MemberPtr {
diff --git a/test/SemaCXX/constant-expression-cxx11.cpp b/test/SemaCXX/constant-expression-cxx11.cpp
index 2cd66b6f62..f576dfa32f 100644
--- a/test/SemaCXX/constant-expression-cxx11.cpp
+++ b/test/SemaCXX/constant-expression-cxx11.cpp
@@ -494,6 +494,19 @@ struct ArrayRVal {
};
static_assert(ArrayRVal().elems[3].f() == 0, "");
+constexpr int selfref[2][2][2] = {
+ selfref[1][1][1] + 1, selfref[0][0][0] + 1,
+ selfref[1][0][1] + 1, selfref[0][1][0] + 1,
+ selfref[1][0][0] + 1, selfref[0][1][1] + 1 };
+static_assert(selfref[0][0][0] == 1, "");
+static_assert(selfref[0][0][1] == 2, "");
+static_assert(selfref[0][1][0] == 1, "");
+static_assert(selfref[0][1][1] == 2, "");
+static_assert(selfref[1][0][0] == 1, "");
+static_assert(selfref[1][0][1] == 3, "");
+static_assert(selfref[1][1][0] == 0, "");
+static_assert(selfref[1][1][1] == 0, "");
+
}
namespace DependentValues {