This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ PATCH for c++/91521 - wrong error with operator->


On 8/23/19 1:37 PM, Marek Polacek wrote:
Since r263836 we enter the "a late-specified return type" block in
grokdeclarator when inner_declarator is null:

         /* Handle a late-specified return type.  */
         tree late_return_type = declarator->u.function.late_return_type;
-       if (funcdecl_p)
+       if (funcdecl_p
+       /* This is the case e.g. for
+          using T = auto () -> int.  */
+       || inner_declarator == NULL)
           {

inner_declarator is null in this testcase too, but here we don't have
a real trailing return type; it's just an overloaded operator ->.  That
means that late_return_type is non-null, but is error_mark_node.  In
that case I think it's not sensible to complain about "trailing return
type only available" or "function with trailing return type not declared
with auto".  In this case that made us reject valid code.

Bootstrapped/regtested on x86_64-linux, ok for trunk and 9?

2019-08-23  Marek Polacek  <polacek@redhat.com>

	PR c++/91521 - wrong error with operator->.
	* decl.c (grokdeclarator): Don't consider error_mark_node a valid
	trailing return type.

	* g++.dg/parse/operator8.C: New test.

diff --git gcc/cp/decl.c gcc/cp/decl.c
index 88aa69ce5de..ea5752a249e 100644
--- gcc/cp/decl.c
+++ gcc/cp/decl.c
@@ -11546,6 +11546,7 @@ grokdeclarator (const cp_declarator *declarator,
  		      }
  		  }
  		else if (late_return_type
+			 && late_return_type != error_mark_node
  			 && sfk != sfk_conversion)
  		  {

What if instead of this change we check for error_mark_node inside the block and return without an error?

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]