|
@@ -586,25 +586,30 @@ namespace PR25627_dont_odr_use_local_consts {
|
|
|
|
|
|
namespace ConversionOperatorDoesNotHaveDeducedReturnType {
|
|
namespace ConversionOperatorDoesNotHaveDeducedReturnType {
|
|
auto x = [](int){};
|
|
auto x = [](int){};
|
|
- auto y = [](auto) -> void {};
|
|
|
|
|
|
+ auto y = [](auto &v) -> void { v.n = 0; };
|
|
using T = decltype(x);
|
|
using T = decltype(x);
|
|
using U = decltype(y);
|
|
using U = decltype(y);
|
|
using ExpectedTypeT = void (*)(int);
|
|
using ExpectedTypeT = void (*)(int);
|
|
template<typename T>
|
|
template<typename T>
|
|
- using ExpectedTypeU = void (*)(T);
|
|
|
|
|
|
+ using ExpectedTypeU = void (*)(T&);
|
|
|
|
|
|
struct X {
|
|
struct X {
|
|
|
|
+ friend auto T::operator()(int) const;
|
|
friend T::operator ExpectedTypeT() const;
|
|
friend T::operator ExpectedTypeT() const;
|
|
|
|
|
|
- // Formally, this is invalid, because the return type of the conversion
|
|
|
|
- // function for a generic lambda expression is an unspecified decltype
|
|
|
|
- // type, which this should not match. However, this declaration is
|
|
|
|
- // functionally equivalent to that one, so we're permitted to choose to
|
|
|
|
- // accept this.
|
|
|
|
|
|
+ // FIXME: The first of these should match. The second should not.
|
|
template<typename T>
|
|
template<typename T>
|
|
- friend U::operator ExpectedTypeU<T>() const;
|
|
|
|
|
|
+ friend void U::operator()(T&) const; // expected-error {{does not match}}
|
|
|
|
+ template<typename T>
|
|
|
|
+ friend U::operator ExpectedTypeU<T>() const; // expected-error {{does not match}}
|
|
|
|
+
|
|
|
|
+ private:
|
|
|
|
+ int n;
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ // Should be OK: lambda's call operator is a friend.
|
|
|
|
+ void use(X &x) { y(x); }
|
|
|
|
+
|
|
// This used to crash in return type deduction for the conversion opreator.
|
|
// This used to crash in return type deduction for the conversion opreator.
|
|
struct A { int n; void f() { +[](decltype(n)) {}; } };
|
|
struct A { int n; void f() { +[](decltype(n)) {}; } };
|
|
}
|
|
}
|