@@ -483,7 +483,7 @@ DeduceNonTypeTemplateArgument(Sema &S, TemplateParameterList *TemplateParams,
483
483
return TemplateDeductionResult::Inconsistent;
484
484
}
485
485
Deduced[NTTP.getIndex ()] = Result;
486
- if (!S.getLangOpts ().CPlusPlus17 )
486
+ if (!S.getLangOpts ().CPlusPlus17 && !PartialOrdering )
487
487
return TemplateDeductionResult::Success;
488
488
489
489
if (NTTP.isExpandedParameterPack ())
@@ -2652,28 +2652,11 @@ DeduceTemplateArguments(Sema &S, TemplateParameterList *TemplateParams,
2652
2652
getDeducedNTTParameterFromExpr (Info, P.getAsExpr ())) {
2653
2653
switch (A.getKind ()) {
2654
2654
case TemplateArgument::Expression: {
2655
- const Expr *E = A.getAsExpr ();
2656
- // When checking NTTP, if either the parameter or the argument is
2657
- // dependent, as there would be otherwise nothing to deduce, we force
2658
- // the argument to the parameter type using this dependent implicit
2659
- // cast, in order to maintain invariants. Now we can deduce the
2660
- // resulting type from the original type, and deduce the original type
2661
- // against the parameter we are checking.
2662
- if (const auto *ICE = dyn_cast<ImplicitCastExpr>(E);
2663
- ICE && ICE->getCastKind () == clang::CK_Dependent) {
2664
- E = ICE->getSubExpr ();
2665
- if (auto Result = DeduceTemplateArgumentsByTypeMatch (
2666
- S, TemplateParams, ICE->getType (), E->getType (), Info,
2667
- Deduced, TDF_SkipNonDependent,
2668
- PartialOrdering ? PartialOrderingKind::NonCall
2669
- : PartialOrderingKind::None,
2670
- /* DeducedFromArrayBound=*/ false , HasDeducedAnyParam);
2671
- Result != TemplateDeductionResult::Success)
2672
- return Result;
2673
- }
2655
+ // The type of the value is the type of the expression as written.
2674
2656
return DeduceNonTypeTemplateArgument (
2675
- S, TemplateParams, NTTP, DeducedTemplateArgument (A), E->getType (),
2676
- Info, PartialOrdering, Deduced, HasDeducedAnyParam);
2657
+ S, TemplateParams, NTTP, DeducedTemplateArgument (A),
2658
+ A.getAsExpr ()->IgnoreImplicitAsWritten ()->getType (), Info,
2659
+ PartialOrdering, Deduced, HasDeducedAnyParam);
2677
2660
}
2678
2661
case TemplateArgument::Integral:
2679
2662
case TemplateArgument::StructuralValue:
0 commit comments