Patchwork Small C++ PATCH to grokdeclarator

login
register
mail settings
Submitter Jason Merrill
Date March 17, 2013, 3:12 a.m.
Message ID <514534B7.9000700@redhat.com>
Download mbox | patch
Permalink /patch/228270/
State New
Headers show

Comments

Jason Merrill - March 17, 2013, 3:12 a.m.
I wondered why grokdeclarator was handling the case of adding a 
ptr-operator to a METHOD_TYPE, since there's no way in C++ to name a 
METHOD_TYPE directly.  So I asserted that it can't happen, and nothing 
broke.

Tested x86_64-pc-linux-gnu, applying to trunk.

Patch

commit 852b32bc251b703a25ecd60e3c99ee5a69e642ab
Author: Jason Merrill <jason@redhat.com>
Date:   Sat Jan 26 22:36:35 2013 -0500

    	* decl.c (grokdeclarator): Assert that we won't see a pointer to
    	METHOD_TYPE.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index b67978d..facaae7 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -9630,9 +9630,11 @@  grokdeclarator (const cp_declarator *declarator,
 	     but to the target of the pointer.  */
 	  type_quals = TYPE_UNQUALIFIED;
 
+	  /* This code used to handle METHOD_TYPE, but I don't think it's
+	     possible to get it here anymore.  */
+	  gcc_assert (TREE_CODE (type) != METHOD_TYPE);
 	  if (declarator->kind == cdk_ptrmem
-	      && (TREE_CODE (type) == FUNCTION_TYPE
-		  || (memfn_quals && TREE_CODE (type) == METHOD_TYPE)))
+	      && TREE_CODE (type) == FUNCTION_TYPE)
 	    {
 	      memfn_quals |= type_memfn_quals (type);
 	      type = build_memfn_type (type,