
types. We previously did not treat a function type as dependent if it had a parameter pack with a non-dependent type -- such a function type depends on the arity of the pack so is dependent even though none of the parameter types is dependent. In order to properly handle this, we now treat pack expansion types as always being dependent types (depending on at least the pack arity), and always canonically being pack expansion types, even in the unusual case when the pattern is not a dependent type. This does mean that we can have canonical types that are pack expansions that contain no unexpanded packs, which is unfortunate but not inaccurate. We also previously did not treat a typedef type as instantiation-dependent if its canonical type was not instantiation-dependent. That's wrong because instantiation-dependence is a property of the type sugar, not of the type; an instantiation-dependent type can have a non-instantiation-dependent canonical type.
25 lines
834 B
C++
25 lines
834 B
C++
// RUN: %clang_cc1 -std=c++20 -verify %s
|
|
|
|
namespace PR46377 {
|
|
template<typename> using IntPtr = int*;
|
|
template<typename ...T> auto non_dependent_typedef() {
|
|
typedef int(*P)(IntPtr<T>...);
|
|
return P();
|
|
}
|
|
template<typename ...T> auto non_dependent_alias() {
|
|
using P = int(*)(IntPtr<T>...);
|
|
return P();
|
|
}
|
|
template<typename ...T> auto non_dependent_via_sizeof() {
|
|
using P = int(*)(int(...pack)[sizeof(sizeof(T))]); // expected-error {{invalid application of 'sizeof'}}
|
|
return P();
|
|
}
|
|
|
|
using a = int (*)(int*, int*);
|
|
using a = decltype(non_dependent_typedef<void, void>());
|
|
using a = decltype(non_dependent_alias<void, void>());
|
|
using a = decltype(non_dependent_via_sizeof<float, float>());
|
|
|
|
using b = decltype(non_dependent_via_sizeof<float, void>()); // expected-note {{instantiation of}}
|
|
}
|