Re: [m32c] type precedence rules and pointer signs

2008-01-31 Thread Richard Guenther
On Jan 31, 2008 9:26 PM, DJ Delorie <[EMAIL PROTECTED]> wrote: > > > It's correct to always sign-extend the offset to the pointer mode > > width (or simply truncate it, if the offset width is larger than > > pointer mode width). > > I'd argue against that if you're dereferencing a large structure >

Re: [m32c] type precedence rules and pointer signs

2008-01-31 Thread DJ Delorie
> It's correct to always sign-extend the offset to the pointer mode > width (or simply truncate it, if the offset width is larger than > pointer mode width). I'd argue against that if you're dereferencing a large structure pointer. P->foo would always be an unsigned offset. Similarly for arrays

Re: [m32c] type precedence rules and pointer signs

2008-01-31 Thread Richard Guenther
On Jan 31, 2008 9:11 PM, DJ Delorie <[EMAIL PROTECTED]> wrote: > > > case POINTER_PLUS_EXPR: > > /* Even though the sizetype mode and the pointer's mode can be > > different > > expand is able to handle this correctly and get the correct result > > out > > of the PLUS_

Re: [m32c] type precedence rules and pointer signs

2008-01-31 Thread DJ Delorie
> case POINTER_PLUS_EXPR: > /* Even though the sizetype mode and the pointer's mode can be different > expand is able to handle this correctly and get the correct result > out > of the PLUS_EXPR code. */ Me thinks that comment now needs some rethinking ;-)

Re: [m32c] type precedence rules and pointer signs

2008-01-31 Thread Andrew Pinski
On Jan 31, 2008 12:00 PM, DJ Delorie <[EMAIL PROTECTED]> wrote: > Which file would that be in? It wasn't obvious from a simple grep. > Or is that sprinkled all over the place? The expansion is in expr.c with a comment of: case POINTER_PLUS_EXPR: /* Even though the sizetype mode and the

Re: [m32c] type precedence rules and pointer signs

2008-01-31 Thread DJ Delorie
> Can you represent all pointer offsets (well, those you actually > support) within sizetype? Yes. It's a limit, but we live with it. It would be nice if the offsets were extended according to their own sign, which gives us 1.5x the range of choosing a single signedness. > If so you probably o

Re: [m32c] type precedence rules and pointer signs

2008-01-31 Thread Richard Guenther
On Jan 31, 2008 8:40 PM, DJ Delorie <[EMAIL PROTECTED]> wrote: > > > The problem you are running into is that sizeof(sizetype) != > > sizeof(void *). In the middle-end the type used as offset > > (sizetype) doesn't have a defined signedness (it's unsigned for C, > > signed for Ada for example), so

Re: [m32c] type precedence rules and pointer signs

2008-01-31 Thread DJ Delorie
> The problem you are running into is that sizeof(sizetype) != > sizeof(void *). In the middle-end the type used as offset > (sizetype) doesn't have a defined signedness (it's unsigned for C, > signed for Ada for example), so we rely on the fact that its size > should match that of pointers (as t

Re: [m32c] type precedence rules and pointer signs

2008-01-31 Thread Richard Guenther
On Jan 31, 2008 12:45 AM, DJ Delorie <[EMAIL PROTECTED]> wrote: > > I'm debugging an EH failure on m32c-elf (-mcpu=m32c). The test case > is this: > > extern int U(); > > void *ra; > > main() > { > foo((ra + U()) - 1); > } > > In the context of the bug, sizeof(void *) is 32 (well, PSImode = 24 >

Re: [m32c] type precedence rules and pointer signs

2008-01-30 Thread Ross Ridge
DJ Delorie writes: >extern int U(); >void *ra; ... > foo((ra + U()) - 1) ... >1. What are the language rules controlling this expression, and do they >have any say about signed vs unsigned wrt the int->pointer promotion? There is no integer to pointer promotion. You're adding an integer to a poi

[m32c] type precedence rules and pointer signs

2008-01-30 Thread DJ Delorie
I'm debugging an EH failure on m32c-elf (-mcpu=m32c). The test case is this: extern int U(); void *ra; main() { foo((ra + U()) - 1); } In the context of the bug, sizeof(void *) is 32 (well, PSImode = 24 bit) and sizeof(int) == 16. U() returns zero in this example. So, the call is this: