summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/constant-expression-cxx11.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2011-12-22 01:07:19 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2011-12-22 01:07:19 +0000
commitca2cfbf5ce7e8ffa2526cd6d1aa2bf7779686c4f (patch)
treef97035489d8c02cf9e3ed1d7131afe7715ea4aab /clang/test/SemaCXX/constant-expression-cxx11.cpp
parent4449b2129401417770245c24a3236b95e9f3c1d6 (diff)
downloadbcm5719-llvm-ca2cfbf5ce7e8ffa2526cd6d1aa2bf7779686c4f.tar.gz
bcm5719-llvm-ca2cfbf5ce7e8ffa2526cd6d1aa2bf7779686c4f.zip
PR11637: implement special-case constant evaluation for char arrays initialized
by string literals. llvm-svn: 147120
Diffstat (limited to 'clang/test/SemaCXX/constant-expression-cxx11.cpp')
-rw-r--r--clang/test/SemaCXX/constant-expression-cxx11.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/constant-expression-cxx11.cpp b/clang/test/SemaCXX/constant-expression-cxx11.cpp
index af0d5f3e1c3..995cd2ffece 100644
--- a/clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ b/clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -391,6 +391,20 @@ struct S {
int n : "foo"[4]; // expected-error {{constant expression}} expected-note {{read of dereferenced one-past-the-end pointer is not allowed in a constant expression}}
};
+struct T {
+ char c[6];
+ constexpr T() : c{"foo"} {}
+};
+constexpr T t;
+
+static_assert(t.c[0] == 'f', "");
+static_assert(t.c[1] == 'o', "");
+static_assert(t.c[2] == 'o', "");
+static_assert(t.c[3] == 0, "");
+static_assert(t.c[4] == 0, "");
+static_assert(t.c[5] == 0, "");
+static_assert(t.c[6] == 0, ""); // expected-error {{constant expression}} expected-note {{one-past-the-end}}
+
}
namespace Array {
OpenPOWER on IntegriCloud