This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: General question about types of tree expressions


On Wed, 9 Feb 2005, Andrew Pinski wrote:

>
> On Feb 9, 2005, at 9:16 AM, Richard Guenther wrote:
>
> > Hi!
> >
> > Are there constraints on say, the types of the operands of a
> > PLUS_EXPR of type t?  I.e. is a PLUS_EXPR (int, short, unsigned int)
> > a valid tree?  Or do the operands need to be both integer in this
> > case, too?
> >
> > I don't seem to find any documentation about such stuff.
>
> That is because it is not quiet well defined just yet (but is generally
> what I will saw below).
>
> But yes any integer (and floating and vector) type is okay for PLUS_EXPR
> as long as all three types match.  What I mean is that the operands of
> PLUS_EXPR have to have the same type as the PLUS_EXPR.

Ok, so PLUS_EXPR (int, short, unsigned int) is invalid - though the
middle-end seems to be "happy" which such node and checking does not
catch it.  For example

 <integer_type 0x4014957c int public SI
    size <integer_cst 0x40141408 type <integer_type 0x401492f4
bit_size_type> constant invariant 32>
    unit size <integer_cst 0x40141198 type <integer_type 0x40149288
unsigned int> constant invariant 4>
    align 32 symtab 0 alias set -1 precision 32 min <integer_cst
0x401413c0 -2147483648> max <integer_cst 0x401413d8 2147483647>
    pointer_to_this <pointer_type 0x40156dec>>

and

<integer_type 0x401495e8 unsigned int public unsigned SI
    size <integer_cst 0x40141408 type <integer_type 0x401492f4
bit_size_type> constant invariant 32>
    unit size <integer_cst 0x40141198 type <integer_type 0x40149288
unsigned int> constant invariant 4>
    align 32 symtab 0 alias set -1 precision 32 min <integer_cst
0x40141480 0> max <integer_cst 0x40141468 4294967295>>

are accepted as operands of a PLUS_EXPR of the first type.

Richard.

--
Richard Guenther <richard dot guenther at uni-tuebingen dot de>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]