We've had a diagnostic for this, but since r10-6571 added an assert to
splice_late_return_type, we need to diagnose before we call it.
PR c++/101051
gcc/cp/ChangeLog:
* decl.cc (grokdeclarator): Reject conversion with trailing return
sooner.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/trailing15.C: New test.
"type specifier", name);
return error_mark_node;
}
+ if (late_return_type && sfk == sfk_conversion)
+ {
+ error ("a conversion function cannot have a trailing return type");
+ return error_mark_node;
+ }
type = splice_late_return_type (type, late_return_type);
if (type == error_mark_node)
return error_mark_node;
maybe_warn_cpp0x (CPP0X_EXPLICIT_CONVERSION);
explicitp = 2;
}
- if (late_return_type_p)
- error ("a conversion function cannot have a trailing return type");
}
else if (sfk == sfk_deduction_guide)
{
--- /dev/null
+// PR c++/101051
+// { dg-do compile { target c++11 } }
+
+template <class T>
+class Foo
+{
+ constexpr operator T() -> T {} // { dg-error "trailing return" }
+};
+
+struct S {
+ operator int() const -> double; // { dg-error "trailing return" }
+};
+
+class A { operator auto*() -> int; }; // { dg-error "auto|trailing return" }