[clang] [clang][Sema] Guard diagnose_if value-dependent conditions (PR #197647)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon May 18 07:55:55 PDT 2026


================
@@ -7801,8 +7801,12 @@ bool Sema::diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function,
         // It's sane to use the same Args for any redecl of this function, since
         // EvaluateWithSubstitution only cares about the position of each
         // argument in the arg list, not the ParmVarDecl* it maps to.
-        if (!DIA->getCond()->EvaluateWithSubstitution(
-                Result, Context, cast<FunctionDecl>(DIA->getParent()), Args, ThisArg))
+        // FIXME: This doesn't consider value-dependent cases, because doing so
+        // is very difficult. Ideally, we should handle them more gracefully.
+        if (DIA->getCond()->isValueDependent() ||
----------------
AaronBallman wrote:

> Perhaps I'm misunderstanding it here... but I don't think the fixme is actually valid. We can't actually CHECK value-dependent cases here, this is a situation where we just have to decide that diagnose_if succeeded, and catch it during a future instantaition, right?

That's what I meant by fix -- once we have the instantiation, it's no longer value dependent and we should catch it then. So this would do the usual two-step dance where we check the non-dependent bits as soon as we can, and then the dependent bits when rebuilding from tree transform.

https://github.com/llvm/llvm-project/pull/197647


More information about the cfe-commits mailing list