Skip to content

Commit 2b38688

Browse files
committed
Reland: [clang] Use getDefaultArgRange instead of getDefaultArg to retrieve
source location in `ConvertConstructorToDeductionGuideTransform`. The commit fec4716 was reverted by accident in 7415524. Reland it with a testcase.
1 parent baffaf0 commit 2b38688

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2679,7 +2679,7 @@ struct ConvertConstructorToDeductionGuideTransform {
26792679
// placeholder to indicate there is a default argument.
26802680
QualType ParamTy = NewDI->getType();
26812681
NewDefArg = new (SemaRef.Context)
2682-
OpaqueValueExpr(OldParam->getDefaultArg()->getBeginLoc(),
2682+
OpaqueValueExpr(OldParam->getDefaultArgRange().getBegin(),
26832683
ParamTy.getNonLValueExprType(SemaRef.Context),
26842684
ParamTy->isLValueReferenceType() ? VK_LValue
26852685
: ParamTy->isRValueReferenceType() ? VK_XValue

clang/test/SemaTemplate/ctad.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,18 @@ template<class T, class B> struct Y { Y(T); };
5454
template<class T, class B=void> struct Y ;
5555
Y y(1);
5656
}
57+
58+
namespace NoCrashOnGettingDefaultArgLoc {
59+
template <typename>
60+
class A {
61+
A(int = 1); // expected-note {{candidate template ignored: couldn't infer template argumen}}
62+
};
63+
class C : A<int> {
64+
using A::A;
65+
};
66+
template <typename>
67+
class D : C { // expected-note {{candidate function template not viable: requires 1 argument}}
68+
using C::C;
69+
};
70+
D abc; // expected-error {{no viable constructor or deduction guide}}
71+
}

0 commit comments

Comments
 (0)