avr currently shows the following failure:
FAIL: c-c++-common/vector-scalar.c  -Wc++-compat  (test for excess errors)
Excess errors:
/home/amylaar/atmel/4.8/unisrc-mainline/gcc/testsuite/c-c++-common/vector-scalar
.c:9:34: error: invalid operands to binary | (have '__vector(8) int' and 'veci')

The issue is that when we compute the result of an operatiopn of a veci and an
int, we get a __vector(8) int result (int is the same size as short),
yet the typechecking later does not accept the vectors as compatible.
Fixed by relaxing the latter for the case that int and short are the same size.

bootstrapped / regtested on i686-pc-linux-gnu.

OK to apply?
2013-07-17  Joern Rennecke  <joern.renne...@embecosm.com>

        * c-common.c (same_scalar_type_ignoring_signedness): Also
        accept short/int as equivalent if they have the same precision.

Index: c-family/c-common.c
===================================================================
--- c-family/c-common.c (revision 201992)
+++ c-family/c-common.c (working copy)
@@ -10700,10 +10700,22 @@ same_scalar_type_ignoring_signedness (tr
              && (c2 == INTEGER_TYPE || c2 == REAL_TYPE
                  || c2 == FIXED_POINT_TYPE));
 
+  t1 = c_common_signed_type (t1);
+  t2 = c_common_signed_type (t2);
   /* Equality works here because c_common_signed_type uses
      TYPE_MAIN_VARIANT.  */
-  return c_common_signed_type (t1)
-    == c_common_signed_type (t2);
+  if (t1 == t2)
+    return true;
+  if (TYPE_PRECISION (t1) != TYPE_PRECISION (t2))
+    return false;
+  /* When short and int are the same size, we promote vectors of short
+     to vectors of int when doing arithmetic with scalars.  Hence,
+     we also have to accept mixing short / int vectors in this case.
+     Example: c-c++-common/vector-scalar.c for target avr.  */
+  if ((t1 == integer_type_node && t2 == short_integer_type_node)
+      || (t2 == integer_type_node && t1 == short_integer_type_node))
+    return true;
+  return false;
 }
 
 /* Check for missing format attributes on function pointers.  LTYPE is

Reply via email to