Skip to content

Commit d97a778

Browse files
committed
add additional tests
1 parent 69689f6 commit d97a778

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

clang/test/SemaCXX/constexpr-return-non-void-cxx2b.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify %s
1+
// RUN: %clang_cc1 -std=c++23 -fsyntax-only -Wimplicit-fallthrough -verify %s
22

33
constexpr int f() { } // expected-warning {{non-void function does not return a value}}
44
static_assert(__is_same(decltype([] constexpr -> int { }( )), int)); // expected-warning {{non-void lambda does not return a value}}
@@ -10,4 +10,27 @@ namespace GH116485 {
1010
int h() {
1111
if consteval { }
1212
} // expected-warning {{non-void function does not return a value}}
13+
14+
void 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+
26+
constexpr 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+
31+
bool k = j();
32+
constinit 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+
1336
}

0 commit comments

Comments
 (0)