OSDN Git Service

* tracer.c (rest_of_handle_tracer): We already cleaned
[pf3gnuchains/gcc-fork.git] / gcc / c-common.c
index 8fb9541..4b1718c 100644 (file)
@@ -254,6 +254,10 @@ int flag_short_double;
 
 int flag_short_wchar;
 
+/* Nonzero means allow implicit conversions between vectors with
+   differing numbers of subparts and/or differing element types.  */
+int flag_lax_vector_conversions;
+
 /* Nonzero means allow Microsoft extensions without warnings or errors.  */
 int flag_ms_extensions;
 
@@ -914,7 +918,7 @@ constant_expression_warning (tree value)
   if ((TREE_CODE (value) == INTEGER_CST || TREE_CODE (value) == REAL_CST
        || TREE_CODE (value) == VECTOR_CST
        || TREE_CODE (value) == COMPLEX_CST)
-      && TREE_CONSTANT_OVERFLOW (value)
+      && TREE_OVERFLOW (value)
       && warn_overflow
       && pedantic)
     pedwarn ("overflow in constant expression");
@@ -1078,19 +1082,44 @@ check_main_parameter_types (tree decl)
    pedwarn ("%q+D takes only zero or two arguments", decl);
 }
 
-/* Nonzero if vector types T1 and T2 can be converted to each other
-   without an explicit cast.  */
-int
-vector_types_convertible_p (tree t1, tree t2)
+/* True if vector types T1 and T2 can be converted to each other
+   without an explicit cast.  If EMIT_LAX_NOTE is true, and T1 and T2
+   can only be converted with -flax-vector-conversions yet that is not
+   in effect, emit a note telling the user about that option if such
+   a note has not previously been emitted.  */
+bool
+vector_types_convertible_p (tree t1, tree t2, bool emit_lax_note)
 {
-  return targetm.vector_opaque_p (t1)
-        || targetm.vector_opaque_p (t2)
-        || (tree_int_cst_equal (TYPE_SIZE (t1), TYPE_SIZE (t2))
-            && (TREE_CODE (TREE_TYPE (t1)) != REAL_TYPE ||
-                TYPE_PRECISION (t1) == TYPE_PRECISION (t2))
-            && INTEGRAL_TYPE_P (TREE_TYPE (t1))
-               == INTEGRAL_TYPE_P (TREE_TYPE (t2)));
+  static bool emitted_lax_note = false;
+  bool convertible_lax;
+
+  if ((targetm.vector_opaque_p (t1) || targetm.vector_opaque_p (t2))
+      && tree_int_cst_equal (TYPE_SIZE (t1), TYPE_SIZE (t2)))
+    return true;
+
+  convertible_lax =
+    (tree_int_cst_equal (TYPE_SIZE (t1), TYPE_SIZE (t2))
+     && (TREE_CODE (TREE_TYPE (t1)) != REAL_TYPE ||
+        TYPE_PRECISION (t1) == TYPE_PRECISION (t2))
+     && (INTEGRAL_TYPE_P (TREE_TYPE (t1))
+        == INTEGRAL_TYPE_P (TREE_TYPE (t2))));
+
+  if (!convertible_lax || flag_lax_vector_conversions)
+    return convertible_lax;
+
+  if (TYPE_VECTOR_SUBPARTS (t1) == TYPE_VECTOR_SUBPARTS (t2)
+      && comptypes (TREE_TYPE (t1), TREE_TYPE (t2)))
+    return true;
+
+  if (emit_lax_note && !emitted_lax_note)
+    {
+      emitted_lax_note = true;
+      inform ("use -flax-vector-conversions to permit "
+              "conversions between vectors with differing "
+              "element types or numbers of subparts");
+    }
+
+  return false;
 }
 
 /* Warns if the conversion of EXPR to TYPE may alter a value.
@@ -1228,11 +1257,8 @@ convert_and_check (tree type, tree expr)
       /* Do not diagnose overflow in a constant expression merely
          because a conversion overflowed.  */
       if (TREE_OVERFLOW (result))
-        {
-          TREE_CONSTANT_OVERFLOW (result) = TREE_CONSTANT_OVERFLOW (expr);
-          TREE_OVERFLOW (result) = TREE_OVERFLOW (expr);
-        }
-      
+        TREE_OVERFLOW (result) = TREE_OVERFLOW (expr);
+
       if (TYPE_UNSIGNED (type))
         {
           /* This detects cases like converting -129 or 256 to
@@ -2291,12 +2317,10 @@ shorten_compare (tree *op0_ptr, tree *op1_ptr, tree *restype_ptr,
        {
          /* Convert primop1 to target type, but do not introduce
             additional overflow.  We know primop1 is an int_cst.  */
-         tree tmp = build_int_cst_wide (*restype_ptr,
-                                        TREE_INT_CST_LOW (primop1),
-                                        TREE_INT_CST_HIGH (primop1));
-
-         primop1 = force_fit_type (tmp, 0, TREE_OVERFLOW (primop1),
-                                   TREE_CONSTANT_OVERFLOW (primop1));
+         primop1 = force_fit_type_double (*restype_ptr,
+                                          TREE_INT_CST_LOW (primop1),
+                                          TREE_INT_CST_HIGH (primop1), 0,
+                                          TREE_OVERFLOW (primop1));
        }
       if (type != *restype_ptr)
        {
@@ -2657,10 +2681,8 @@ c_common_truthvalue_conversion (tree expr)
       return expr;
 
     case INTEGER_CST:
-      /* Avoid integer_zerop to ignore TREE_CONSTANT_OVERFLOW.  */
-      return (TREE_INT_CST_LOW (expr) != 0 || TREE_INT_CST_HIGH (expr) != 0)
-            ? truthvalue_true_node
-            : truthvalue_false_node;
+      return integer_zerop (expr) ? truthvalue_false_node
+                                 : truthvalue_true_node;
 
     case REAL_CST:
       return real_compare (NE_EXPR, &TREE_REAL_CST (expr), &dconst0)