c++: robustify testcase [PR109752]
[official-gcc.git] / gcc / testsuite / g++.dg / cpp1y / constexpr-tracking-const14.C
blob45c4fcf50be7a740dbdcb833e61f9e116061f7ac
1 // PR c++/91264
2 // { dg-do compile { target c++14 } }
4 struct F {
5   const int f;
6   constexpr F() : f(9) { }
7 };
9 struct C {
10   int n;
11   const F f;
12   constexpr C() : n(1) { n = 66; }
15 struct A {
16   int r;
17   const C c;
18   constexpr A() : r(11) { r = 14; const_cast<C &>(c).n = 42; } // { dg-error "modifying a const object" }
21 struct D {
22   const A a;
23   constexpr D() { } // { dg-message "in .constexpr. expansion of" }
26 struct E {
27   const D d;
28   constexpr E() { } // { dg-message "in .constexpr. expansion of" }
31 struct B {
32   const E e;
33   constexpr B(bool) { } // { dg-message "in .constexpr. expansion of" }
36 constexpr B b(false); // { dg-message "in .constexpr. expansion of" }
37 // { dg-message "originally declared" "" { target *-*-* } .-1 }
38 static_assert(b.e.d.a.c.n == 2, ""); // { dg-error "non-constant condition" }