[clang] [clang] Fix bad error recovery when classes are defined inside template (PR #142278)

Artyom Zabroda via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 1 03:19:27 PDT 2025


================
@@ -220,6 +220,14 @@ static ExprResult EvaluateAtomicConstraint(
     if (Inst.isInvalid())
       return ExprError();
 
+    if (const TemplateTypeParmType *TTPT =
+        dyn_cast<TemplateTypeParmType>(AtomicExpr->getType().getDesugaredType(S.Context))) {
+      TemplateTypeParmDecl *TTPD = TTPT->getDecl();
+      if (TTPD->isInvalidDecl()) {
+        return ExprError();
+      }
+    }
+
----------------
ArtyomZabroda wrote:

I don't understand how changing TTPDecl->setTypeForDecl to int can solve the issue for constraints. If I remove the check for invalid decl that I've made in EvaluateAtomicConstraint and set the type to int for the TemplateTypeParmDecl as you suggested, then the same errors pop up in the compiler. I'm not confident with the codebase yet, so maybe I've missed something, but I can't see any code in CheckInstantiatedFunctionTemplateConstraints and functions inside of it that checks dependence of a type inside TemplateTypeParmDecl before substituting an argument.

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


More information about the cfe-commits mailing list