[clang] Fix a crash when CTAD fails

Differential Revision: https://reviews.llvm.org/D99145
This commit is contained in:
Kadir Cetinkaya 2021-03-23 06:58:11 +01:00
parent 003fab9e8d
commit 8f80c66bd2
No known key found for this signature in database
GPG Key ID: E39E36B8D2057ED6
2 changed files with 14 additions and 1 deletions

View File

@ -4492,7 +4492,8 @@ void Sema::CheckArgAlignment(SourceLocation Loc, NamedDecl *FDecl,
// 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);

View File

@ -543,6 +543,18 @@ namespace PR47175 {
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