[PATCH] D131704: [Clang] Tighten restrictions on enum out of range diagnostic
Shafik Yaghmour via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 12 23:22:06 PDT 2022
shafik added a comment.
In D131704#3719954 <https://reviews.llvm.org/D131704#3719954>, @thakis wrote:
>> This is constant initialization, so this is indeed expected.
>
> Do we have a test for this in clang? It seems that the diag appeared for that case after the change that turned this diag into a disable-able warning. Given it's intentional, we should make sure we test that this diag is emitted, to make sure it stays around once the diag goes back to always-an-error.
After discussing this with @erichkeane we decided that a diagnostic for the constant initialization of a global was not desirable.
It took me a while to find a solution for this case. One might think that `CCEDiag` machinery would have the information we need to determine whether we are initializing a `constexpr` variable or not but actually the determination of whether to discard the diagnostic is done by the consumer further away. An example can be seen in `Sema::CheckCompleteVariableDeclaration` when it gets the diagnostic notes from `var->checkForConstantInitialization(Notes)`. If the initialization is not constant then it must do various checks for example `var->isConstexpr()` to determine whether to discard the diagnostics or not.
Fortunately, we have access to the `VarDecl` through `Info.EvaluatingDecl` and we do similar checks in other instances. I am testing some approaches.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131704/new/
https://reviews.llvm.org/D131704
More information about the cfe-commits
mailing list