@@ -1228,45 +1228,35 @@ bool Sema::AttachTypeConstraint(AutoTypeLoc TL,
1228
1228
NonTypeTemplateParmDecl *NewConstrainedParm,
1229
1229
NonTypeTemplateParmDecl *OrigConstrainedParm,
1230
1230
SourceLocation EllipsisLoc) {
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
- }();
1261
-
1262
- if (ImmediatelyDeclaredConstraint.isInvalid () ||
1263
- !ImmediatelyDeclaredConstraint.isUsable ()) {
1264
- NewConstrainedParm->setPlaceholderTypeConstraint (
1265
- RecoveryExpr::Create (Context, OrigConstrainedParm->getType (),
1266
- OrigConstrainedParm->getBeginLoc (),
1267
- OrigConstrainedParm->getEndLoc (), {}));
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 ();
1268
1238
return true ;
1269
1239
}
1240
+ // FIXME: Concepts: This should be the type of the placeholder, but this is
1241
+ // unclear in the wording right now.
1242
+ DeclRefExpr *Ref =
1243
+ BuildDeclRefExpr (OrigConstrainedParm, OrigConstrainedParm->getType (),
1244
+ VK_PRValue, OrigConstrainedParm->getLocation ());
1245
+ if (!Ref)
1246
+ return true ;
1247
+ ExprResult ImmediatelyDeclaredConstraint = formImmediatelyDeclaredConstraint (
1248
+ *this , TL.getNestedNameSpecifierLoc (), TL.getConceptNameInfo (),
1249
+ TL.getNamedConcept (), /* FoundDecl=*/ TL.getFoundDecl (), TL.getLAngleLoc (),
1250
+ TL.getRAngleLoc (), BuildDecltypeType (Ref),
1251
+ OrigConstrainedParm->getLocation (),
1252
+ [&](TemplateArgumentListInfo &ConstraintArgs) {
1253
+ for (unsigned I = 0 , C = TL.getNumArgs (); I != C; ++I)
1254
+ ConstraintArgs.addArgument (TL.getArgLoc (I));
1255
+ },
1256
+ EllipsisLoc);
1257
+ if (ImmediatelyDeclaredConstraint.isInvalid () ||
1258
+ !ImmediatelyDeclaredConstraint.isUsable ())
1259
+ return true ;
1270
1260
1271
1261
NewConstrainedParm->setPlaceholderTypeConstraint (
1272
1262
ImmediatelyDeclaredConstraint.get ());
0 commit comments