Patchwork C++ PATCH for c++/56447 (wrong lambda conversion op in templates)

login
register
mail settings
Submitter Jason Merrill
Date March 16, 2013, 7:25 p.m.
Message ID <5144C73A.2050300@redhat.com>
Download mbox | patch
Permalink /patch/228242/
State New
Headers show

Comments

Jason Merrill - March 16, 2013, 7:25 p.m.
And let's use nreverse in the parser rather than open-coding it.

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

Patch

commit 5abab0d6bc5ccdea38af62f2563a1c0d9dda27d3
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Feb 15 12:04:47 2013 -0500

    	* parser.c (cp_parser_lambda_expression): Use nreverse.

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index b45daae..8e0c964 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -8195,19 +8195,8 @@  cp_parser_lambda_expression (cp_parser* parser)
       cp_parser_skip_to_end_of_block_or_statement (parser);
 
     /* The capture list was built up in reverse order; fix that now.  */
-    {
-      tree newlist = NULL_TREE;
-      tree elt, next;
-
-      for (elt = LAMBDA_EXPR_CAPTURE_LIST (lambda_expr);
-	   elt; elt = next)
-	{
-	  next = TREE_CHAIN (elt);
-	  TREE_CHAIN (elt) = newlist;
-	  newlist = elt;
-	}
-      LAMBDA_EXPR_CAPTURE_LIST (lambda_expr) = newlist;
-    }
+    LAMBDA_EXPR_CAPTURE_LIST (lambda_expr)
+      = nreverse (LAMBDA_EXPR_CAPTURE_LIST (lambda_expr));
 
     if (ok)
       maybe_add_lambda_conv_op (type);