diff mbox

[Ping] Re: [C++ Patch] Tidy a bit cp_parser_lookup_name

Message ID 52610893.8020505@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Oct. 18, 2013, 10:08 a.m. UTC
Hi

On 10/13/2013 08:26 PM, Paolo Carlini wrote:
> Hi,
>
> today I noticed that in cp_parser_lookup_name the code in the 
> object_type != NULL_TREE else can be tidied a bit and a 
> lookup_name_real often avoided. Tested x86_64-linux.
Can I apply this clean-up? It seems pretty straightforward to me, 
essentially matter of logic, and saves a redundant name lookup. I'm also 
attaching a variant which avoids early initializing the decl local and 
shaves about 120 bytes out the release cc1plus compared to the first 
version.

Thanks!
Paolo.

//////////////////////

Comments

Jason Merrill Oct. 18, 2013, 1:57 p.m. UTC | #1
OK.  I thought I had already approved this, but apparently not.

Jason
Paolo Carlini Oct. 18, 2013, 2:41 p.m. UTC | #2
On 10/18/2013 03:57 PM, Jason Merrill wrote:
> OK. I thought I had already approved this, but apparently not.
Thanks, applied.

Can I also ask you to follow up to this exchange which remained hanging?

     http://gcc.gnu.org/ml/gcc-patches/2013-10/msg00827.html

Thanks in advance!
Paolo.
diff mbox

Patch

Index: parser.c
===================================================================
--- parser.c	(revision 203517)
+++ parser.c	(working copy)
@@ -21875,7 +21875,6 @@  cp_parser_lookup_name (cp_parser *parser, tree nam
     }
   else if (object_type)
     {
-      tree object_decl = NULL_TREE;
       /* Look up the name in the scope of the OBJECT_TYPE, unless the
 	 OBJECT_TYPE is not a class.  */
       if (CLASS_TYPE_P (object_type))
@@ -21883,19 +21882,21 @@  cp_parser_lookup_name (cp_parser *parser, tree nam
 	   be instantiated during name lookup.  In that case, errors
 	   may be issued.  Even if we rollback the current tentative
 	   parse, those errors are valid.  */
-	object_decl = lookup_member (object_type,
-				     name,
-				     /*protect=*/0,
-				     tag_type != none_type,
-				     tf_warning_or_error);
-      /* Look it up in the enclosing context, too.  */
-      decl = lookup_name_real (name, tag_type != none_type,
-			       /*nonclass=*/0,
-			       /*block_p=*/true, is_namespace, 0);
+	decl = lookup_member (object_type,
+			      name,
+			      /*protect=*/0,
+			      tag_type != none_type,
+			      tf_warning_or_error);
+      else
+	decl = NULL_TREE;
+
+      if (!decl)
+	/* Look it up in the enclosing context.  */
+	decl = lookup_name_real (name, tag_type != none_type,
+				 /*nonclass=*/0,
+				 /*block_p=*/true, is_namespace, 0);
       parser->object_scope = object_type;
       parser->qualifying_scope = NULL_TREE;
-      if (object_decl)
-	decl = object_decl;
     }
   else
     {