Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,8 @@ Improvements to Clang's diagnostics
getS(); // Now diagnoses "Reason 2", previously diagnoses "Reason 1"
}

- Clang now diagnoses missing return value in functions containing ``if consteval`` (#GH116485).

Improvements to Clang's time-trace
----------------------------------

Expand Down
5 changes: 4 additions & 1 deletion clang/lib/Analysis/CFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3177,11 +3177,14 @@ CFGBlock *CFGBuilder::VisitIfStmt(IfStmt *I) {
if (!I->isConsteval())
KnownVal = tryEvaluateBool(I->getCond());

// Add the successors. If we know that specific branches are
// Add the successors. If we know that specific branches are
// unreachable, inform addSuccessor() of that knowledge.
addSuccessor(Block, ThenBlock, /* IsReachable = */ !KnownVal.isFalse());
addSuccessor(Block, ElseBlock, /* IsReachable = */ !KnownVal.isTrue());

if (I->isConsteval())
return Block;

// Add the condition as the last statement in the new block. This may
// create new blocks as the condition may contain control-flow. Any newly
// created blocks will be pointed to be "Block".
Expand Down
6 changes: 6 additions & 0 deletions clang/test/SemaCXX/constexpr-return-non-void-cxx2b.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ static_assert(__is_same(decltype([] constexpr -> int { }( )), int)); // expected

consteval int g() { } // expected-warning {{non-void function does not return a value}}
static_assert(__is_same(decltype([] consteval -> int { }( )), int)); // expected-warning {{non-void lambda does not return a value}}

namespace GH116485 {
int h() {
if consteval { }
} // expected-warning {{non-void function does not return a value}}
}
Loading