]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree.h (tree_to_shwi): Add attribute nonnull and pure.
authorMartin Sebor <msebor@redhat.com>
Thu, 27 Sep 2018 22:55:23 +0000 (22:55 +0000)
committerMartin Sebor <msebor@gcc.gnu.org>
Thu, 27 Sep 2018 22:55:23 +0000 (16:55 -0600)
gcc/ChangeLog:

* tree.h (tree_to_shwi): Add attribute nonnull and pure.
(tree_to_poly_int64, tree_to_uhwi, tree_to_poly_uint64): Same.
(int_fits_type_p): Same.

gcc/ada/ChangeLog:

* gcc-interface/utils.c (make_packable_type): Introduce a temporary
to avoid -Wnonnull.
(unchecked_convert): Same.

From-SVN: r264680

gcc/ChangeLog
gcc/ada/ChangeLog
gcc/ada/gcc-interface/utils.c
gcc/tree.h

index f0b82bc6564744f09d939a51dce7ced33450d5e1..367c4c42737196147a0e06e45099d12411ad21bb 100644 (file)
@@ -1,3 +1,9 @@
+2018-09-27  Martin Sebor  <msebor@redhat.com>
+
+       * tree.h (tree_to_shwi): Add attribute nonnull and pure.
+       (tree_to_poly_int64, tree_to_uhwi, tree_to_poly_uint64): Same.
+       (int_fits_type_p): Same.
+
 2018-09-27  Uros Bizjak  <ubizjak@gmail.com>
 
        * config/i386/i386.md (FPCR_REG): Remove.
index a45e0b8bc4dd4f6f05ceeb47dcefc36abf40d5aa..ce20db3d0d0dcf35cb2de6e635a8378bc18210a3 100644 (file)
@@ -1,3 +1,9 @@
+2018-09-27  Martin Sebor  <msebor@redhat.com>
+
+       * gcc-interface/utils.c (make_packable_type): Introduce a temporary
+       to avoid -Wnonnull.
+       (unchecked_convert): Same.
+
 2018-09-26  Elisa Barboni  <barboni@adacore.com>
 
        * sem_prag.adb (Check_Refined_Global_Item): Improve error
index 73ab562bbb1fe333ed6a2dcdf19efa375cc9cfdc..9530165a0c1dbab74905558d39edacdc483656e5 100644 (file)
@@ -990,15 +990,16 @@ make_packable_type (tree type, bool in_record, unsigned int max_align)
     }
   else
     {
+      tree type_size = TYPE_ADA_SIZE (type);
       /* Do not try to shrink the size if the RM size is not constant.  */
       if (TYPE_CONTAINS_TEMPLATE_P (type)
-         || !tree_fits_uhwi_p (TYPE_ADA_SIZE (type)))
+         || !tree_fits_uhwi_p (type_size))
        return type;
 
       /* Round the RM size up to a unit boundary to get the minimal size
         for a BLKmode record.  Give up if it's already the size and we
         don't need to lower the alignment.  */
-      new_size = tree_to_uhwi (TYPE_ADA_SIZE (type));
+      new_size = tree_to_uhwi (type_size);
       new_size = (new_size + BITS_PER_UNIT - 1) & -BITS_PER_UNIT;
       if (new_size == size && (max_align == 0 || align <= max_align))
        return type;
@@ -5307,20 +5308,21 @@ unchecked_convert (tree type, tree expr, bool notrunc_p)
      to its size, sign- or zero-extend the result.  But we need not do this
      if the input is also an integral type and both are unsigned or both are
      signed and have the same precision.  */
