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