@@ -1228,36 +1228,37 @@ bool Sema::AttachTypeConstraint(AutoTypeLoc TL,
1228
1228
NonTypeTemplateParmDecl *NewConstrainedParm,
1229
1229
NonTypeTemplateParmDecl *OrigConstrainedParm,
1230
1230
SourceLocation EllipsisLoc) {
1231
- if (NewConstrainedParm->getType ().getNonPackExpansionType () != TL.getType () ||
1232
- TL.getAutoKeyword () != AutoTypeKeyword::Auto) {
1233
- Diag (NewConstrainedParm->getTypeSourceInfo ()->getTypeLoc ().getBeginLoc (),
1234
- diag::err_unsupported_placeholder_constraint)
1235
- << NewConstrainedParm->getTypeSourceInfo ()
1236
- ->getTypeLoc ()
1237
- .getSourceRange ();
1238
- NewConstrainedParm->setPlaceholderTypeConstraint (
1239
- RecoveryExpr::Create (Context, OrigConstrainedParm->getType (),
1240
- OrigConstrainedParm->getBeginLoc (),
1241
- OrigConstrainedParm->getEndLoc (), {}));
1242
- return true ;
1243
- }
1244
- // FIXME: Concepts: This should be the type of the placeholder, but this is
1245
- // unclear in the wording right now.
1246
- DeclRefExpr *Ref =
1247
- BuildDeclRefExpr (OrigConstrainedParm, OrigConstrainedParm->getType (),
1248
- VK_PRValue, OrigConstrainedParm->getLocation ());
1249
- assert (Ref != nullptr && " Unexpected nullptr!" );
1231
+ ExprResult ImmediatelyDeclaredConstraint = [&] {
1232
+ if (NewConstrainedParm->getType ().getNonPackExpansionType () !=
1233
+ TL.getType () ||
1234
+ TL.getAutoKeyword () != AutoTypeKeyword::Auto) {
1235
+ Diag (NewConstrainedParm->getTypeSourceInfo ()->getTypeLoc ().getBeginLoc (),
1236
+ diag::err_unsupported_placeholder_constraint)
1237
+ << NewConstrainedParm->getTypeSourceInfo ()
1238
+ ->getTypeLoc ()
1239
+ .getSourceRange ();
1240
+ return ExprResult ();
1241
+ }
1242
+
1243
+ // FIXME: Concepts: This should be the type of the placeholder, but this is
1244
+ // unclear in the wording right now.
1245
+ DeclRefExpr *Ref =
1246
+ BuildDeclRefExpr (OrigConstrainedParm, OrigConstrainedParm->getType (),
1247
+ VK_PRValue, OrigConstrainedParm->getLocation ());
1248
+ assert (Ref != nullptr && " Unexpected nullptr!" );
1249
+
1250
+ return formImmediatelyDeclaredConstraint (
1251
+ *this , TL.getNestedNameSpecifierLoc (), TL.getConceptNameInfo (),
1252
+ TL.getNamedConcept (), /* FoundDecl=*/ TL.getFoundDecl (),
1253
+ TL.getLAngleLoc (), TL.getRAngleLoc (), BuildDecltypeType (Ref),
1254
+ OrigConstrainedParm->getLocation (),
1255
+ [&](TemplateArgumentListInfo &ConstraintArgs) {
1256
+ for (unsigned I = 0 , C = TL.getNumArgs (); I != C; ++I)
1257
+ ConstraintArgs.addArgument (TL.getArgLoc (I));
1258
+ },
1259
+ EllipsisLoc);
1260
+ }();
1250
1261
1251
- ExprResult ImmediatelyDeclaredConstraint = formImmediatelyDeclaredConstraint (
1252
- *this , TL.getNestedNameSpecifierLoc (), TL.getConceptNameInfo (),
1253
- TL.getNamedConcept (), /* FoundDecl=*/ TL.getFoundDecl (), TL.getLAngleLoc (),
1254
- TL.getRAngleLoc (), BuildDecltypeType (Ref),
1255
- OrigConstrainedParm->getLocation (),
1256
- [&](TemplateArgumentListInfo &ConstraintArgs) {
1257
- for (unsigned I = 0 , C = TL.getNumArgs (); I != C; ++I)
1258
- ConstraintArgs.addArgument (TL.getArgLoc (I));
1259
- },
1260
- EllipsisLoc);
1261
1262
if (ImmediatelyDeclaredConstraint.isInvalid () ||
1262
1263
!ImmediatelyDeclaredConstraint.isUsable ()) {
1263
1264
NewConstrainedParm->setPlaceholderTypeConstraint (
0 commit comments