This is an archive of the discontinued LLVM Phabricator instance.

[clang][diagnostics] Don't warn about unreachable code in constexpr if
ClosedPublic

Authored by ayzhao on Aug 12 2022, 4:45 PM.

Details

Summary

The point of a constexpr if statement is to determine which branch to
take at compile time, so warning on unreachable code is meaningless in
these situations.

Fixes #57123.

Diff Detail

Event Timeline

ayzhao created this revision.Aug 12 2022, 4:45 PM
Herald added a project: Restricted Project. · View Herald Transcript
ayzhao requested review of this revision.Aug 12 2022, 4:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 12 2022, 4:45 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
ayzhao updated this revision to Diff 452334.Aug 12 2022, 4:59 PM

Add a test for non-constexpr if statements

inclyc added a subscriber: inclyc.Aug 13 2022, 8:56 PM

Thanks!

Can you add a test for non-constexpr unreachable code within the constexpr if and test that that still warns?

ayzhao updated this revision to Diff 452721.Aug 15 2022, 9:53 AM

Add tests for nested non-constexpr if

Thanks!

Can you add a test for non-constexpr unreachable code within the constexpr if and test that that still warns?

Done

thakis accepted this revision.Aug 15 2022, 11:34 AM

Thanks!

This revision is now accepted and ready to land.Aug 15 2022, 11:34 AM