Skip to content

Commit f091991

Browse files
committed
Fix an assert hit with default arguments.
1 parent 0b59273 commit f091991

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

clang/lib/Sema/SemaInit.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10922,11 +10922,15 @@ struct AliasTemplateDeductionGuideTransform {
1092210922
// placeholder to indicate there is a default argument.
1092310923
QualType ParamTy = NewDI->getType();
1092410924
NewDefArg = new (SemaRef.Context)
10925-
OpaqueValueExpr(OldParam->getDefaultArg()->getBeginLoc(),
10926-
ParamTy.getNonLValueExprType(SemaRef.Context),
10927-
ParamTy->isLValueReferenceType() ? VK_LValue
10928-
: ParamTy->isRValueReferenceType() ? VK_XValue
10929-
: VK_PRValue);
10925+
// FIXME: using getDefaultArg will crash hitting "Default argument is
10926+
// not yet instantiated!" erro, fixed in constructor transformer as
10927+
// well.
10928+
OpaqueValueExpr(
10929+
OldParam->getDefaultArgRange().getBegin(),
10930+
ParamTy.getNonLValueExprType(SemaRef.Context),
10931+
ParamTy->isLValueReferenceType() ? VK_LValue
10932+
: ParamTy->isRValueReferenceType() ? VK_XValue
10933+
: VK_PRValue);
1093010934
}
1093110935

1093210936
ParmVarDecl *NewParam = ParmVarDecl::Create(SemaRef.Context, DC,

clang/test/SemaCXX/cxx20-ctad-type-alias.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,14 @@ void test2() {
3030
static_assert(__is_same(decltype(xy.x), int));
3131
static_assert(__is_same(decltype(xy.y), double));
3232
}
33+
34+
namespace test3 {
35+
template<typename T, class>
36+
struct container {
37+
// test with default arguments.
38+
container(T a , T b = T());
39+
};
40+
41+
template<class T> using vector = container<T, int>;
42+
vector v(0, 0);
43+
} // namespace test3

0 commit comments

Comments
 (0)