Mercurial > hg > CbC > CbC_gcc
annotate gcc/testsuite/g++.dg/cpp1y/constexpr-tracking-const7.C @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | |
children |
rev | line source |
---|---|
145 | 1 // PR c++/91264 |
2 // { dg-do compile { target c++14 } } | |
3 | |
4 struct D { int n; }; | |
5 | |
6 struct C { const D d; }; | |
7 | |
8 struct A { | |
9 C c; | |
10 constexpr A() : c{} { } | |
11 }; | |
12 | |
13 struct B { | |
14 A a; | |
15 constexpr B() { | |
16 int &r = const_cast<int &>(a.c.d.n); | |
17 r = 3; // { dg-error "modifying a const object" } | |
18 } | |
19 }; | |
20 | |
21 constexpr B b{}; // { dg-message "in .constexpr. expansion of " } | |
22 // { dg-message "originally declared" "" { target *-*-* } .-1 } | |
23 static_assert((b.a.c.d.n, 1), ""); |