@@ -7347,6 +7347,9 @@ ExprResult Sema::CheckTemplateArgument(NamedDecl *Param, QualType ParamType,
7347
7347
return Arg;
7348
7348
}
7349
7349
7350
+ // These should have all been handled above using the C++17 rules.
7351
+ assert (!ArgPE && !StrictCheck);
7352
+
7350
7353
// C++ [temp.arg.nontype]p5:
7351
7354
// The following conversions are performed on each expression used
7352
7355
// as a non-type template-argument. If a non-type
@@ -7374,13 +7377,13 @@ ExprResult Sema::CheckTemplateArgument(NamedDecl *Param, QualType ParamType,
7374
7377
// template-parameter; or
7375
7378
llvm::APSInt Value;
7376
7379
ExprResult ArgResult = CheckConvertedConstantExpression (
7377
- DeductionArg , ParamType, Value, CCEKind::TemplateArg);
7380
+ Arg , ParamType, Value, CCEKind::TemplateArg);
7378
7381
if (ArgResult.isInvalid ())
7379
7382
return ExprError ();
7380
- setDeductionArg ( ArgResult.get () );
7383
+ Arg = ArgResult.get ();
7381
7384
7382
7385
// We can't check arbitrary value-dependent arguments.
7383
- if (DeductionArg ->isValueDependent ()) {
7386
+ if (Arg ->isValueDependent ()) {
7384
7387
SugaredConverted = TemplateArgument (Arg, /* IsCanonical=*/ false );
7385
7388
CanonicalConverted =
7386
7389
Context.getCanonicalTemplateArgument (SugaredConverted);
@@ -7397,24 +7400,18 @@ ExprResult Sema::CheckTemplateArgument(NamedDecl *Param, QualType ParamType,
7397
7400
? Context.getIntWidth (IntegerType)
7398
7401
: Context.getTypeSize (IntegerType));
7399
7402
7400
- if (ArgPE) {
7401
- SugaredConverted = TemplateArgument (Arg, /* IsCanonical=*/ false );
7402
- CanonicalConverted =
7403
- Context.getCanonicalTemplateArgument (SugaredConverted);
7404
- } else {
7405
- SugaredConverted = TemplateArgument (Context, Value, ParamType);
7406
- CanonicalConverted = TemplateArgument (
7407
- Context, Value, Context.getCanonicalType (ParamType));
7408
- }
7403
+ SugaredConverted = TemplateArgument (Context, Value, ParamType);
7404
+ CanonicalConverted =
7405
+ TemplateArgument (Context, Value, Context.getCanonicalType (ParamType));
7409
7406
return Arg;
7410
7407
}
7411
7408
7412
7409
ExprResult ArgResult = DefaultLvalueConversion (Arg);
7413
7410
if (ArgResult.isInvalid ())
7414
7411
return ExprError ();
7415
- DeductionArg = ArgResult.get ();
7412
+ Arg = ArgResult.get ();
7416
7413
7417
- QualType ArgType = DeductionArg ->getType ();
7414
+ QualType ArgType = Arg ->getType ();
7418
7415
7419
7416
// C++ [temp.arg.nontype]p1:
7420
7417
// A template-argument for a non-type, non-template
@@ -7425,11 +7422,12 @@ ExprResult Sema::CheckTemplateArgument(NamedDecl *Param, QualType ParamType,
7425
7422
// -- the name of a non-type template-parameter; or
7426
7423
llvm::APSInt Value;
7427
7424
if (!ArgType->isIntegralOrEnumerationType ()) {
7428
- Diag (StartLoc , diag::err_template_arg_not_integral_or_enumeral)
7429
- << ArgType << DeductionArg ->getSourceRange ();
7425
+ Diag (Arg-> getBeginLoc () , diag::err_template_arg_not_integral_or_enumeral)
7426
+ << ArgType << Arg ->getSourceRange ();
7430
7427
NoteTemplateParameterLocation (*Param);
7431
7428
return ExprError ();
7432
- } else if (!DeductionArg->isValueDependent ()) {
7429
+ }
7430
+ if (!Arg->isValueDependent ()) {
7433
7431
class TmplArgICEDiagnoser : public VerifyICEDiagnoser {
7434
7432
QualType T;
7435
7433
@@ -7442,10 +7440,8 @@ ExprResult Sema::CheckTemplateArgument(NamedDecl *Param, QualType ParamType,
7442
7440
}
7443
7441
} Diagnoser (ArgType);
7444
7442
7445
- DeductionArg =
7446
- VerifyIntegerConstantExpression (DeductionArg, &Value, Diagnoser)
7447
- .get ();
7448
- if (!DeductionArg)
7443
+ Arg = VerifyIntegerConstantExpression (Arg, &Value, Diagnoser).get ();
7444
+ if (!Arg)
7449
7445
return ExprError ();
7450
7446
}
7451
7447
@@ -7458,28 +7454,23 @@ ExprResult Sema::CheckTemplateArgument(NamedDecl *Param, QualType ParamType,
7458
7454
// Okay: no conversion necessary
7459
7455
} else if (ParamType->isBooleanType ()) {
7460
7456
// This is an integral-to-boolean conversion.
7461
- DeductionArg =
7462
- ImpCastExprToType (DeductionArg, ParamType, CK_IntegralToBoolean)
7463
- .get ();
7457
+ Arg = ImpCastExprToType (Arg, ParamType, CK_IntegralToBoolean).get ();
7464
7458
} else if (IsIntegralPromotion (Arg, ArgType, ParamType) ||
7465
7459
!ParamType->isEnumeralType ()) {
7466
7460
// This is an integral promotion or conversion.
7467
- DeductionArg =
7468
- ImpCastExprToType (DeductionArg, ParamType, CK_IntegralCast).get ();
7461
+ Arg = ImpCastExprToType (Arg, ParamType, CK_IntegralCast).get ();
7469
7462
} else {
7470
7463
// We can't perform this conversion.
7471
7464
Diag (StartLoc, diag::err_template_arg_not_convertible)
7472
- << DeductionArg->getType () << ParamType
7473
- << DeductionArg->getSourceRange ();
7465
+ << Arg->getType () << ParamType << Arg->getSourceRange ();
7474
7466
NoteTemplateParameterLocation (*Param);
7475
7467
return ExprError ();
7476
7468
}
7477
- setDeductionArg (DeductionArg);
7478
7469
7479
7470
// Add the value of this argument to the list of converted
7480
7471
// arguments. We use the bitwidth and signedness of the template
7481
7472
// parameter.
7482
- if (DeductionArg ->isValueDependent ()) {
7473
+ if (Arg ->isValueDependent ()) {
7483
7474
// The argument is value-dependent. Create a new
7484
7475
// TemplateArgument with the converted expression.
7485
7476
SugaredConverted = TemplateArgument (Arg, /* IsCanonical=*/ false );
@@ -7537,20 +7528,14 @@ ExprResult Sema::CheckTemplateArgument(NamedDecl *Param, QualType ParamType,
7537
7528
}
7538
7529
}
7539
7530
7540
- if (ArgPE) {
7541
- SugaredConverted = TemplateArgument (Arg, /* IsCanonical=*/ false );
7542
- CanonicalConverted =
7543
- Context.getCanonicalTemplateArgument (SugaredConverted);
7544
- } else {
7545
- QualType T = ParamType->isEnumeralType () ? ParamType : IntegerType;
7546
- SugaredConverted = TemplateArgument (Context, Value, T);
7547
- CanonicalConverted =
7548
- TemplateArgument (Context, Value, Context.getCanonicalType (T));
7549
- }
7531
+ QualType T = ParamType->isEnumeralType () ? ParamType : IntegerType;
7532
+ SugaredConverted = TemplateArgument (Context, Value, T);
7533
+ CanonicalConverted =
7534
+ TemplateArgument (Context, Value, Context.getCanonicalType (T));
7550
7535
return Arg;
7551
7536
}
7552
7537
7553
- QualType ArgType = DeductionArg ->getType ();
7538
+ QualType ArgType = Arg ->getType ();
7554
7539
DeclAccessPair FoundResult; // temporary for ResolveOverloadedFunction
7555
7540
7556
7541
// Handle pointer-to-function, reference-to-function, and
@@ -7577,7 +7562,7 @@ ExprResult Sema::CheckTemplateArgument(NamedDecl *Param, QualType ParamType,
7577
7562
ParamType->castAs <MemberPointerType>()->getPointeeType ()
7578
7563
->isFunctionType ())) {
7579
7564
7580
- if (DeductionArg ->getType () == Context.OverloadTy ) {
7565
+ if (Arg ->getType () == Context.OverloadTy ) {
7581
7566
if (FunctionDecl *Fn = ResolveAddressOfOverloadedFunction (Arg, ParamType,
7582
7567
true ,
7583
7568
FoundResult)) {
@@ -7587,12 +7572,11 @@ ExprResult Sema::CheckTemplateArgument(NamedDecl *Param, QualType ParamType,
7587
7572
ExprResult Res = FixOverloadedFunctionReference (Arg, FoundResult, Fn);
7588
7573
if (Res.isInvalid ())
7589
7574
return ExprError ();
7590
- DeductionArg = Res.get ();
7575
+ Arg = Res.get ();
7591
7576
ArgType = Arg->getType ();
7592
7577
} else
7593
7578
return ExprError ();
7594
7579
}
7595
- setDeductionArg (DeductionArg);
7596
7580
7597
7581
if (!ParamType->isMemberPointerType ()) {
7598
7582
if (CheckTemplateArgumentAddressOfObjectOrFunction (
@@ -7608,8 +7592,6 @@ ExprResult Sema::CheckTemplateArgument(NamedDecl *Param, QualType ParamType,
7608
7592
return Arg;
7609
7593
}
7610
7594
7611
- setDeductionArg (DeductionArg);
7612
-
7613
7595
if (ParamType->isPointerType ()) {
7614
7596
// -- for a non-type template-parameter of type pointer to
7615
7597
// object, qualification conversions (4.4) and the
@@ -7618,7 +7600,6 @@ ExprResult Sema::CheckTemplateArgument(NamedDecl *Param, QualType ParamType,
7618
7600
assert (ParamType->getPointeeType ()->isIncompleteOrObjectType () &&
7619
7601
" Only object pointers allowed here" );
7620
7602
7621
- // FIXME: Deal with pack expansions here.
7622
7603
if (CheckTemplateArgumentAddressOfObjectOrFunction (
7623
7604
*this , Param, ParamType, Arg, SugaredConverted, CanonicalConverted))
7624
7605
return ExprError ();
@@ -7635,7 +7616,6 @@ ExprResult Sema::CheckTemplateArgument(NamedDecl *Param, QualType ParamType,
7635
7616
assert (ParamRefType->getPointeeType ()->isIncompleteOrObjectType () &&
7636
7617
" Only object references allowed here" );
7637
7618
7638
- // FIXME: Deal with pack expansions here.
7639
7619
if (Arg->getType () == Context.OverloadTy ) {
7640
7620
if (FunctionDecl *Fn = ResolveAddressOfOverloadedFunction (Arg,
7641
7621
ParamRefType->getPointeeType (),
@@ -7660,18 +7640,17 @@ ExprResult Sema::CheckTemplateArgument(NamedDecl *Param, QualType ParamType,
7660
7640
7661
7641
// Deal with parameters of type std::nullptr_t.
7662
7642
if (ParamType->isNullPtrType ()) {
7663
- if (DeductionArg ->isTypeDependent () || DeductionArg ->isValueDependent ()) {
7643
+ if (Arg ->isTypeDependent () || Arg ->isValueDependent ()) {
7664
7644
SugaredConverted = TemplateArgument (Arg, /* IsCanonical=*/ false );
7665
7645
CanonicalConverted =
7666
7646
Context.getCanonicalTemplateArgument (SugaredConverted);
7667
7647
return Arg;
7668
7648
}
7669
7649
7670
- switch (isNullPointerValueTemplateArgument (*this , Param, ParamType,
7671
- DeductionArg)) {
7650
+ switch (isNullPointerValueTemplateArgument (*this , Param, ParamType, Arg)) {
7672
7651
case NPV_NotNullPointer:
7673
7652
Diag (Arg->getExprLoc (), diag::err_template_arg_not_convertible)
7674
- << DeductionArg ->getType () << ParamType;
7653
+ << Arg ->getType () << ParamType;
7675
7654
NoteTemplateParameterLocation (*Param);
7676
7655
return ExprError ();
7677
7656
@@ -7680,17 +7659,10 @@ ExprResult Sema::CheckTemplateArgument(NamedDecl *Param, QualType ParamType,
7680
7659
7681
7660
case NPV_NullPointer:
7682
7661
Diag (Arg->getExprLoc (), diag::warn_cxx98_compat_template_arg_null);
7683
- if (ArgPE) {
7684
- SugaredConverted = TemplateArgument (Arg, /* IsCanonical=*/ false );
7685
- CanonicalConverted =
7686
- Context.getCanonicalTemplateArgument (SugaredConverted);
7687
- } else {
7688
- SugaredConverted = TemplateArgument (ParamType,
7662
+ SugaredConverted = TemplateArgument (ParamType,
7663
+ /* isNullPtr=*/ true );
7664
+ CanonicalConverted = TemplateArgument (Context.getCanonicalType (ParamType),
7689
7665
/* isNullPtr=*/ true );
7690
- CanonicalConverted =
7691
- TemplateArgument (Context.getCanonicalType (ParamType),
7692
- /* isNullPtr=*/ true );
7693
- }
7694
7666
return Arg;
7695
7667
}
7696
7668
}
@@ -7699,7 +7671,6 @@ ExprResult Sema::CheckTemplateArgument(NamedDecl *Param, QualType ParamType,
7699
7671
// member, qualification conversions (4.4) are applied.
7700
7672
assert (ParamType->isMemberPointerType () && " Only pointers to members remain" );
7701
7673
7702
- // FIXME: Deal with pack expansions here.
7703
7674
if (CheckTemplateArgumentPointerToMember (
7704
7675
*this , Param, ParamType, Arg, SugaredConverted, CanonicalConverted))
7705
7676
return ExprError ();
0 commit comments