Skip to content

Commit 061aa96

Browse files
committed
[Sema] Handle AttributedType in template deduction with derived-to-base conversions
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 61ef286 commit 061aa96

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

clang/lib/Sema/SemaTemplateDeduction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4446,7 +4446,7 @@ static bool AdjustFunctionParmAndArgTypesForDeduction(
44464446
// transformed A can be a pointer to a derived class pointed to by
44474447
// the deduced A.
44484448
if (isSimpleTemplateIdType(ParamType) ||
4449-
(isa<PointerType>(ParamType) &&
4449+
(ParamType->getAs<PointerType>() &&
44504450
isSimpleTemplateIdType(
44514451
ParamType->castAs<PointerType>()->getPointeeType())))
44524452
TDF |= TDF_DerivedClass;
Lines changed: 16 additions & 0 deletions
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)