1 // RUN: %clang_cc1 -std=c++2a -fsyntax-only %s -verify 2 3 namespace basic_sema { 4 f1(int i)5consteval int f1(int i) { 6 return i; 7 } 8 f2(int i)9consteval constexpr int f2(int i) { 10 //expected-error@-1 {{cannot combine}} 11 return i; 12 } 13 __anon7450ca5d0102(int i) 14constexpr auto l_eval = [](int i) consteval { 15 16 return i; 17 }; 18 f3(int i)19constexpr consteval int f3(int i) { 20 //expected-error@-1 {{cannot combine}} 21 return i; 22 } 23 24 struct A { f1basic_sema::A25 consteval int f1(int i) const { 26 return i; 27 } 28 consteval A(int i); 29 consteval A() = default; 30 consteval ~A() = default; 31 }; 32 33 consteval struct B {}; // expected-error {{struct cannot be marked consteval}} 34 35 consteval typedef B b; // expected-error {{typedef cannot be consteval}} 36 redecl()37consteval int redecl() {return 0;} // expected-note {{previous declaration is here}} redecl()38constexpr int redecl() {return 0;} // expected-error {{constexpr declaration of 'redecl' follows consteval declaration}} 39 40 consteval int i = 0; // expected-error {{consteval can only be used in function declarations}} 41 42 consteval int; // expected-error {{consteval can only be used in function declarations}} 43 f1()44consteval int f1() {} // expected-error {{no return statement in consteval function}} 45 46 struct C { Cbasic_sema::C47 C() {} ~Cbasic_sema::C48 ~C() {} 49 }; 50 51 struct D { 52 C c; 53 consteval D() = default; // expected-error {{cannot be consteval}} 54 consteval ~D() = default; // expected-error {{cannot be consteval}} 55 }; 56 57 struct E : C { // expected-note {{here}} ~Ebasic_sema::E58 consteval ~E() {} // expected-error {{cannot be declared consteval because base class 'basic_sema::C' does not have a constexpr destructor}} 59 }; 60 } 61 main()62consteval int main() { // expected-error {{'main' is not allowed to be declared consteval}} 63 return 0; 64 } 65