[PATCH] D99145: [clang] Fix a crash when CTAD fails
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 23 05:05:05 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8f80c66bd298: [clang] Fix a crash when CTAD fails (authored by kadircet).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D99145/new/
https://reviews.llvm.org/D99145
Files:
clang/lib/Sema/SemaChecking.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
@@ -543,6 +543,18 @@
int m = n<int>;
}
+// Ensure we don't crash when CTAD fails.
+template <typename T1, typename T2>
+struct Foo { // expected-note{{candidate function template not viable}}
+ Foo(T1, T2); // expected-note{{candidate function template not viable}}
+};
+
+template <typename... Args>
+void insert(Args &&...args);
+
+void foo() {
+ insert(Foo(2, 2, 2)); // expected-error{{no viable constructor or deduction guide}}
+}
#else
// expected-no-diagnostics
Index: clang/lib/Sema/SemaChecking.cpp
===================================================================
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4492,7 +4492,8 @@
// Find expected alignment, and the actual alignment of the passed object.
// getTypeAlignInChars requires complete types
- if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType())
+ if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
+ ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
return;
CharUnits ParamAlign = Context.getTypeAlignInChars(ParamTy);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99145.332626.patch
Type: text/x-patch
Size: 1360 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210323/c99184d4/attachment.bin>
More information about the cfe-commits
mailing list