================
@@ -18,6 +18,21 @@ using namespace clang::interp;
 
 State::~State() {}
 
+bool State::shouldRelaxDiag(const SourceLocation &Loc, diag::kind DiagId) {
+  if (!Ctx.getLangOpts().MSVCCompat)
----------------
eleviant wrote:

> This is calling into the constant evaluator through 
> StandardConversionSequence::getNarrowingKind()?

Yes

> I think specifically in the context of BuildConvertedConstantExpression 
> calling getNarrowingKind(), it's okay to use relaxed mode, then throw away 
> the diagnostic: we know we're going to be evaluating the expression again, so 
> any diagnostic will get emitted later.

I've tried setting temporary pointer in ASTContext to set dummy `ExtendedDiag` 
pointer during `BuildConvertedConstantExpression`  (see latest update). Not 
sure, may be there there exists better way to accomplish this?

> More generally, I think we don't want to accept this as a constant expression 
> in contexts where we haven't considered it; that could lead to weird results; 
> that means we treat an expression that's not a constant express as a constant 
> expression, and that could lead to rejecting a valid program if SFINAE gets 
> involved.

For now we allow relaxed constant folding in these places only:
- VarDecl::evaluateValueImpl
- Sema::VerifyIntegerConstantExpression
- Sema::BuildConvertedConstantExpression / 
Sema::EvaluateConvertedConstantExpression



https://github.com/llvm/llvm-project/pull/197005
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to