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: locating unsigned type for non-standard precision


On Fri, Apr 27, 2012 at 4:29 AM, Georg-Johann Lay <avr@gjlay.de> wrote:
> Richard Guenther wrote:
>> [PR c/51527]
>>
>> I think the fix would be sth like
>>
>> Index: gcc/convert.c
>> ===================================================================
>> --- gcc/convert.c ? ? ? (revision 186871)
>> +++ gcc/convert.c ? ? ? (working copy)
>> @@ -769,6 +769,7 @@ convert_to_integer (tree type, tree expr
>> ? ? ? ? ? ? ? ? ? ?(Otherwise would recurse infinitely in convert. ?*/
>> ? ? ? ? ? ? ? ? if (TYPE_PRECISION (typex) != inprec)
>> ? ? ? ? ? ? ? ? ? {
>> + ? ? ? ? ? ? ? ? ? tree otypex = typex;
>> ? ? ? ? ? ? ? ? ? ? /* Don't do unsigned arithmetic where signed was wanted,
>> ? ? ? ? ? ? ? ? ? ? ? ?or vice versa.
>> ? ? ? ? ? ? ? ? ? ? ? ?Exception: if both of the original operands were
>> @@ -806,10 +807,11 @@ convert_to_integer (tree type, tree expr
>> ? ? ? ? ? ? ? ? ? ? ? typex = unsigned_type_for (typex);
>> ? ? ? ? ? ? ? ? ? ? else
>> ? ? ? ? ? ? ? ? ? ? ? typex = signed_type_for (typex);
>> - ? ? ? ? ? ? ? ? ? return convert (type,
>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? fold_build2 (ex_form, typex,
>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?convert (typex, arg0),
>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?convert (typex, arg1)));
>> + ? ? ? ? ? ? ? ? ? if (TYPE_PRECISION (otypex) == TYPE_PRECISION (typex))
>> + ? ? ? ? ? ? ? ? ? ? return convert (type,
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? fold_build2 (ex_form, typex,
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?convert (typex, arg0),
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?convert (typex, arg1)));
>> ? ? ? ? ? ? ? ? ? }
>> ? ? ? ? ? ? ? }
>> ? ? ? ? ? }
>
> Thanks for the patch.
>
> I bootstrapped and regression-tested on i686-pc-linux-gnu.
>
> If it's ok with you I'd go ahead and install it.
>
> And maybe Peter could tell if it also fixes the issue on his platform.

It does (though so did moving the original test down past the last
change to typex).

I've switched mspgcc to use the version you committed.

Peter

>
> Johann


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