c++: robustify testcase [PR109752]
[official-gcc.git] / gcc / testsuite / g++.dg / cpp1y / constexpr-tracking-const10.C
blob53acb37beb85a56cae91710f3cd373a29b9113eb
1 // PR c++/91264
2 // { dg-do compile { target c++14 } }
4 struct B {
5   B() = default;
6   int i;
7 };
9 constexpr B bar()
11     constexpr B b = B(); // { dg-message "originally declared" }
12     B *p = const_cast<B*>(&b);
14     p->i = 11; // { dg-error "modifying a const object" }
16    return *p;
19 void foo()
20 {  
21    constexpr B y = bar(); // { dg-message "in .constexpr. expansion of" }