Skip to content

Commit 03e78a9

Browse files
authored
[Clang][Sema] Check null after ExtractTypeForDeductionGuide (#165776)
1 parent bc08e69 commit 03e78a9

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,7 @@ Bug Fixes to C++ Support
505505
nontrivial member when another member has an initializer. (#GH81774)
506506
- Fixed a template depth issue when parsing lambdas inside a type constraint. (#GH162092)
507507
- Diagnose unresolved overload sets in non-dependent compound requirements. (#GH51246) (#GH97753)
508+
- Fix a crash when extracting unavailable member type from alias in template deduction. (#GH165560)
508509

509510
Bug Fixes to AST Handling
510511
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/SemaTemplateDeductionGuide.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,8 @@ struct ConvertConstructorToDeductionGuideTransform {
659659
SemaRef, MaterializedTypedefs, NestedPattern,
660660
TransformingOuterPatterns ? &Args : nullptr)
661661
.transform(NewDI);
662-
662+
if (!NewDI)
663+
return nullptr;
663664
// Resolving a wording defect, we also inherit default arguments from the
664665
// constructor.
665666
ExprResult NewDefArg;

clang/test/SemaTemplate/ctad.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,15 @@ namespace ConvertDeducedTemplateArgument {
104104

105105
auto x = C(D<A::B>());
106106
}
107+
108+
namespace pr165560 {
109+
template <class T, class> struct S {
110+
using A = T;
111+
template <class> struct I { // expected-note{{candidate function template not viable: requires 1 argument, but 0 were provided}} \
112+
// expected-note{{implicit deduction guide declared as 'template <class> I(pr165560::S<int, int>::I<type-parameter-0-0>) -> pr165560::S<int, int>::I<type-parameter-0-0>'}}
113+
I(typename A::F) {} // expected-error{{type 'A' (aka 'int') cannot be used prior to '::' because it has no members}}
114+
};
115+
};
116+
S<int, int>::I i; // expected-error{{no viable constructor or deduction guide for deduction of template arguments of 'S<int, int>::I'}} \
117+
// expected-note{{while building implicit deduction guide first needed here}}
118+
}

0 commit comments

Comments
 (0)