Skip to content

Commit f76ebd3

Browse files
committed
[Clang] skip consumed analysis for consteval conditions in control-flow terminators
1 parent 2704647 commit f76ebd3

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

clang/lib/Analysis/Consumed.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,6 +1229,9 @@ bool ConsumedAnalyzer::splitState(const CFGBlock *CurrBlock,
12291229

12301230
if (const auto *IfNode =
12311231
dyn_cast_or_null<IfStmt>(CurrBlock->getTerminator().getStmt())) {
1232+
if (IfNode->isConsteval())
1233+
return false;
1234+
12321235
const Expr *Cond = IfNode->getCond();
12331236

12341237
PInfo = Visitor.getInfo(Cond);

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -std=c++23 -fsyntax-only -Wimplicit-fallthrough -verify %s
1+
// RUN: %clang_cc1 -std=c++23 -fsyntax-only -Wimplicit-fallthrough -Wconsumed -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}}
@@ -34,3 +34,10 @@ constinit bool l = j(); // expected-error {{variable does not have a constant in
3434
// expected-note {{in call to 'j()'}}
3535

3636
}
37+
38+
namespace GH117385 {
39+
void f() {
40+
if consteval {
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)