Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / SemaCXX / consteval-return-void.cpp
blobb21e8e821dc6e7d0b5534cb4b80a1d87f80b506c
1 // RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
3 consteval int Fun() { return; } // expected-error {{non-void consteval function 'Fun' should return a value}}
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}}
10 enum E {};
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}}
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}}
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();