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

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to