Patchwork C++ PATCH for c++/57391 (bootstrap fail on AIX)

login
register
mail settings
Submitter Jason Merrill
Date May 24, 2013, 2:16 p.m.
Message ID <519F7622.1050509@redhat.com>
Download mbox | patch
Permalink /patch/246163/
State New
Headers show

Comments

Jason Merrill - May 24, 2013, 2:16 p.m.
When FMA_EXPR was added to potential_constant_expression_1, it wasn't 
added to cxx_eval_constant_expression at the same time...

Regression tested x86_64-pc-linux-gnu, applying to trunk.  David, can 
you verify that this fixes bootstrap on AIX?
Paolo Carlini - May 24, 2013, 2:52 p.m.
On 05/24/2013 04:16 PM, Jason Merrill wrote:
> When FMA_EXPR was added to potential_constant_expression_1, it wasn't 
> added to cxx_eval_constant_expression at the same time...
Sorry.

Paolo.
David Edelsohn - May 24, 2013, 4:11 p.m.
On Fri, May 24, 2013 at 10:16 AM, Jason Merrill <jason@redhat.com> wrote:
> When FMA_EXPR was added to potential_constant_expression_1, it wasn't added
> to cxx_eval_constant_expression at the same time...
>
> Regression tested x86_64-pc-linux-gnu, applying to trunk.  David, can you
> verify that this fixes bootstrap on AIX?

With the patch applied, I am able to progress past the point of the
previous ICE.

Thanks, David

Patch

commit a78fee4d0a9c2a353637f239c6ac189227248491
Author: Jason Merrill <jason@redhat.com>
Date:   Fri May 24 09:52:10 2013 -0400

    	PR c++/57391
    	* semantics.c (cxx_eval_constant_expression): Handle FMA_EXPR.
    	(cxx_eval_trinary_expression): Rename from cxx_eval_vec_perm_expr.

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index c115d23..c1385c1 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -7776,37 +7776,32 @@  non_const_var_error (tree r)
     }
 }
 
-/* Evaluate VEC_PERM_EXPR (v1, v2, mask).  */
+/* Subroutine of cxx_eval_constant_expression.
+   Like cxx_eval_unary_expression, except for trinary expressions.  */
+
 static tree
-cxx_eval_vec_perm_expr (const constexpr_call *call, tree t, 
-			bool allow_non_constant, bool addr,
-			bool *non_constant_p, bool *overflow_p)
+cxx_eval_trinary_expression (const constexpr_call *call, tree t,
+			     bool allow_non_constant, bool addr,
+			     bool *non_constant_p, bool *overflow_p)
 {
   int i;
   tree args[3];
   tree val;
-  tree elttype = TREE_TYPE (t);
 
   for (i = 0; i < 3; i++)
     {
       args[i] = cxx_eval_constant_expression (call, TREE_OPERAND (t, i),
 					      allow_non_constant, addr,
 					      non_constant_p, overflow_p);
-      if (*non_constant_p)
-      	goto fail;
+      VERIFY_CONSTANT (args[i]);
     }
 
-  gcc_assert (TREE_CODE (TREE_TYPE (args[0])) == VECTOR_TYPE);
-  gcc_assert (TREE_CODE (TREE_TYPE (args[1])) == VECTOR_TYPE);
-  gcc_assert (TREE_CODE (TREE_TYPE (args[2])) == VECTOR_TYPE);
-
-  val = fold_ternary_loc (EXPR_LOCATION (t), VEC_PERM_EXPR, elttype, 
+  val = fold_ternary_loc (EXPR_LOCATION (t), TREE_CODE (t), TREE_TYPE (t),
 			  args[0], args[1], args[2]);
-  if (val != NULL_TREE)
-    return val;
-
- fail:
-  return t;
+  if (val == NULL_TREE)
+    return t;
+  VERIFY_CONSTANT (val);
+  return val;
 }
 
 /* Attempt to reduce the expression T to a constant value.
@@ -8106,9 +8101,10 @@  cxx_eval_constant_expression (const constexpr_call *call, tree t,
 			     non_constant_p, overflow_p);
       break;
 
+    case FMA_EXPR:
     case VEC_PERM_EXPR:
-      r = cxx_eval_vec_perm_expr (call, t, allow_non_constant, addr,
-				  non_constant_p, overflow_p);
+      r = cxx_eval_trinary_expression (call, t, allow_non_constant, addr,
+				       non_constant_p, overflow_p);
       break;
 
     case CONVERT_EXPR: