]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/c-family/c-format.c
Merge in trunk.
[thirdparty/gcc.git] / gcc / c-family / c-format.c
index f0371d3cb6ec200d139c498eb155cf8718bcbf55..0ba9085bcd10425e2459db14f06a69edd39c57a0 100644 (file)
@@ -226,13 +226,13 @@ check_format_string (tree fntype, unsigned HOST_WIDE_INT format_num,
 static bool
 get_constant (tree expr, unsigned HOST_WIDE_INT *value, int validated_p)
 {
-  if (TREE_CODE (expr) != INTEGER_CST || TREE_INT_CST_HIGH (expr) != 0)
+  if (!cst_fits_uhwi_p (expr))
     {
       gcc_assert (!validated_p);
       return false;
     }
 
-  *value = TREE_INT_CST_LOW (expr);
+  *value = tree_to_hwi (expr);
 
   return true;
 }
@@ -1459,8 +1459,8 @@ check_format_arg (void *ctx, tree format_tree,
          res->number_non_literal++;
          return;
        }
-      if (!host_integerp (arg1, 0)
-         || (offset = tree_low_cst (arg1, 0)) < 0)
+      if (!tree_fits_shwi_p (arg1)
+         || (offset = tree_to_shwi (arg1)) < 0)
        {
          res->number_non_literal++;
          return;
@@ -1506,8 +1506,8 @@ check_format_arg (void *ctx, tree format_tree,
       return;
     }
   if (TREE_CODE (format_tree) == ARRAY_REF
-      && host_integerp (TREE_OPERAND (format_tree, 1), 0)
-      && (offset += tree_low_cst (TREE_OPERAND (format_tree, 1), 0)) >= 0)
+      && tree_fits_shwi_p (TREE_OPERAND (format_tree, 1))
+      && (offset += tree_to_shwi (TREE_OPERAND (format_tree, 1))) >= 0)
     format_tree = TREE_OPERAND (format_tree, 0);
   if (TREE_CODE (format_tree) == VAR_DECL
       && TREE_CODE (TREE_TYPE (format_tree)) == ARRAY_TYPE
@@ -1537,9 +1537,9 @@ check_format_arg (void *ctx, tree format_tree,
       /* Variable length arrays can't be initialized.  */
       gcc_assert (TREE_CODE (array_size) == INTEGER_CST);
 
-      if (host_integerp (array_size, 0))
+      if (tree_fits_shwi_p (array_size))
        {
-         HOST_WIDE_INT array_size_value = TREE_INT_CST_LOW (array_size);
+         HOST_WIDE_INT array_size_value = tree_to_shwi (array_size);
          if (array_size_value > 0
              && array_size_value == (int) array_size_value
              && format_length > array_size_value)