[clang] [clang] Handle constructor closures with consteval default args (PR #203554)

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 22 05:44:54 PDT 2026


================
@@ -1070,10 +1070,8 @@ bool Sema::CheckCXXThrowOperand(SourceLocation ThrowLoc,
 
       // We don't keep the instantiated default argument expressions around so
       // we must rebuild them here.
-      for (unsigned I = 1, E = CD->getNumParams(); I != E; ++I) {
-        if (CheckCXXDefaultArgExpr(ThrowLoc, CD, CD->getParamDecl(I)))
-          return true;
-      }
+      if (BuildCtorClosureDefaultArgs(ThrowLoc, CD, /*IsCopy=*/true))
----------------
zmodem wrote:

If you mean why don't we check/build the default arg already at the copy constructor definition point, I suppose we don't know at that point whether we'll need them. 

BuildCtorClosureDefaultArgs() has a check that we don't build the arguments twice.

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


More information about the cfe-commits mailing list