[gcc/devel/ranger] c++: Adjust formatting.

Aldy Hernandez aldyh@gcc.gnu.org
Wed Jun 17 20:05:41 GMT 2020


https://gcc.gnu.org/g:595f1b1274b1cb86c74c72b9cc297e6981fe4549

commit 595f1b1274b1cb86c74c72b9cc297e6981fe4549
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Mar 31 17:34:59 2020 -0400

    c++: Adjust formatting.
    
    This patch has no semantic effect; committing it separately makes the change
    for 94205 easier to read.
    
    gcc/cp/ChangeLog
    2020-03-31  Jason Merrill  <jason@redhat.com>
    
            * constexpr.c (cxx_eval_constant_expression) [TARGET_EXPR]: Use
            local variables.

Diff:
---
 gcc/cp/ChangeLog   |   5 +++
 gcc/cp/constexpr.c | 104 ++++++++++++++++++++++++++++-------------------------
 2 files changed, 60 insertions(+), 49 deletions(-)

diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index cc79ece1689..2814a866f5d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2020-03-31  Jason Merrill  <jason@redhat.com>
+
+	* constexpr.c (cxx_eval_constant_expression) [TARGET_EXPR]: Use
+	local variables.
+
 2020-03-30  Jason Merrill  <jason@redhat.com>
 
 	PR c++/90711
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 2f9377229ef..e85b3c113f0 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -5525,56 +5525,62 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
       break;
 
     case TARGET_EXPR:
-      if (!literal_type_p (TREE_TYPE (t)))
-	{
-	  if (!ctx->quiet)
-	    {
-	      auto_diagnostic_group d;
-	      error ("temporary of non-literal type %qT in a "
-		     "constant expression", TREE_TYPE (t));
-	      explain_non_literal_class (TREE_TYPE (t));
-	    }
-	  *non_constant_p = true;
-	  break;
-	}
-      gcc_checking_assert (!TARGET_EXPR_DIRECT_INIT_P (t));
-      /* Avoid evaluating a TARGET_EXPR more than once.  */
-      if (tree *p = ctx->global->values.get (TARGET_EXPR_SLOT (t)))
-	{
-	  if (lval)
-	    return TARGET_EXPR_SLOT (t);
-	  r = *p;
+      {
+	tree type = TREE_TYPE (t);
+
+	if (!literal_type_p (type))
+	  {
+	    if (!ctx->quiet)
+	      {
+		auto_diagnostic_group d;
+		error ("temporary of non-literal type %qT in a "
+		       "constant expression", type);
+		explain_non_literal_class (type);
+	      }
+	    *non_constant_p = true;
+	    break;
+	  }
+	gcc_checking_assert (!TARGET_EXPR_DIRECT_INIT_P (t));
+	/* Avoid evaluating a TARGET_EXPR more than once.  */
+	tree slot = TARGET_EXPR_SLOT (t);
+	if (tree *p = ctx->global->values.get (slot))
+	  {
+	    if (lval)
+	      return slot;
+	    r = *p;
+	    break;
+	  }
+	tree init = TARGET_EXPR_INITIAL (t);
+	if ((AGGREGATE_TYPE_P (type) || VECTOR_TYPE_P (type)))
+	  {
+	    /* We're being expanded without an explicit target, so start
+	       initializing a new object; expansion with an explicit target
+	       strips the TARGET_EXPR before we get here.  */
+	    new_ctx = *ctx;
+	    new_ctx.ctor = build_constructor (type, NULL);
+	    CONSTRUCTOR_NO_CLEARING (new_ctx.ctor) = true;
+	    new_ctx.object = slot;
+	    ctx->global->values.put (new_ctx.object, new_ctx.ctor);
+	    ctx = &new_ctx;
+	  }
+	/* Pass false for 'lval' because this indicates
+	   initialization of a temporary.  */
+	r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 1),
+					  false,
+					  non_constant_p, overflow_p);
+	if (*non_constant_p)
 	  break;
-	}
-      if ((AGGREGATE_TYPE_P (TREE_TYPE (t)) || VECTOR_TYPE_P (TREE_TYPE (t))))
-	{
-	  /* We're being expanded without an explicit target, so start
-	     initializing a new object; expansion with an explicit target
-	     strips the TARGET_EXPR before we get here.  */
-	  new_ctx = *ctx;
-	  new_ctx.ctor = build_constructor (TREE_TYPE (t), NULL);
-	  CONSTRUCTOR_NO_CLEARING (new_ctx.ctor) = true;
-	  new_ctx.object = TARGET_EXPR_SLOT (t);
-	  ctx->global->values.put (new_ctx.object, new_ctx.ctor);
-	  ctx = &new_ctx;
-	}
-      /* Pass false for 'lval' because this indicates
-	 initialization of a temporary.  */
-      r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 1),
-					false,
-					non_constant_p, overflow_p);
-      if (*non_constant_p)
-	break;
-      /* Adjust the type of the result to the type of the temporary.  */
-      r = adjust_temp_type (TREE_TYPE (t), r);
-      if (TARGET_EXPR_CLEANUP (t) && !CLEANUP_EH_ONLY (t))
-	ctx->global->cleanups->safe_push (TARGET_EXPR_CLEANUP (t));
-      r = unshare_constructor (r);
-      ctx->global->values.put (TARGET_EXPR_SLOT (t), r);
-      if (ctx->save_exprs)
-	ctx->save_exprs->safe_push (TARGET_EXPR_SLOT (t));
-      if (lval)
-	return TARGET_EXPR_SLOT (t);
+	/* Adjust the type of the result to the type of the temporary.  */
+	r = adjust_temp_type (type, r);
+	if (TARGET_EXPR_CLEANUP (t) && !CLEANUP_EH_ONLY (t))
+	  ctx->global->cleanups->safe_push (TARGET_EXPR_CLEANUP (t));
+	r = unshare_constructor (r);
+	ctx->global->values.put (slot, r);
+	if (ctx->save_exprs)
+	  ctx->save_exprs->safe_push (slot);
+	if (lval)
+	  return slot;
+      }
       break;
 
     case INIT_EXPR:


More information about the Gcc-cvs mailing list