Skip to content

Commit ccce5dc

Browse files
author
git apple-llvm automerger
committed
Merge commit '7b28fcd2b182' from llvm.org/main into next
2 parents ff266ca + 7b28fcd commit ccce5dc

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

clang/lib/Sema/SemaTemplateDeduction.cpp

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ DeduceNonTypeTemplateArgument(Sema &S, TemplateParameterList *TemplateParams,
483483
return TemplateDeductionResult::Inconsistent;
484484
}
485485
Deduced[NTTP.getIndex()] = Result;
486-
if (!S.getLangOpts().CPlusPlus17)
486+
if (!S.getLangOpts().CPlusPlus17 && !PartialOrdering)
487487
return TemplateDeductionResult::Success;
488488

489489
if (NTTP.isExpandedParameterPack())
@@ -2652,28 +2652,11 @@ DeduceTemplateArguments(Sema &S, TemplateParameterList *TemplateParams,
26522652
getDeducedNTTParameterFromExpr(Info, P.getAsExpr())) {
26532653
switch (A.getKind()) {
26542654
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.
26742656
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);
26772660
}
26782661
case TemplateArgument::Integral:
26792662
case TemplateArgument::StructuralValue:

0 commit comments

Comments
 (0)