[PATCH] D97965: [clang] Fix crash when creating deduction guide.
Adam Czachorowski via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 4 09:15:23 PST 2021
adamcz updated this revision to Diff 328206.
adamcz added a comment.
format
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97965/new/
https://reviews.llvm.org/D97965
Files:
clang/lib/Sema/SemaTemplate.cpp
clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
Index: clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
===================================================================
--- clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
+++ clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
@@ -416,6 +416,16 @@
}
+namespace no_crash_on_default_arg {
+class A {
+ template <typename T> class B {
+ B(int c = 1);
+ };
+ // This used to crash due to unparsed default arg above.
+ B(); // expected-error {{deduction guide declaration without trailing return type}}
+};
+} // namespace no_crash_on_default_arg
+
#pragma clang diagnostic push
#pragma clang diagnostic warning "-Wctad-maybe-unsupported"
namespace test_implicit_ctad_warning {
Index: clang/lib/Sema/SemaTemplate.cpp
===================================================================
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -2494,6 +2494,12 @@
if (!CD || (!FTD && CD->isFunctionTemplateSpecialization()))
continue;
+ // Cannot make a deduction guide when unparsed arguments are present.
+ if (std::any_of(CD->param_begin(), CD->param_end(), [](ParmVarDecl *P) {
+ return !P || P->hasUnparsedDefaultArg();
+ }))
+ continue;
+
Transform.transformConstructor(FTD, CD);
AddedAny = true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97965.328206.patch
Type: text/x-patch
Size: 1330 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210304/642ba406/attachment.bin>
More information about the cfe-commits
mailing list