+  tree type_rm_size;
   if (!notrunc_p
       && INTEGRAL_TYPE_P (type)
       && !(code == INTEGER_TYPE && TYPE_BIASED_REPRESENTATION_P (type))
-      && TYPE_RM_SIZE (type)
-      && tree_int_cst_compare (TYPE_RM_SIZE (type), TYPE_SIZE (type)) < 0
+      && (type_rm_size = TYPE_RM_SIZE (type))
+      && tree_int_cst_compare (type_rm_size, TYPE_SIZE (type)) < 0
       && !(INTEGRAL_TYPE_P (etype)
           && type_unsigned_for_rm (type) == type_unsigned_for_rm (etype)
           && (type_unsigned_for_rm (type)
-              || tree_int_cst_compare (TYPE_RM_SIZE (type),
+              || tree_int_cst_compare (type_rm_size,
                                        TYPE_RM_SIZE (etype)
                                        ? TYPE_RM_SIZE (etype)
                                        : TYPE_SIZE (etype)) == 0)))
     {
-      if (integer_zerop (TYPE_RM_SIZE (type)))
+      if (integer_zerop (type_rm_size))
        expr = build_int_cst (type, 0);
       else
        {
@@ -5330,7 +5332,7 @@ unchecked_convert (tree type, tree expr, bool notrunc_p)
          tree shift_expr
            = convert (base_type,
                       size_binop (MINUS_EXPR,
-                                  TYPE_SIZE (type), TYPE_RM_SIZE (type)));
+                                  TYPE_SIZE (type), type_rm_size));
          expr
            = convert (type,
                       build_binary_op (RSHIFT_EXPR, base_type,
index 33fcbcd64963557ab2b632aff4c4f00ac5f4d414..dcf8253c3bc823afb08c07889e6843213bb541c2 100644 (file)
@@ -4231,16 +4231,23 @@ extern tree purpose_member (const_tree, tree);
 extern bool vec_member (const_tree, vec<tree, va_gc> *);
 extern tree chain_index (int, tree);
 
+/* Arguments may be null.  */
 extern int tree_int_cst_equal (const_tree, const_tree);
 
+/* The following predicates are safe to call with a null argument.  */
 extern bool tree_fits_shwi_p (const_tree) ATTRIBUTE_PURE;
 extern bool tree_fits_poly_int64_p (const_tree) ATTRIBUTE_PURE;
 extern bool tree_fits_uhwi_p (const_tree) ATTRIBUTE_PURE;
 extern bool tree_fits_poly_uint64_p (const_tree) ATTRIBUTE_PURE;
-extern HOST_WIDE_INT tree_to_shwi (const_tree);
-extern poly_int64 tree_to_poly_int64 (const_tree);
-extern unsigned HOST_WIDE_INT tree_to_uhwi (const_tree);
-extern poly_uint64 tree_to_poly_uint64 (const_tree);
+
+extern HOST_WIDE_INT tree_to_shwi (const_tree)
+  ATTRIBUTE_NONNULL (1) ATTRIBUTE_PURE;
+extern poly_int64 tree_to_poly_int64 (const_tree)
+  ATTRIBUTE_NONNULL (1) ATTRIBUTE_PURE;
+extern unsigned HOST_WIDE_INT tree_to_uhwi (const_tree)
+  ATTRIBUTE_NONNULL (1) ATTRIBUTE_PURE;
+extern poly_uint64 tree_to_poly_uint64 (const_tree)
+  ATTRIBUTE_NONNULL (1) ATTRIBUTE_PURE;
 #if !defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 4003)
 extern inline __attribute__ ((__gnu_inline__)) HOST_WIDE_INT
 tree_to_shwi (const_tree t)
@@ -4893,7 +4900,8 @@ extern bool really_constant_p (const_tree);
 extern bool ptrdiff_tree_p (const_tree, poly_int64_pod *);
 extern bool decl_address_invariant_p (const_tree);
 extern bool decl_address_ip_invariant_p (const_tree);
-extern bool int_fits_type_p (const_tree, const_tree);
+extern bool int_fits_type_p (const_tree, const_tree)
+  ATTRIBUTE_NONNULL (1) ATTRIBUTE_NONNULL (2) ATTRIBUTE_PURE;
 #ifndef GENERATOR_FILE
 extern void get_type_static_bounds (const_tree, mpz_t, mpz_t);
 #endif