diff --git a/clang/test/SemaCXX/cxx2a-consteval.cpp b/clang/test/SemaCXX/cxx2a-consteval.cpp index d98ec8048c324..82d3212ed8156 100644 --- a/clang/test/SemaCXX/cxx2a-consteval.cpp +++ b/clang/test/SemaCXX/cxx2a-consteval.cpp @@ -1126,4 +1126,39 @@ int test2() { return h{nullptr}; } // expected-note@-2 {{subobject 'g' is not initialized}} +} + +namespace GH65985 { + +int consteval operator""_foo(unsigned long long V) { + return 0; +} +int consteval operator""_bar(unsigned long long V); // expected-note 3{{here}} + +int consteval f() { + return 0; +} + +int consteval g(); // expected-note {{here}} + + +struct C { + static const int a = 1_foo; + static constexpr int b = 1_foo; + static const int c = 1_bar; // expected-error {{call to consteval function 'GH65985::operator""_bar' is not a constant expression}} \ + // expected-note {{undefined function 'operator""_bar' cannot be used in a constant expression}} \ + // expected-error {{in-class initializer for static data member is not a constant expression}} + + // FIXME: remove duplicate diagnostics + static constexpr int d = 1_bar; // expected-error {{call to consteval function 'GH65985::operator""_bar' is not a constant expression}} \ + // expected-note {{undefined function 'operator""_bar' cannot be used in a constant expression}} \ + // expected-error {{constexpr variable 'd' must be initialized by a constant expression}} \ + // expected-note {{undefined function 'operator""_bar' cannot be used in a constant expression}} + + static const int e = f(); + static const int f = g(); // expected-error {{call to consteval function 'GH65985::g' is not a constant expression}} \ + // expected-error {{in-class initializer for static data member is not a constant expression}} \ + // expected-note {{undefined function 'g' cannot be used in a constant expression}} +}; + } diff --git a/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp b/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp index f967ce6554d77..c5eb7f1393275 100644 --- a/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp +++ b/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp @@ -330,26 +330,3 @@ struct S { S s(0); // expected-note {{in the default initializer of 'j'}} } - -namespace GH65985 { - -int consteval operator""_foo(unsigned long long V) { - return 0; -} -int consteval operator""_bar(unsigned long long V); // expected-note 3{{here}} - -struct C { - static const int a = 1_foo; - static constexpr int b = 1_foo; - static const int c = 1_bar; // expected-error {{call to consteval function 'GH65985::operator""_bar' is not a constant expression}} \ - // expected-note {{undefined function 'operator""_bar' cannot be used in a constant expression}} \ - // expected-error {{in-class initializer for static data member is not a constant expression}} - - // FIXME: remove duplicate diagnostics - static constexpr int d = 1_bar; // expected-error {{call to consteval function 'GH65985::operator""_bar' is not a constant expression}} \ - // expected-note {{undefined function 'operator""_bar' cannot be used in a constant expression}} \ - // expected-error {{constexpr variable 'd' must be initialized by a constant expression}} \ - // expected-note {{undefined function 'operator""_bar' cannot be used in a constant expression}} -}; - -}