]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix a few incorrect accesses.
authorAndrew MacLeod <amacleod@redhat.com>
Tue, 29 Nov 2022 18:07:28 +0000 (13:07 -0500)
committerAndrew MacLeod <amacleod@redhat.com>
Fri, 2 Dec 2022 16:50:05 +0000 (11:50 -0500)
This consists of 3 changes which stronger type checking has indicated
are incorrect.

gcc/
* fold-const.cc (fold_unary_loc): Check TREE_TYPE of node.
(tree_invalid_nonnegative_warnv_p): Likewise.

gcc/c-family/
* c-attribs.cc (handle_deprecated_attribute): Use type when
using TYPE_NAME.

gcc/c-family/c-attribs.cc
gcc/fold-const.cc

index 07bca68e9b9425ed4631f110e2572eb99c1ee11c..b36dd97802b9c2003afdbe67a120aba322d2766c 100644 (file)
@@ -4240,7 +4240,7 @@ handle_deprecated_attribute (tree *node, tree name,
       if (type && TYPE_NAME (type))
        {
          if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
-           what = TYPE_NAME (*node);
+           what = TYPE_NAME (type);
          else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
                   && DECL_NAME (TYPE_NAME (type)))
            what = DECL_NAME (TYPE_NAME (type));
index 114258fa182b1bede268a61e073130746545da1a..e80be8049e1680d73042d610f534e7f4858c0e46 100644 (file)
@@ -9369,8 +9369,8 @@ fold_unary_loc (location_t loc, enum tree_code code, tree type, tree op0)
              && TREE_CODE (tem) == COND_EXPR
              && TREE_CODE (TREE_OPERAND (tem, 1)) == code
              && TREE_CODE (TREE_OPERAND (tem, 2)) == code
-             && ! VOID_TYPE_P (TREE_OPERAND (tem, 1))
-             && ! VOID_TYPE_P (TREE_OPERAND (tem, 2))
+             && ! VOID_TYPE_P (TREE_TYPE (TREE_OPERAND (tem, 1)))
+             && ! VOID_TYPE_P (TREE_TYPE (TREE_OPERAND (tem, 2)))
              && (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (tem, 1), 0))
                  == TREE_TYPE (TREE_OPERAND (TREE_OPERAND (tem, 2), 0)))
              && (! (INTEGRAL_TYPE_P (TREE_TYPE (tem))
@@ -15002,7 +15002,7 @@ tree_invalid_nonnegative_warnv_p (tree t, bool *strict_overflow_p, int depth)
 
        /* If the initializer is non-void, then it's a normal expression
           that will be assigned to the slot.  */
-       if (!VOID_TYPE_P (t))
+       if (!VOID_TYPE_P (TREE_TYPE (t)))
          return RECURSE (t);
 
        /* Otherwise, the initializer sets the slot in some way.  One common