@@ -811,7 +811,7 @@ populate(
811811 {
812812 populate (I.Requires , TRC);
813813 }
814- else
814+ else if (I. Requires . Written . empty ())
815815 {
816816 // Return type SFINAE constraints
817817 if (I.ReturnType &&
@@ -1200,33 +1200,37 @@ populate(
12001200 }
12011201
12021202 // Extract requires clause from SFINAE context
1203- for ( auto it = Template.Args . begin (); it != Template. Args . end (); )
1203+ if ( Template.Requires . Written . empty () )
12041204 {
1205- auto & arg = *it;
1206- if (!arg)
1207- {
1208- ++it;
1209- continue ;
1210- }
1211- if (auto * T = dynamic_cast <TypeTArg*>(arg.operator ->());
1212- T &&
1213- T->Type &&
1214- !T->Type ->Constraints .empty ())
1205+ for (auto it = Template.Args .begin (); it != Template.Args .end ();)
12151206 {
1216- for (ExprInfo const & constraint: T->Type ->Constraints )
1207+ auto & arg = *it;
1208+ if (!arg)
1209+ {
1210+ ++it;
1211+ continue ;
1212+ }
1213+ if (auto * T = dynamic_cast <TypeTArg*>(arg.operator ->());
1214+ T &&
1215+ T->Type &&
1216+ !T->Type ->Constraints .empty ())
12171217 {
1218- if (!Template. Requires . Written . empty () )
1218+ for (ExprInfo const & constraint: T-> Type -> Constraints )
12191219 {
1220- Template.Requires .Written += " && " ;
1220+ if (!Template.Requires .Written .empty ())
1221+ {
1222+ Template.Requires .Written += " && " ;
1223+ }
1224+ Template.Requires .Written += constraint.Written ;
12211225 }
1222- Template.Requires .Written += constraint.Written ;
1226+ it = Template.Args .erase (it);
1227+ continue ;
12231228 }
1224- it = Template.Args .erase (it);
1225- continue ;
1229+ ++it;
12261230 }
1227- ++it;
12281231 }
12291232
1233+
12301234 // Extract the template parameters if this is a partial specialization
12311235 if (auto * CTPSD = dyn_cast<ClassTemplatePartialSpecializationDecl>(CTSD))
12321236 {
@@ -1468,7 +1472,7 @@ populate(
14681472 {
14691473 populate (TI.Requires , RC);
14701474 }
1471- else
1475+ else if (TI. Requires . Written . empty ())
14721476 {
14731477 // If there's no requires clause, check if the template
14741478 // parameter types we extracted have constraints
0 commit comments