This is the mail archive of the 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: [PATCH] Fold VIEW_CONVERT_EXPR <type, STRING_CST> generated by Fortran FE a lot (PR target/35366)

Jakub Jelinek wrote, at 11/11/2008 1:35 PM:
> On Tue, Nov 11, 2008 at 01:27:30PM -0800, Brooks Moses wrote:
>>> +	  else
>>> +	    gfc_warning ("Assigning value other than 0 or 1 to LOGICAL"
>>> +			 " at %L might have undefined result", &expr->where);
>> This doesn't -- if I'm understanding it correctly, it warns on any cast
>> of a non-integer value to a logical, regardless of whether the result
>> might or might not in fact be undefined.
> No, that's not what it does.  This warning is only in case it is constant,
> and stored in memory.  So in theory tmp should always be INTEGER_CST.
> I guess I could just assume it (or assert it).

Oh, okay; my mistake from not reading the code thoroughly enough.  But,
yes, if it's something that in theory should always be true, then
checking for it as if it's a plausible condition just makes the code
harder to understand.

I think it's reasonable to either assume or assert it, depending on how
confident you are that theory and practice match in this case.  Given
that you're creating tmp from a fold_build1 call with an integer type,
it seems safe to assume that it will in fact have an integer TREE_CODE,
and if it doesn't, something is sufficiently broken that it will be
showing up elsewhere too.  So I'd just assume it.

The warning could perhaps be edited a little, too, to reflect that the
user isn't necessarily thinking of the input as an integer.  Maybe:
"Cannot assign value with bitwise representation other than 0x0 or 0x1
to LOGICAL at %L".

- Brooks

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