annotate gcc/testsuite/g++.dg/cpp1y/constexpr-type-def1.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 // PR c++/55250
kono
parents:
diff changeset
2 // { dg-do compile { target c++14 } }
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 #define SA(X) static_assert((X),#X)
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 constexpr int Test1(int x) { enum E { y = 1 }; return x + y; }
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 constexpr int Test2(int x) { struct T { constexpr operator int() { return 1; } }; return x + T(); }
kono
parents:
diff changeset
9
kono
parents:
diff changeset
10 constexpr int Test3(int x) { typedef enum E { y = 1 } EE; return x + EE::y; }
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 constexpr int Test4(int x) { typedef struct T { constexpr operator int() { return 1; } } TT; return x + TT(); }
kono
parents:
diff changeset
13
kono
parents:
diff changeset
14 constexpr int Test5(int x) { using EE = enum E { y = 1 }; return x + EE::y; }
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 constexpr int Test6(int x) { using TT = struct T { constexpr operator int() { return 1; } }; return x + TT(); }
kono
parents:
diff changeset
17
kono
parents:
diff changeset
18 SA(Test1(2) == 3);
kono
parents:
diff changeset
19 SA(Test2(2) == 3);
kono
parents:
diff changeset
20 SA(Test3(2) == 3);
kono
parents:
diff changeset
21 SA(Test4(2) == 3);
kono
parents:
diff changeset
22 SA(Test5(2) == 3);
kono
parents:
diff changeset
23 SA(Test6(2) == 3);
kono
parents:
diff changeset
24
kono
parents:
diff changeset
25 struct S1
kono
parents:
diff changeset
26 {
kono
parents:
diff changeset
27 constexpr S1() { enum E { y = 1 }; SA(y == 1); }
kono
parents:
diff changeset
28 };
kono
parents:
diff changeset
29
kono
parents:
diff changeset
30 struct S2
kono
parents:
diff changeset
31 {
kono
parents:
diff changeset
32 constexpr S2() { struct T { constexpr operator int() { return 1; } }; SA(T() == 1); }
kono
parents:
diff changeset
33 };
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 struct S3
kono
parents:
diff changeset
36 {
kono
parents:
diff changeset
37 constexpr S3() { typedef enum E { y = 1} EE; SA(EE::y == 1); }
kono
parents:
diff changeset
38 };
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 struct S4
kono
parents:
diff changeset
41 {
kono
parents:
diff changeset
42 constexpr S4() { typedef struct T { constexpr operator int() { return 1; } } TT; SA(TT() == 1); }
kono
parents:
diff changeset
43 };
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 struct S5
kono
parents:
diff changeset
46 {
kono
parents:
diff changeset
47 constexpr S5() { using EE = enum E { y = 1}; SA(EE::y == 1); }
kono
parents:
diff changeset
48 };
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 struct S6
kono
parents:
diff changeset
51 {
kono
parents:
diff changeset
52 constexpr S6() { using TT = struct T { constexpr operator int() { return 1; } }; SA(TT() == 1); }
kono
parents:
diff changeset
53 };
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 S1 s1;
kono
parents:
diff changeset
56 S2 s2;
kono
parents:
diff changeset
57 S3 s3;
kono
parents:
diff changeset
58 S4 s4;
kono
parents:
diff changeset
59 S5 s5;
kono
parents:
diff changeset
60 S6 s6;