From: Marek Polacek Date: Fri, 23 Aug 2019 23:24:46 +0000 (+0000) Subject: PR c++/91521 - wrong error with operator->. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9bf6c63da9ff140bb37d957ad1252848e2df28ef;p=gcc.git PR c++/91521 - wrong error with operator->. * decl.c (grokdeclarator): Return error_mark_node for an invalid trailing return type. * g++.dg/parse/operator8.C: New test. From-SVN: r274891 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5a59f984af0..8eebf894f45 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2019-08-23 Marek Polacek + PR c++/91521 - wrong error with operator->. + * decl.c (grokdeclarator): Return error_mark_node for an invalid + trailing return type. + PR c++/79817 - attribute deprecated on namespace. * cp-tree.h (cp_warn_deprecated_use_scopes): Declare. * decl.c (grokdeclarator): Call cp_warn_deprecated_use_scopes. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index cb5571e4f24..9f7923871db 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -11549,6 +11549,8 @@ grokdeclarator (const cp_declarator *declarator, 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. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f657cfa1a63..2162fcf40f4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-08-23 Marek Polacek + + PR c++/91521 - wrong error with operator->. + * g++.dg/parse/operator8.C: New test. + 2019-08-23 Segher Boessenkool PR target/91481 diff --git a/gcc/testsuite/g++.dg/parse/operator8.C b/gcc/testsuite/g++.dg/parse/operator8.C new file mode 100644 index 00000000000..c5ee3eb934a --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/operator8.C @@ -0,0 +1,13 @@ +// 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; +}