public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++] code cleanup
@ 2016-05-20 21:01 Nathan Sidwell
  0 siblings, 0 replies; only message in thread
From: Nathan Sidwell @ 2016-05-20 21:01 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 283 bytes --]

When working on the constexpr machinery for gcc 6, I noticed a couple of cleanup 
opportunities.

1) cxx_bind_parameters_in_call contains 'if (cond) goto x; ... x:;', which can 
easily be rewritten to 'if (!cond) { ...}'

2) a which vs that grammar error.

applied to trunk.

nathan

[-- Attachment #2: cexpr.patch --]
[-- Type: text/x-patch, Size: 1676 bytes --]

2016-05-20  Nathan Sidwell  <nathan@acm.org>

	* constexpr.c (cxx_bind_parameters_in_call): Avoid gratuitous if
	... goto.
	(cxx_eval_call_expression): Fix comment grammar.

Index: cp/constexpr.c
===================================================================
--- cp/constexpr.c	(revision 236510)
+++ cp/constexpr.c	(working copy)
@@ -1201,18 +1201,18 @@ cxx_bind_parameters_in_call (const const
       /* Just discard ellipsis args after checking their constantitude.  */
       if (!parms)
 	continue;
-      if (*non_constant_p)
-	/* Don't try to adjust the type of non-constant args.  */
-	goto next;
-
-      /* Make sure the binding has the same type as the parm.  */
-      if (TREE_CODE (type) != REFERENCE_TYPE)
-	arg = adjust_temp_type (type, arg);
-      if (!TREE_CONSTANT (arg))
-	*non_constant_args = true;
-      *p = build_tree_list (parms, arg);
-      p = &TREE_CHAIN (*p);
-    next:
+
+      if (!*non_constant_p)
+	{
+	  /* Make sure the binding has the same type as the parm.  But
+	     only for constant args.  */
+	  if (TREE_CODE (type) != REFERENCE_TYPE)
+	    arg = adjust_temp_type (type, arg);
+	  if (!TREE_CONSTANT (arg))
+	    *non_constant_args = true;
+	  *p = build_tree_list (parms, arg);
+	  p = &TREE_CHAIN (*p);
+	}
       parms = TREE_CHAIN (parms);
     }
 }
@@ -1420,7 +1420,7 @@ cxx_eval_call_expression (const constexp
 	  *slot = entry = ggc_alloc<constexpr_call> ();
 	  *entry = new_call;
 	}
-      /* Calls which are in progress have their result set to NULL
+      /* Calls that are in progress have their result set to NULL,
 	 so that we can detect circular dependencies.  */
       else if (entry->result == NULL)
 	{

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-05-20 21:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-20 21:01 [C++] code cleanup Nathan Sidwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).