public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Richard Guenther" <richard.guenther@gmail.com>
To: "Aldy Hernandez" <aldyh@redhat.com>
Cc: "Diego Novillo" <dnovillo@google.com>, gcc-patches@gcc.gnu.org
Subject: Re: [tuples] dereference POINTER_PLUS_EXPR check
Date: Wed, 21 Nov 2007 23:43:00 -0000	[thread overview]
Message-ID: <84fc9c000711211357w7a2587d2n663dd561845e4e1c@mail.gmail.com> (raw)
In-Reply-To: <20071121215235.GA11077@redhat.com>

On Nov 21, 2007 10:52 PM, Aldy Hernandez <aldyh@redhat.com> wrote:
> > Maybe we could make this a helper in tree.c.  Something like
> > pointed_to_type().  I don't think one exists already, but I may be wrong.
>
> Things are a bit cleaner now too, bonus!
>
> Is this OK?

No, sorry.  It doesn't make sense to check the pointed-to types.  Or do you
say the modify expr embeds a de-reference?

Richard.

>         * tree.c (pointed_to_type): New.
>         * tree.h (pointed_to_type): Protoize.
>         * tree-cfg.c (verify_types_in_gimple_assign): Use the dereferenced
>         type when checking the validity of a POINTER_PLUS_EXPR.
>
> Index: tree.c
> ===================================================================
> --- tree.c      (revision 130313)
> +++ tree.c      (working copy)
> @@ -8833,4 +8833,14 @@ block_nonartificial_location (tree block
>    return ret;
>  }
>
> +/* Given a tree type T, drill down to the type it points to and return
> +   it.  */
> +tree
> +pointed_to_type (tree t)
> +{
> +  while (POINTER_TYPE_P (t) || TREE_CODE (t) == ARRAY_TYPE)
> +    t = TREE_TYPE (t);
> +  return t;
> +}
> +
>  #include "gt-tree.h"
> Index: tree.h
> ===================================================================
> --- tree.h      (revision 130313)
> +++ tree.h      (working copy)
> @@ -4918,6 +4918,7 @@ extern tree *tree_block (tree);
>  extern tree *generic_tree_operand (tree, int);
>  extern tree *generic_tree_type (tree);
>  extern location_t *block_nonartificial_location (tree);
> +extern tree pointed_to_type (tree);
>
>  /* In function.c */
>  extern void expand_main_function (void);
> Index: tree-cfg.c
> ===================================================================
> --- tree-cfg.c  (revision 130313)
> +++ tree-cfg.c  (working copy)
> @@ -3558,8 +3558,16 @@ verify_types_in_gimple_assign (gimple st
>             error ("invalid operands in pointer plus expression");
>             return true;
>           }
> -       if (!POINTER_TYPE_P (rhs1_type)
> -           || !useless_type_conversion_p (lhs_type, rhs1_type)
> +
> +       if (!POINTER_TYPE_P (lhs_type)
> +           || !POINTER_TYPE_P (rhs1_type))
> +         {
> +           error ("type mismatch in pointer plus expression");
> +           return true;
> +         }
> +
> +       if (!useless_type_conversion_p (pointed_to_type (lhs_type),
> +                                       pointed_to_type (rhs1_type))
>             || !useless_type_conversion_p (sizetype, rhs2_type))
>
>           {
>             error ("type mismatch in pointer plus expression");
>

  reply	other threads:[~2007-11-21 21:57 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-21 22:03 Aldy Hernandez
2007-11-21 23:03 ` Diego Novillo
2007-11-21 23:25   ` Aldy Hernandez
2007-11-21 23:43     ` Richard Guenther [this message]
2007-11-22  1:26       ` Aldy Hernandez
2007-11-22  7:35         ` Richard Guenther
2007-11-22 11:32           ` Aldy Hernandez
2007-11-22 12:08             ` Andrew Pinski
2007-11-22 21:35               ` [FORTRAN mainline] dereference POINTER_PLUS_EXPR check (was tuples) Aldy Hernandez
2007-11-22 21:56                 ` Richard Guenther
2007-11-23 11:38                   ` Aldy Hernandez
2007-11-23 12:13                     ` Richard Guenther
2007-11-24 20:54                     ` libgomp failure (was: Re: [FORTRAN mainline] dereference POINTER_PLUS_EXPR check) Tobias Burnus
2007-11-25 16:13                       ` Aldy Hernandez
2007-11-25 21:32                       ` Aldy Hernandez
2007-11-25 21:59                         ` Richard Guenther
2007-11-27 13:24                         ` [PATCH] Fix fortran libgomp failures Jakub Jelinek
2007-11-27 16:51                           ` Richard Guenther
2007-11-28 19:39                             ` Tobias Burnus
2007-11-22 22:09                 ` [FORTRAN mainline] dereference POINTER_PLUS_EXPR check (was tuples) Tobias Burnus
2007-11-22 13:43             ` [tuples] dereference POINTER_PLUS_EXPR check Richard Guenther
2007-11-22 15:34           ` Diego Novillo
2007-11-22 18:56             ` Aldy Hernandez
2007-11-21 23:31 ` Richard Guenther

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=84fc9c000711211357w7a2587d2n663dd561845e4e1c@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=aldyh@redhat.com \
    --cc=dnovillo@google.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).