* decl.c (grokdeclarator): Return error_mark_node for an invalid
trailing return type.
* g++.dg/parse/operator8.C: New test.
From-SVN: r274892
+2019-08-23 Marek Polacek <polacek@redhat.com>
+
+ Backported from mainline
+ 2019-08-23 Marek Polacek <polacek@redhat.com>
+
+ PR c++/91521 - wrong error with operator->.
+ * decl.c (grokdeclarator): Return error_mark_node for an invalid
+ trailing return type.
+
2019-08-16 Jason Merrill <jason@redhat.com>
PR c++/90393 - ICE with throw in ?:
else if (late_return_type
&& sfk != sfk_conversion)
{
+ if (late_return_type == error_mark_node)
+ return error_mark_node;
if (cxx_dialect < cxx11)
/* Not using maybe_warn_cpp0x because this should
always be an error. */
--- /dev/null
+// PR c++/91521 - wrong error with operator->.
+// { dg-do compile }
+
+struct foo {
+ int bar() { return 0; }
+ foo* operator->() { return this; }
+};
+
+int main()
+{
+ int pt(foo()->bar());
+ return pt;
+}