[Sema] Diagnose annotating `if constexpr` with a likelihood attribute
authorMark de Wever <koraq@xs4all.nl>
Sat, 31 Oct 2020 12:07:06 +0000 (13:07 +0100)
committerMark de Wever <koraq@xs4all.nl>
Sat, 31 Oct 2020 16:51:36 +0000 (17:51 +0100)
commitb231396122f131ffaff5fc4ba36685a7df554aaa
tree89d6ff8095939b84590667d49a20ce4fa366eb91
parentb46fddf75fc27ee1545f00ab853d50b10c1d7ee6
[Sema] Diagnose annotating `if constexpr` with a likelihood attribute

Adds a diagnostic when the user annotates an `if constexpr` with a
likelihood attribute. The `if constexpr` statement is evaluated at compile
time so the attribute has no effect. Annotating the accompanied `else`
with a likelihood attribute has the same effect as annotating a generic
statement. Since the attribute there is most likely not intended, a
diagnostic will be issued. Since the attributes can't conflict, the
"conflict" won't be diagnosed for an `if constexpr`.

Differential Revision: https://reviews.llvm.org/D90336
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaStmt.cpp
clang/test/SemaCXX/attr-likelihood.cpp