File tree Expand file tree Collapse file tree 3 files changed +36
-2
lines changed Expand file tree Collapse file tree 3 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -559,6 +559,8 @@ Improvements to Clang's diagnostics
559
559
560
560
- Clang now diagnoses ``= delete("reason") `` extension warnings only in pedantic mode rather than on by default. (#GH109311).
561
561
562
+ - Clang now diagnoses missing return value in functions containing ``if consteval `` (#GH116485).
563
+
562
564
Improvements to Clang's time-trace
563
565
----------------------------------
564
566
Original file line number Diff line number Diff line change @@ -3177,11 +3177,14 @@ CFGBlock *CFGBuilder::VisitIfStmt(IfStmt *I) {
3177
3177
if (!I->isConsteval ())
3178
3178
KnownVal = tryEvaluateBool (I->getCond ());
3179
3179
3180
- // Add the successors. If we know that specific branches are
3180
+ // Add the successors. If we know that specific branches are
3181
3181
// unreachable, inform addSuccessor() of that knowledge.
3182
3182
addSuccessor (Block, ThenBlock, /* IsReachable = */ !KnownVal.isFalse ());
3183
3183
addSuccessor (Block, ElseBlock, /* IsReachable = */ !KnownVal.isTrue ());
3184
3184
3185
+ if (I->isConsteval ())
3186
+ return Block;
3187
+
3185
3188
// Add the condition as the last statement in the new block. This may
3186
3189
// create new blocks as the condition may contain control-flow. Any newly
3187
3190
// created blocks will be pointed to be "Block".
Original file line number Diff line number Diff line change 1
- // RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify %s
1
+ // RUN: %clang_cc1 -std=c++23 -fsyntax-only -Wimplicit-fallthrough - verify %s
2
2
3
3
constexpr int f () { } // expected-warning {{non-void function does not return a value}}
4
4
static_assert (__is_same(decltype ([] constexpr -> int { }( )), int)); // expected-warning {{non-void lambda does not return a value}}
5
5
6
6
consteval int g () { } // expected-warning {{non-void function does not return a value}}
7
7
static_assert (__is_same(decltype ([] consteval -> int { }( )), int)); // expected-warning {{non-void lambda does not return a value}}
8
+
9
+ namespace GH116485 {
10
+ int h () {
11
+ if consteval { }
12
+ } // 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
+
36
+ }
You can’t perform that action at this time.
0 commit comments