[clang] [clang][Sema] Fix access checking in nested concept-id substitution (PR #246811)

Shashwat Agrawal via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 29 01:53:23 PST 2026


================
@@ -812,7 +812,12 @@ ConstraintSatisfactionChecker::SubstitutionInTemplateArguments(
   // mappings to preserve the outer depths.
   if (S.SubstTemplateArgumentsInParameterMapping(
           Constraint.getParameterMapping(), Constraint.getBeginLoc(), MLTAL,
-          SubstArgs)) {
+          SubstArgs) ||
+      Trap.hasErrorOccurred()) {
----------------
ShashwatAgrawal20 wrote:

It is a bit odd. `SubstTemplateArgumentsInParameterMapping` reports failures through its return value, but access-control diagnostics are `SFINAE_AccessControl`: `Sema::EmitDiagnostic` records them on the active `SFINAETrap` and suppresses them, so the transform can complete and return success (`false`).

I checked the trap at the call site to match the existing patterns in this file: `EvaluateAtomicConstraint` (`isInvalid() || Trap.hasErrorOccurred()`) and `EvaluateSlow(ConceptIdConstraint)` (`SubstTemplateArguments(...) || Trap.hasErrorOccurred()`). I didn't move it into the helper because `SubstituteParameterMappings` also calls it during normalization under `Sema::NonSFINAEContext`, where there's no trap and these diagnostics should remain hard errors.

Happy to leave it as-is with the comment, or fold the check into the helper behind an active-SFINAE guard if you'd prefer that shape.

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


More information about the cfe-commits mailing list