constexpr tidyups:
* Fix bug when determining whether && / || are potential constant expressions
* Try harder when determining whether ?: is a potential constant expression
* Produce a diagnostic on sizeof(VLA) to provide a better source location
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150657 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaCXX/constant-expression-cxx11.cpp b/test/SemaCXX/constant-expression-cxx11.cpp
index aa40311..f5cc1b3 100644
--- a/test/SemaCXX/constant-expression-cxx11.cpp
+++ b/test/SemaCXX/constant-expression-cxx11.cpp
@@ -1169,3 +1169,26 @@
constexpr const int j = i; // expected-error {{constant expression}} expected-note {{initializer of 'i' is not a constant expression}}
}
+
+namespace RecursiveOpaqueExpr {
+ template<typename Iter>
+ constexpr auto LastNonzero(Iter p, Iter q) -> decltype(+*p) {
+ return p != q ? (LastNonzero(p+1, q) ?: *p) : 0; // expected-warning {{GNU}}
+ }
+
+ constexpr int arr1[] = { 1, 0, 0, 3, 0, 2, 0, 4, 0, 0 };
+ static_assert(LastNonzero(begin(arr1), end(arr1)) == 4, "");
+
+ constexpr int arr2[] = { 1, 0, 0, 3, 0, 2, 0, 4, 0, 5 };
+ static_assert(LastNonzero(begin(arr2), end(arr2)) == 5, "");
+}
+
+namespace VLASizeof {
+
+ void f(int k) {
+ int arr[k]; // expected-warning {{C99}}
+ constexpr int n = 1 +
+ sizeof(arr) // expected-error {{constant expression}}
+ * 3;
+ }
+}