https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124909
--- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Nope, at least not for this case. The cast from 8-bit or 16-bit test_enum to
int is not a nop_convert.
I guess you can also use
bool
foo (unsigned char x)
{
return (-1U << x) == x;
}
bool
bar (signed short x)
{
return (-1ULL << x) != x;
}
as further tests so that it is not dependent on -fshort-enum.
I guess INTEGRAL_TYPE (TREE_TYPE (@1)) for that (convert3? @1)
and perhaps TYPE_PRECISION (TREE_TYPE (@3)) >= TYPE_PRECISION (TREE_TYPE (@1))
?
Though I admit I haven't thought out if the narrowing casts are really a
problem.
I was thinking about @1 being say 0xffffffff00000001ULL and @3 being int or
unsigned int (so shift count being 1 or something small). But perhaps it is ok
even then.