annotate gcc/testsuite/g++.dg/cpp0x/constexpr-non-const-arg.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // Example from issue 1125 drafting; D() and v were well-formed with the
kono
parents:
diff changeset
2 // wording approved in Rapperswil, now seems they should be ill-formed.
kono
parents:
diff changeset
3 // { dg-do compile { target c++11 } }
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 struct B {
kono
parents:
diff changeset
6 constexpr B(int x) : i(0) { } // "x" is unused
kono
parents:
diff changeset
7 int i;
kono
parents:
diff changeset
8 };
kono
parents:
diff changeset
9
kono
parents:
diff changeset
10 int global; // { dg-message "not const" }
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 struct D : B {
kono
parents:
diff changeset
13 constexpr D() : B(global) { } // { dg-error "global|argument" }
kono
parents:
diff changeset
14 };
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 struct A2 {
kono
parents:
diff changeset
17 constexpr A2(bool b, int x) : m(b ? 42 : x) { }
kono
parents:
diff changeset
18 int m;
kono
parents:
diff changeset
19 };
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 // ok, constructor call initializes m with the value 42 after substitution
kono
parents:
diff changeset
22 constexpr int v = A2(true, global).m; // { dg-error "global" }
kono
parents:
diff changeset
23 // error: initializer for m is "x", which is non-constant
kono
parents:
diff changeset
24 constexpr int w = A2(false, global).m; // { dg-error "global" }