File tree Expand file tree Collapse file tree 2 files changed +35
-23
lines changed Expand file tree Collapse file tree 2 files changed +35
-23
lines changed Original file line number Diff line number Diff line change @@ -1126,4 +1126,39 @@ int test2() { return h{nullptr}; }
11261126// expected-note@-2 {{subobject 'g' is not initialized}}
11271127
11281128
1129+ }
1130+
1131+ namespace GH65985 {
1132+
1133+ int consteval operator " " _foo(unsigned long long V) {
1134+ return 0 ;
1135+ }
1136+ int consteval operator " " _bar(unsigned long long V); // expected-note 3{{here}}
1137+
1138+ int consteval f () {
1139+ return 0 ;
1140+ }
1141+
1142+ int consteval g (); // expected-note {{here}}
1143+
1144+
1145+ struct C {
1146+ static const int a = 1_foo;
1147+ static constexpr int b = 1_foo;
1148+ static const int c = 1_bar; // expected-error {{call to consteval function 'GH65985::operator""_bar' is not a constant expression}} \
1149+ // expected-note {{undefined function 'operator""_bar' cannot be used in a constant expression}} \
1150+ // expected-error {{in-class initializer for static data member is not a constant expression}}
1151+
1152+ // FIXME: remove duplicate diagnostics
1153+ static constexpr int d = 1_bar; // expected-error {{call to consteval function 'GH65985::operator""_bar' is not a constant expression}} \
1154+ // expected-note {{undefined function 'operator""_bar' cannot be used in a constant expression}} \
1155+ // expected-error {{constexpr variable 'd' must be initialized by a constant expression}} \
1156+ // expected-note {{undefined function 'operator""_bar' cannot be used in a constant expression}}
1157+
1158+ static const int e = f();
1159+ static const int f = g(); // expected-error {{call to consteval function 'GH65985::g' is not a constant expression}} \
1160+ // expected-error {{in-class initializer for static data member is not a constant expression}} \
1161+ // expected-note {{undefined function 'g' cannot be used in a constant expression}}
1162+ };
1163+
11291164}
Original file line number Diff line number Diff line change @@ -330,26 +330,3 @@ struct S {
330330S s (0 ); // expected-note {{in the default initializer of 'j'}}
331331
332332}
333-
334- namespace GH65985 {
335-
336- int consteval operator " " _foo(unsigned long long V) {
337- return 0 ;
338- }
339- int consteval operator " " _bar(unsigned long long V); // expected-note 3{{here}}
340-
341- struct C {
342- static const int a = 1_foo;
343- static constexpr int b = 1_foo;
344- static const int c = 1_bar; // expected-error {{call to consteval function 'GH65985::operator""_bar' is not a constant expression}} \
345- // expected-note {{undefined function 'operator""_bar' cannot be used in a constant expression}} \
346- // expected-error {{in-class initializer for static data member is not a constant expression}}
347-
348- // FIXME: remove duplicate diagnostics
349- static constexpr int d = 1_bar; // expected-error {{call to consteval function 'GH65985::operator""_bar' is not a constant expression}} \
350- // expected-note {{undefined function 'operator""_bar' cannot be used in a constant expression}} \
351- // expected-error {{constexpr variable 'd' must be initialized by a constant expression}} \
352- // expected-note {{undefined function 'operator""_bar' cannot be used in a constant expression}}
353- };
354-
355- }
You can’t perform that action at this time.
0 commit comments