1 // RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s 2 3 consteval int Fun() { return; } // expected-error {{non-void consteval function 'Fun' should return a value}} 4 5 template <typename T> consteval int FunT1() { return; } // expected-error {{non-void consteval function 'FunT1' should return a value}} 6 template <typename T> consteval int FunT2() { return 0; } 7 template <> consteval int FunT2<double>() { return 0; } 8 template <> consteval int FunT2<int>() { return; } // expected-error {{non-void consteval function 'FunT2<int>' should return a value}} 9 10 enum E {}; 11 12 constexpr E operator+(E,E) { return; } // expected-error {{non-void constexpr function 'operator+' should return a value}} 13 consteval E operator-(E,E) { return; } // expected-error {{non-void consteval function 'operator-' should return a value}} 14 template <typename T> constexpr E operator+(E,E) { return; } // expected-error {{non-void constexpr function 'operator+' should return a value}} 15 template <typename T> consteval E operator-(E,E) { return; } // expected-error {{non-void consteval function 'operator-' should return a value}} 16 17 template <typename T> constexpr E operator*(E,E); 18 template <typename T> consteval E operator/(E,E); 19 template <> constexpr E operator*<int>(E,E) { return; } // expected-error {{non-void constexpr function 'operator*<int>' should return a value}} 20 template <> consteval E operator/<int>(E,E) { return; } // expected-error {{non-void consteval function 'operator/<int>' should return a value}} 21 22 consteval void no_return() {} 23 consteval void with_return() { return; } 24 consteval void with_return_void() { return void(); } 25 void use_void_fn() { 26 no_return(); 27 with_return(); 28 with_return_void(); 29 } 30