Author: Ilya Biryukov Date: 2025-04-04T14:23:55+02:00 New Revision: d02786e7785ffa8c0aae4d89e9f6391bb4645500
URL: https://github.com/llvm/llvm-project/commit/d02786e7785ffa8c0aae4d89e9f6391bb4645500 DIFF: https://github.com/llvm/llvm-project/commit/d02786e7785ffa8c0aae4d89e9f6391bb4645500.diff LOG: [Sema] Handle AttributedType in template deduction with derived-to-base conversions (#134361) Fix #134356. We accidentally skipped checking derived-to-base conversions because deduction did not strip sugar in the relevant code. This caused deduction failures when a parameter type had an attribute. Added: clang/test/Sema/nullability-and-template-deduction.cpp Modified: clang/lib/Sema/SemaTemplateDeduction.cpp Removed: ################################################################################ diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp index ab6e18aee7206..170b9f05002b1 100644 --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/lib/Sema/SemaTemplateDeduction.cpp @@ -4447,7 +4447,7 @@ static bool AdjustFunctionParmAndArgTypesForDeduction( // transformed A can be a pointer to a derived class pointed to by // the deduced A. if (isSimpleTemplateIdType(ParamType) || - (isa<PointerType>(ParamType) && + (ParamType->getAs<PointerType>() && isSimpleTemplateIdType( ParamType->castAs<PointerType>()->getPointeeType()))) TDF |= TDF_DerivedClass; diff --git a/clang/test/Sema/nullability-and-template-deduction.cpp b/clang/test/Sema/nullability-and-template-deduction.cpp new file mode 100644 index 0000000000000..3ea6d38d26b69 --- /dev/null +++ b/clang/test/Sema/nullability-and-template-deduction.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -fsyntax-only %s -verify +// expected-no-diagnostics + +template <class T> struct Base {}; +template <class T> struct Derived : Base<T> {}; + +template <class T> void foo(Base<T> *_Nonnull); + +template <class T> void bar(Base<T> *); + + +void test() { + Derived<int> d; + foo(&d); + bar(&d); +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits