Haojian Wu 2b386888b7 Reland: [clang] Use getDefaultArgRange instead of getDefaultArg to retrieve
source location in `ConvertConstructorToDeductionGuideTransform`.

The commit fec471649fffaa3ec44e17801e5c9605825e58bb was reverted by accident in 7415524b45392651969374c067041daa82dc89e7.

Reland it with a testcase.
2024-05-11 22:07:21 +02:00

72 lines
1.5 KiB
C++

// RUN: %clang_cc1 -std=c++17 -verify %s
namespace pr41427 {
template <typename T> class A {
public:
A(void (*)(T)) {}
};
void D(int) {}
void f() {
A a(&D);
using T = decltype(a);
using T = A<int>;
}
}
namespace Access {
struct B {
protected:
struct type {};
};
template<typename T> struct D : B { // expected-note {{not viable}}
D(T, typename T::type); // expected-note {{private member}}
};
D b = {B(), {}};
class X {
using type = int;
};
D x = {X(), {}}; // expected-error {{no viable constructor or deduction guide}}
// Once we implement proper support for dependent nested name specifiers in
// friends, this should still work.
class Y {
template <typename T> friend D<T>::D(T, typename T::type); // expected-warning {{dependent nested name specifier}}
struct type {};
};
D y = {Y(), {}};
class Z {
template <typename T> friend class D;
struct type {};
};
D z = {Z(), {}};
}
namespace GH69987 {
template<class> struct X {};
template<class = void> struct X;
X x;
template<class T, class B> struct Y { Y(T); };
template<class T, class B=void> struct Y ;
Y y(1);
}
namespace NoCrashOnGettingDefaultArgLoc {
template <typename>
class A {
A(int = 1); // expected-note {{candidate template ignored: couldn't infer template argumen}}
};
class C : A<int> {
using A::A;
};
template <typename>
class D : C { // expected-note {{candidate function template not viable: requires 1 argument}}
using C::C;
};
D abc; // expected-error {{no viable constructor or deduction guide}}
}