-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[Clang][Sema] Check null after ExtractTypeForDeductionGuide #165776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-clang Author: Qiu Chaofan (ecnelises) ChangesFixes #165560 Full diff: https://github.com/llvm/llvm-project/pull/165776.diff 2 Files Affected:
diff --git a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
index ad50600f6399c..bfcd3978817ca 100644
--- a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
+++ b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
@@ -659,7 +659,8 @@ struct ConvertConstructorToDeductionGuideTransform {
SemaRef, MaterializedTypedefs, NestedPattern,
TransformingOuterPatterns ? &Args : nullptr)
.transform(NewDI);
-
+ if (!NewDI)
+ return nullptr;
// Resolving a wording defect, we also inherit default arguments from the
// constructor.
ExprResult NewDefArg;
diff --git a/clang/test/SemaTemplate/ctad.cpp b/clang/test/SemaTemplate/ctad.cpp
index 1a575ea527006..60603f0c963a5 100644
--- a/clang/test/SemaTemplate/ctad.cpp
+++ b/clang/test/SemaTemplate/ctad.cpp
@@ -104,3 +104,15 @@ namespace ConvertDeducedTemplateArgument {
auto x = C(D<A::B>());
}
+
+namespace pr165560 {
+template <class T, class> struct S {
+ using A = T;
+ template <class> struct I { // expected-note{{candidate function template not viable: requires 1 argument, but 0 were provided}} \
+ // 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>'}}
+ I(typename A::F) {} // expected-error{{type 'A' (aka 'int') cannot be used prior to '::' because it has no members}}
+ };
+};
+S<int, int>::I i; // expected-error{{no viable constructor or deduction guide for deduction of template arguments of 'S<int, int>::I'}} \
+ // expected-note{{while building implicit deduction guide first needed here}}
+}
|
Fznamznon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for working on this, could you please add a release note?
60c6b13 to
a74b48f
Compare
|
@Fznamznon could you have a quick look at the release note? thanks! |
Fznamznon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Fixes #165560