The following fixes a pasto in cp_build_binary_op.  Will apply
as obvious after it passes bootstrap/testing on x86_64-unknown-linux-gnu.

Richard.

2016-03-30  Richard Biener  <rguent...@suse.de>

        PR c++/70430
        * typeck.c (cp_build_binary_op): Fix operand order of vector
        conditional in truth op handling.

        * g++.dg/ext/vector30.C: New testcase.

Index: gcc/cp/typeck.c
===================================================================
*** gcc/cp/typeck.c     (revision 234546)
--- gcc/cp/typeck.c     (working copy)
*************** cp_build_binary_op (location_t location,
*** 4364,4370 ****
            {
              tree m1 = build_all_ones_cst (TREE_TYPE (op0));
              tree z = build_zero_cst (TREE_TYPE (op0));
!             op1 = build_conditional_expr (location, op1, z, m1, complain);
            }
          else if (!COMPARISON_CLASS_P (op1))
            op1 = cp_build_binary_op (EXPR_LOCATION (op1), NE_EXPR, op1,
--- 4364,4370 ----
            {
              tree m1 = build_all_ones_cst (TREE_TYPE (op0));
              tree z = build_zero_cst (TREE_TYPE (op0));
!             op1 = build_conditional_expr (location, op1, m1, z, complain);
            }
          else if (!COMPARISON_CLASS_P (op1))
            op1 = cp_build_binary_op (EXPR_LOCATION (op1), NE_EXPR, op1,
Index: gcc/testsuite/g++.dg/ext/vector30.C
===================================================================
*** gcc/testsuite/g++.dg/ext/vector30.C (revision 0)
--- gcc/testsuite/g++.dg/ext/vector30.C (working copy)
***************
*** 0 ****
--- 1,15 ----
+ // PR c++/70430
+ // { dg-do run }
+ extern "C" void abort (void);
+ typedef int v4si __attribute__ ((vector_size (16)));
+ int main()
+ {
+   v4si b = {1,0,-1,2}, c;
+   c = b && 1;
+   if (c[0] != -1 || c[1] != 0 || c[2] != -1 || c[3] != -1)
+     abort ();
+   c = b && 0;
+   if (c[0] != 0 || c[1] != 0 || c[2] != 0 || c[3] != 0)
+     abort ();
+   return 0;
+ }

Reply via email to