Skip to content

Commit 8f80c66

Browse files
committed
[clang] Fix a crash when CTAD fails
Differential Revision: https://reviews.llvm.org/D99145
1 parent 003fab9 commit 8f80c66

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

clang/lib/Sema/SemaChecking.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4492,7 +4492,8 @@ void Sema::CheckArgAlignment(SourceLocation Loc, NamedDecl *FDecl,
44924492

44934493
// Find expected alignment, and the actual alignment of the passed object.
44944494
// getTypeAlignInChars requires complete types
4495-
if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType())
4495+
if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
4496+
ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
44964497
return;
44974498

44984499
CharUnits ParamAlign = Context.getTypeAlignInChars(ParamTy);

clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,18 @@ namespace PR47175 {
543543
int m = n<int>;
544544
}
545545

546+
// Ensure we don't crash when CTAD fails.
547+
template <typename T1, typename T2>
548+
struct Foo { // expected-note{{candidate function template not viable}}
549+
Foo(T1, T2); // expected-note{{candidate function template not viable}}
550+
};
551+
552+
template <typename... Args>
553+
void insert(Args &&...args);
554+
555+
void foo() {
556+
insert(Foo(2, 2, 2)); // expected-error{{no viable constructor or deduction guide}}
557+
}
546558
#else
547559

548560
// expected-no-diagnostics

0 commit comments

Comments
 (0)