kadircet created this revision. kadircet added a reviewer: hokein. kadircet requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D99145 Files: clang/lib/Sema/SemaChecking.cpp clang/test/Sema/check-arg-alignment.cpp Index: clang/test/Sema/check-arg-alignment.cpp =================================================================== --- /dev/null +++ clang/test/Sema/check-arg-alignment.cpp @@ -0,0 +1,13 @@ +// Ensure we don't crash when CTAD fails. +// RUN: %clang_cc1 -std=c++17 -verify %s +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}} +} 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);
Index: clang/test/Sema/check-arg-alignment.cpp =================================================================== --- /dev/null +++ clang/test/Sema/check-arg-alignment.cpp @@ -0,0 +1,13 @@ +// Ensure we don't crash when CTAD fails. +// RUN: %clang_cc1 -std=c++17 -verify %s +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}} +} 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);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits