44 lines · cpp
1// RUN: %clang_cc1 -Wno-error=return-type -std=c++23 -fsyntax-only -Wimplicit-fallthrough -Wconsumed -verify %s2 3constexpr int f() { } // expected-warning {{non-void function does not return a value}}4static_assert(__is_same(decltype([] constexpr -> int { }( )), int)); // expected-warning {{non-void lambda does not return a value}}5 6consteval int g() { } // expected-warning {{non-void function does not return a value}}7static_assert(__is_same(decltype([] consteval -> int { }( )), int)); // expected-warning {{non-void lambda does not return a value}}8 9namespace GH116485 {10int h() {11 if consteval { }12} // expected-warning {{non-void function does not return a value}}13 14void i(int x) {15 if consteval {16 }17 switch (x) {18 case 1:19 i(1);20 case 2: // expected-warning {{unannotated fall-through between switch labels}} \21 // expected-note {{insert 'break;' to avoid fall-through}}22 break;23 }24}25 26constexpr bool j() {27 if !consteval { return true; }28} // expected-warning {{non-void function does not return a value in all control paths}} \29 // expected-note {{control reached end of constexpr function}}30 31bool k = j();32constinit bool l = j(); // expected-error {{variable does not have a constant initializer}} \33 // expected-note {{required by 'constinit' specifier here}} \34 // expected-note {{in call to 'j()'}}35 36}37 38namespace GH117385 {39void f() {40 if consteval {41 }42}43}44