My first effort to do this more subtly failed, so elaborately
test for an invalid declaration at every single place in the
constant evaluator that's about to request a struct layout.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155868 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaCXX/constant-expression-cxx11.cpp b/test/SemaCXX/constant-expression-cxx11.cpp
index 9f80e71..a9e1008 100644
--- a/test/SemaCXX/constant-expression-cxx11.cpp
+++ b/test/SemaCXX/constant-expression-cxx11.cpp
@@ -1248,3 +1248,13 @@
}
constexpr auto v2 = g(4);
}
+
+// PR12626, redux
+namespace InvalidClasses {
+ void test0() {
+ struct X; // expected-note {{forward declaration}}
+ struct Y { bool b; X x; }; // expected-error {{field has incomplete type}}
+ Y y;
+ auto& b = y.b;
+ }
+}