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

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 11 14:30:25 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();
+      }
+    }
+
----------------
mizvekov wrote:

Hello, I missed the earlier notification for your message, and now I will be unavailable for the next couple of weeks, sorry about that.

Using a TreeTransform to fix things up post facto is certainly possible, but I think it should still be possible to detect we are getting into a struct definition from within an alias template.

I think whenever we get into an alias template, we push it into an evaluation context, and you might be able to look there.

I will take a better look at this in a couple of weeks.

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


More information about the cfe-commits mailing list