annotate gcc/testsuite/g++.dg/cpp1z/direct-enum-init1.C @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // P0138R2 - direct-list-initialization of enums
kono
parents:
diff changeset
2 // { dg-do compile { target c++11 } }
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 enum A { G = 26 };
kono
parents:
diff changeset
5 enum B : short {};
kono
parents:
diff changeset
6 enum class C {};
kono
parents:
diff changeset
7 enum struct D : long {};
kono
parents:
diff changeset
8 enum class E : unsigned char { e = 7 };
kono
parents:
diff changeset
9 struct S { operator C () { return C (s); } int s; } s;
kono
parents:
diff changeset
10 struct T { operator long () { return t; } long t; } t;
kono
parents:
diff changeset
11 struct V { E v; };
kono
parents:
diff changeset
12 long l;
kono
parents:
diff changeset
13 long long ll;
kono
parents:
diff changeset
14 short c;
kono
parents:
diff changeset
15 void bar (E);
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 void
kono
parents:
diff changeset
18 foo ()
kono
parents:
diff changeset
19 {
kono
parents:
diff changeset
20 A a1 { 5 }; // { dg-error "invalid conversion from 'int' to 'A'" }
kono
parents:
diff changeset
21 B b1 { 7 }; // { dg-error "invalid conversion from 'int' to 'B'" "" { target c++14_down } }
kono
parents:
diff changeset
22 C c1 { s };
kono
parents:
diff changeset
23 D d1 { D(t) }; // { dg-error "invalid cast from type 'T' to type 'D'" }
kono
parents:
diff changeset
24 D d2 { t }; // { dg-error "cannot convert 'T' to 'D' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
25 // { dg-error "invalid cast from type 'T' to type 'D'" "" { target c++17 } .-1 }
kono
parents:
diff changeset
26 D d3 { 9 }; // { dg-error "cannot convert 'int' to 'D' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
27 D d4 { l }; // { dg-error "cannot convert 'long int' to 'D' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
28 D d5 { D(l) };
kono
parents:
diff changeset
29 D d6 { G }; // { dg-error "cannot convert 'A' to 'D' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
30 E e1 { 5 }; // { dg-error "cannot convert 'int' to 'E' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
31 E e2 { -1 }; // { dg-error "cannot convert 'int' to 'E' in initialization" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
32 // { dg-error "narrowing conversion of '-1' from 'int' to 'unsigned char'" "" { target c++17 } .-1 }
111
kono
parents:
diff changeset
33 E e3 { 5.0 }; // { dg-error "cannot convert 'double' to 'E' in initialization" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
34 // { dg-error "narrowing conversion of '5.0e.0' from 'double' to 'unsigned char'" "" { target c++17 } .-1 }
111
kono
parents:
diff changeset
35 E e4 { 5.2 }; // { dg-error "cannot convert 'double' to 'E' in initialization" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
36 // { dg-error "narrowing conversion of '5.\[0-9]*e.0' from 'double' to 'unsigned char'" "" { target c++17 } .-1 }
111
kono
parents:
diff changeset
37 B b2 = { 7 }; // { dg-error "invalid conversion from 'int' to 'B'" }
kono
parents:
diff changeset
38 C c2 = { C { 8 } }; // { dg-error "cannot convert 'int' to 'C' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 D *d7 = new D { 9 }; // { dg-error "cannot convert \[^\n\r]* to 'D' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
41 E *e5 = new E { -4 }; // { dg-error "cannot convert \[^\n\r]* to 'E' in initialization" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
42 // { dg-error "narrowing conversion of '-4' from 'int' to 'unsigned char'" "" { target c++17 } .-1 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
43 bar ({ 10 }); // { dg-error "cannot convert \[^\n\r]* to 'E'" }
111
kono
parents:
diff changeset
44 bar (E { 9 }); // { dg-error "cannot convert 'int' to 'E' in initialization" "" { target c++14_down } }
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
45 V v1 = { { 11 } }; // { dg-error "cannot convert '<brace-enclosed initializer list>' to 'E' in initialization" }
111
kono
parents:
diff changeset
46 V v2 = { E { 12 } }; // { dg-error "cannot convert 'int' to 'E' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
47 V v3 = { E { 5.0 } }; // { dg-error "cannot convert 'double' to 'E' in initialization" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
48 // { dg-error "narrowing conversion of '5.0e.0' from 'double' to 'unsigned char'" "" { target c++17 } .-1 }
111
kono
parents:
diff changeset
49 V v4 = { 13 }; // { dg-error "cannot convert 'int' to 'E' in initialization" }
kono
parents:
diff changeset
50 if (B b3 { 5 }) // { dg-error "invalid conversion from 'int' to 'B'" "" { target c++14_down } }
kono
parents:
diff changeset
51 ;
kono
parents:
diff changeset
52 if (B b4 { 4.0 }) // { dg-error "cannot convert 'double' to 'B' in initialization" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
53 ; // { dg-error "narrowing conversion of '4.0e.0' from 'double' to 'short int'" "" { target c++17 } .-1 }
111
kono
parents:
diff changeset
54 C c3 { 8L }; // { dg-error "cannot convert 'long int' to 'C' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
55 B b4 {short (c + 5)}; // { dg-error "invalid conversion from 'short int' to 'B'" "" { target c++14_down } }
kono
parents:
diff changeset
56 B b5 {c + 5}; // { dg-error "invalid conversion from 'int' to 'B'" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
57 // { dg-error "narrowing conversion of \[^\n\r]* from 'int' to 'short int'" "" { target c++17 } .-1 }
111
kono
parents:
diff changeset
58 C c4 { ll }; // { dg-error "cannot convert 'long long int' to 'C' in initialization" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
59 // { dg-error "narrowing conversion of 'll' from 'long long int' to 'int'" "" { target c++17 } .-1 }
111
kono
parents:
diff changeset
60 C c5 {short (c + 5)}; // { dg-error "cannot convert 'short int' to 'C' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
61 C c6 {c + 5}; // { dg-error "cannot convert 'int' to 'C' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
62 }
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 struct U
kono
parents:
diff changeset
65 {
kono
parents:
diff changeset
66 U () : e { 5 } {} // { dg-error "cannot convert \[^\n\r]* to 'E' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
67 U (int) : e { 5.0 } {}// { dg-error "cannot convert \[^\n\r]* to 'E' in initialization" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
68 // { dg-error "narrowing conversion of '5.0e.0' from 'double' to 'unsigned char'" "" { target c++17 } .-1 }
111
kono
parents:
diff changeset
69 U (float) : e({ 6 }) {}// { dg-error "list-initializer for non-class type must not be parenthesized" }
kono
parents:
diff changeset
70 // { dg-error "cannot convert \[^\n\r]* to 'E' in initialization" "" { target *-*-* } .-1 }
kono
parents:
diff changeset
71 E e;
kono
parents:
diff changeset
72 };
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 struct W
kono
parents:
diff changeset
75 {
kono
parents:
diff changeset
76 A a { 5 }; // { dg-error "invalid conversion from 'int' to 'A'" }
kono
parents:
diff changeset
77 B b { 6 }; // { dg-error "invalid conversion from 'int' to 'B'" "" { target c++14_down } }
kono
parents:
diff changeset
78 C c { 3.0f }; // { dg-error "cannot convert \[^\n\r]* to 'C' in initialization" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
79 // { dg-error "narrowing conversion of '3.0e.0f' from 'float' to 'int'" "" { target c++17 } .-1 }
111
kono
parents:
diff changeset
80 D d = { 7 }; // { dg-error "cannot convert \[^\n\r]* to 'D' in initialization" }
kono
parents:
diff changeset
81 };
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 template <int N>
kono
parents:
diff changeset
84 void
kono
parents:
diff changeset
85 foo2 ()
kono
parents:
diff changeset
86 {
kono
parents:
diff changeset
87 A a1 { 5 }; // { dg-error "invalid conversion from 'int' to 'A'" }
kono
parents:
diff changeset
88 B b1 { 7 }; // { dg-error "invalid conversion from 'int' to 'B'" "" { target c++14_down } }
kono
parents:
diff changeset
89 C c1 { s };
kono
parents:
diff changeset
90 D d1 { D(t) }; // { dg-error "invalid cast from type 'T' to type 'D'" }
kono
parents:
diff changeset
91 D d2 { t }; // { dg-error "cannot convert 'T' to 'D' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
92 // { dg-error "invalid cast from type 'T' to type 'D'" "" { target c++17 } .-1 }
kono
parents:
diff changeset
93 D d3 { 9 }; // { dg-error "cannot convert 'int' to 'D' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
94 D d4 { l }; // { dg-error "cannot convert 'long int' to 'D' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
95 D d5 { D(l) };
kono
parents:
diff changeset
96 D d6 { G }; // { dg-error "cannot convert 'A' to 'D' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
97 E e1 { 5 }; // { dg-error "cannot convert 'int' to 'E' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
98 E e2 { -1 }; // { dg-error "cannot convert 'int' to 'E' in initialization" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
99 // { dg-error "narrowing conversion of '-1' from 'int' to 'unsigned char'" "" { target c++17 } .-1 }
111
kono
parents:
diff changeset
100 E e3 { 5.0 }; // { dg-error "cannot convert 'double' to 'E' in initialization" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
101 // { dg-error "narrowing conversion of '5.0e.0' from 'double' to 'unsigned char'" "" { target c++17 } .-1 }
111
kono
parents:
diff changeset
102 E e4 { 5.2 }; // { dg-error "cannot convert 'double' to 'E' in initialization" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
103 // { dg-error "narrowing conversion of '5.\[0-9]*e.0' from 'double' to 'unsigned char'" "" { target c++17 } .-1 }
111
kono
parents:
diff changeset
104 B b2 = { 7 }; // { dg-error "invalid conversion from 'int' to 'B'" }
kono
parents:
diff changeset
105 C c2 = { C { 8 } }; // { dg-error "cannot convert 'int' to 'C' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
106 D *d7 = new D { 9 }; // { dg-error "cannot convert \[^\n\r]* to 'D' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
107 E *e5 = new E { -4 }; // { dg-error "cannot convert \[^\n\r]* to 'E' in initialization" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
108 // { dg-error "narrowing conversion of '-4' from 'int' to 'unsigned char'" "" { target c++17 } .-1 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
109 bar ({ 10 }); // { dg-error "cannot convert \[^\n\r]* to 'E'" }
111
kono
parents:
diff changeset
110 bar (E { 9 }); // { dg-error "cannot convert 'int' to 'E' in initialization" "" { target c++14_down } }
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
111 V v1 = { { 11 } }; // { dg-error "cannot convert '<brace-enclosed initializer list>' to 'E' in initialization" }
111
kono
parents:
diff changeset
112 V v2 = { E { 12 } }; // { dg-error "cannot convert 'int' to 'E' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
113 V v3 = { E { 5.0 } }; // { dg-error "cannot convert 'double' to 'E' in initialization" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
114 // { dg-error "narrowing conversion of '5.0e.0' from 'double' to 'unsigned char'" "" { target c++17 } .-1 }
111
kono
parents:
diff changeset
115 V v4 = { 13 }; // { dg-error "cannot convert 'int' to 'E' in initialization" }
kono
parents:
diff changeset
116 if (B b3 { 5 }) // { dg-error "invalid conversion from 'int' to 'B'" "" { target c++14_down } }
kono
parents:
diff changeset
117 ;
kono
parents:
diff changeset
118 if (B b4 { 4.0 }) // { dg-error "cannot convert 'double' to 'B' in initialization" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
119 ; // { dg-error "narrowing conversion of '4.0e.0' from 'double' to 'short int'" "" { target c++17 } .-1 }
111
kono
parents:
diff changeset
120 C c3 { 8L }; // { dg-error "cannot convert 'long int' to 'C' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
121 B b4 {short (c + 5)}; // { dg-error "invalid conversion from 'short int' to 'B'" "" { target c++14_down } }
kono
parents:
diff changeset
122 B b5 {c + 5}; // { dg-error "invalid conversion from 'int' to 'B'" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
123 // { dg-error "narrowing conversion of \[^\n\r]* from 'int' to 'short int'" "" { target c++17 } .-1 }
111
kono
parents:
diff changeset
124 C c4 { ll }; // { dg-error "cannot convert 'long long int' to 'C' in initialization" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
125 // { dg-error "narrowing conversion of 'll' from 'long long int' to 'int'" "" { target c++17 } .-1 }
111
kono
parents:
diff changeset
126 C c5 {short (c + 5)}; // { dg-error "cannot convert 'short int' to 'C' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
127 C c6 {c + 5}; // { dg-error "cannot convert 'int' to 'C' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
128 }
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 template <int N>
kono
parents:
diff changeset
131 struct U2
kono
parents:
diff changeset
132 {
kono
parents:
diff changeset
133 U2 () : e { 5 } {} // { dg-error "cannot convert \[^\n\r]* to 'E' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
134 U2 (int) : e { 5.0 } {}// { dg-error "cannot convert \[^\n\r]* to 'E' in initialization" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
135 // { dg-error "narrowing conversion of '5.0e.0' from 'double' to 'unsigned char'" "" { target c++17 } .-1 }
111
kono
parents:
diff changeset
136 U2 (float) : e({ 6 }) {}
kono
parents:
diff changeset
137 E e;
kono
parents:
diff changeset
138 };
kono
parents:
diff changeset
139
kono
parents:
diff changeset
140 template <int N>
kono
parents:
diff changeset
141 struct W2
kono
parents:
diff changeset
142 {
kono
parents:
diff changeset
143 A a { 5 }; // { dg-error "invalid conversion from 'int' to 'A'" "" { target *-*-* } }
kono
parents:
diff changeset
144 B b { 6 }; // { dg-error "invalid conversion from 'int' to 'B'" "" { target c++14_down } }
kono
parents:
diff changeset
145 C c { 3.0f }; // { dg-error "cannot convert \[^\n\r]* to 'C' in initialization" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
146 // { dg-error "narrowing conversion of '3.0e.0f' from 'float' to 'int'" "" { target c++17 } .-1 }
111
kono
parents:
diff changeset
147 D d = { 7 }; // { dg-error "cannot convert \[^\n\r]* to 'D' in initialization" "" { target *-*-* } }
kono
parents:
diff changeset
148 };
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150 template <typename H, typename I, typename J, typename K, typename L, typename M>
kono
parents:
diff changeset
151 void
kono
parents:
diff changeset
152 foo3 ()
kono
parents:
diff changeset
153 {
kono
parents:
diff changeset
154 void bar3 (L);
kono
parents:
diff changeset
155 H a1 { 5 }; // { dg-error "invalid conversion from 'int' to 'A'" }
kono
parents:
diff changeset
156 I b1 { 7 }; // { dg-error "invalid conversion from 'int' to 'B'" "" { target c++14_down } }
kono
parents:
diff changeset
157 J c1 { s };
kono
parents:
diff changeset
158 K d1 { K(t) }; // { dg-error "invalid cast from type 'T' to type 'D'" }
kono
parents:
diff changeset
159 K d2 { t }; // { dg-error "cannot convert 'T' to 'D' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
160 // { dg-error "invalid cast from type 'T' to type 'D'" "" { target c++17 } .-1 }
kono
parents:
diff changeset
161 K d3 { 9 }; // { dg-error "cannot convert 'int' to 'D' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
162 K d4 { l }; // { dg-error "cannot convert 'long int' to 'D' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
163 K d5 { K(l) };
kono
parents:
diff changeset
164 K d6 { G }; // { dg-error "cannot convert 'A' to 'D' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
165 L e1 { 5 }; // { dg-error "cannot convert 'int' to 'E' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
166 L e2 { -1 }; // { dg-error "cannot convert 'int' to 'E' in initialization" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
167 // { dg-error "narrowing conversion of '-1' from 'int' to 'unsigned char'" "" { target c++17 } .-1 }
111
kono
parents:
diff changeset
168 L e3 { 5.0 }; // { dg-error "cannot convert 'double' to 'E' in initialization" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
169 // { dg-error "narrowing conversion of '5.0e.0' from 'double' to 'unsigned char'" "" { target c++17 } .-1 }
111
kono
parents:
diff changeset
170 L e4 { 5.2 }; // { dg-error "cannot convert 'double' to 'E' in initialization" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
171 // { dg-error "narrowing conversion of '5.\[0-9]*e.0' from 'double' to 'unsigned char'" "" { target c++17 } .-1 }
111
kono
parents:
diff changeset
172 I b2 = { 7 }; // { dg-error "invalid conversion from 'int' to 'B'" }
kono
parents:
diff changeset
173 J c2 = { J { 8 } }; // { dg-error "cannot convert 'int' to 'C' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
174 K *d7 = new K { 9 }; // { dg-error "cannot convert \[^\n\r]* to 'D' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
175 L *e5 = new L { -4 }; // { dg-error "cannot convert \[^\n\r]* to 'E' in initialization" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
176 // { dg-error "narrowing conversion of '-4' from 'int' to 'unsigned char'" "" { target c++17 } .-1 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
177 bar3 ({ 10 }); // { dg-error "cannot convert \[^\n\r]* to 'E'" }
111
kono
parents:
diff changeset
178 bar3 (E { 9 }); // { dg-error "cannot convert 'int' to 'E' in initialization" "" { target c++14_down } }
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
179 M v1 = { { 11 } }; // { dg-error "cannot convert '<brace-enclosed initializer list>' to 'E' in initialization" }
111
kono
parents:
diff changeset
180 M v2 = { L { 12 } }; // { dg-error "cannot convert 'int' to 'E' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
181 M v3 = { L { 5.0 } }; // { dg-error "cannot convert 'double' to 'E' in initialization" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
182 // { dg-error "narrowing conversion of '5.0e.0' from 'double' to 'unsigned char'" "" { target c++17 } .-1 }
111
kono
parents:
diff changeset
183 M v4 = { 13 }; // { dg-error "cannot convert 'int' to 'E' in initialization" }
kono
parents:
diff changeset
184 if (I b3 { 5 }) // { dg-error "invalid conversion from 'int' to 'B'" "" { target c++14_down } }
kono
parents:
diff changeset
185 ;
kono
parents:
diff changeset
186 if (I b4 { 4.0 }) // { dg-error "cannot convert 'double' to 'B' in initialization" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
187 ; // { dg-error "narrowing conversion of '4.0e.0' from 'double' to 'short int'" "" { target c++17 } .-1 }
111
kono
parents:
diff changeset
188 J c3 { 8L }; // { dg-error "cannot convert 'long int' to 'C' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
189 I b4 {short (c + 5)}; // { dg-error "invalid conversion from 'short int' to 'B'" "" { target c++14_down } }
kono
parents:
diff changeset
190 I b5 {c + 5}; // { dg-error "invalid conversion from 'int' to 'B'" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
191 // { dg-error "narrowing conversion of \[^\n\r]* from 'int' to 'short int'" "" { target c++17 } .-1 }
111
kono
parents:
diff changeset
192 J c4 { ll }; // { dg-error "cannot convert 'long long int' to 'C' in initialization" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
193 // { dg-error "narrowing conversion of 'll' from 'long long int' to 'int'" "" { target c++17 } .-1 }
111
kono
parents:
diff changeset
194 J c5 {short (c + 5)}; // { dg-error "cannot convert 'short int' to 'C' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
195 J c6 {c + 5}; // { dg-error "cannot convert 'int' to 'C' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
196 }
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198 template <typename L>
kono
parents:
diff changeset
199 struct U3
kono
parents:
diff changeset
200 {
kono
parents:
diff changeset
201 U3 () : e { 5 } {} // { dg-error "cannot convert \[^\n\r]* to 'E' in initialization" "" { target c++14_down } }
kono
parents:
diff changeset
202 U3 (int) : e { 5.0 } {}// { dg-error "cannot convert \[^\n\r]* to 'E' in initialization" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
203 // { dg-error "narrowing conversion of '5.0e.0' from 'double' to 'unsigned char'" "" { target c++17 } .-1 }
111
kono
parents:
diff changeset
204 U3 (float) : e({ 6 }) {}
kono
parents:
diff changeset
205 L e;
kono
parents:
diff changeset
206 };
kono
parents:
diff changeset
207
kono
parents:
diff changeset
208 template <typename H, typename I, typename J, typename K>
kono
parents:
diff changeset
209 struct W3
kono
parents:
diff changeset
210 {
kono
parents:
diff changeset
211 H a { 5 }; // { dg-error "invalid conversion from 'int' to 'A'" "" { target *-*-* } }
kono
parents:
diff changeset
212 I b { 6 }; // { dg-error "invalid conversion from 'int' to 'B'" "" { target c++14_down } }
kono
parents:
diff changeset
213 J c { 3.0f }; // { dg-error "cannot convert \[^\n\r]* to 'C' in initialization" "" { target c++14_down } }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
214 // { dg-error "narrowing conversion of '3.0e.0f' from 'float' to 'int'" "" { target c++17 } .-1 }
111
kono
parents:
diff changeset
215 K d = { 7 }; // { dg-error "cannot convert \[^\n\r]* to 'D' in initialization" "" { target *-*-* } }
kono
parents:
diff changeset
216 };
kono
parents:
diff changeset
217
kono
parents:
diff changeset
218 void
kono
parents:
diff changeset
219 test ()
kono
parents:
diff changeset
220 {
kono
parents:
diff changeset
221 foo2<0> ();
kono
parents:
diff changeset
222 U2<0> u20;
kono
parents:
diff changeset
223 U2<1> u21 (5);
kono
parents:
diff changeset
224 W2<0> w2; // { dg-message "" }
kono
parents:
diff changeset
225 foo3<A, B, C, D, E, V> ();
kono
parents:
diff changeset
226 U3<E> u30;
kono
parents:
diff changeset
227 U3<E> u31 (5);
kono
parents:
diff changeset
228 W3<A, B, C, D> w3; // { dg-message "" }
kono
parents:
diff changeset
229 }