Skip to content

Commit d02786e

Browse files
[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.
1 parent 547d054 commit d02786e

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

clang/lib/Sema/SemaTemplateDeduction.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -4447,7 +4447,7 @@ static bool AdjustFunctionParmAndArgTypesForDeduction(
44474447
// transformed A can be a pointer to a derived class pointed to by
44484448
// the deduced A.
44494449
if (isSimpleTemplateIdType(ParamType) ||
4450-
(isa<PointerType>(ParamType) &&
4450+
(ParamType->getAs<PointerType>() &&
44514451
isSimpleTemplateIdType(
44524452
ParamType->castAs<PointerType>()->getPointeeType())))
44534453
TDF |= TDF_DerivedClass;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %clang_cc1 -fsyntax-only %s -verify
2+
// expected-no-diagnostics
3+
4+
template <class T> struct Base {};
5+
template <class T> struct Derived : Base<T> {};
6+
7+
template <class T> void foo(Base<T> *_Nonnull);
8+
9+
template <class T> void bar(Base<T> *);
10+
11+
12+
void test() {
13+
Derived<int> d;
14+
foo(&d);
15+
bar(&d);
16+
}

0 commit comments

Comments
 (0)