On Tue, Jun 24, 2014 at 11:16 PM, Eric Botcazou <ebotca...@adacore.com> wrote:
>> I think that was on purpose to avoid arithmetics in enum types.  As those
>> conversions are useless and thus stripped later is it really important
>> to retain enum and boolean kind here?
>
> The problem is that convert.c is called by front-ends and the patch also
> removed the callback into them that made it possible to have some control.
> So, yes, it's pretty annoying to see totally bogus conversion nodes being
> introduced into your ASTs behind your back...

Ok, but the (previous and proposed) behavior is odd as for
unsigned_type_for (boolean_type_node) you'd get back
a BOOLEAN_TYPE but for unsigned_type_for (signed_type_for
(boolean_type_node)) you get back an INTEGER_TYPE.

That is, because we use build_nonstandard_integer_type now
the result will always be an INTEGER_TYPE (unless you happen
to pass in a type with the correct signedness with your patch).

I don't like re-introducing that inconsistency.

Maybe instead make convert.c do if (!TYPE_UNSIGNED) unsigned_type_for ()
instead?  I notice that all callers of [un]signed_type_for are in
"premature" optimizations convert.c performs (that better should be done
in fold-const.c).

Thanks,
Richard.

> --
> Eric Botcazou

Reply via email to