diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp index 9969f1762fe36..92283867c38cd 100644 --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/lib/Sema/SemaTemplateDeduction.cpp @@ -4446,7 +4446,7 @@ static bool AdjustFunctionParmAndArgTypesForDeduction( // transformed A can be a pointer to a derived class pointed to by // the deduced A. if (isSimpleTemplateIdType(ParamType) || - (isa(ParamType) && + (ParamType->getAs() && isSimpleTemplateIdType( ParamType->castAs()->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 struct Base {}; +template struct Derived : Base {}; + +template void foo(Base *_Nonnull); + +template void bar(Base *); + + +void test() { + Derived d; + foo(&d); + bar(&d); +}