On Tue, 1 May 2012, Manuel López-Ibáñez wrote: > > What if the comparison is > > > > (unsigned) (expr_of_signed_enum_type) >= 0 > > > > ? (With GCC, the enum will have a signed type if one of its values is > > negative.) That seems worth a warning - the point of the patch as I > > understand it is to avoid warning for > > What I understood from the PR is that we should never warn for enums.
I think the point is we shouldn't warn if the enum itself if part of the comparison - as opposed to the enum cast to some type whose signedness is not implementation-defined. But at present it may be difficult to tell if there was an explicit cast of an unsigned enum to unsigned - but we can still detect the above case. > +/* Given an expression as a tree, return its original type. Do this > + by stripping any conversion that generates no instruction but don't > + let the signedness change. */ "generates no instruction" is not appropriate semantics for something related to diagnostics. "any conversion that preserves the sign and precision"? OK with that version. -- Joseph S. Myers jos...@codesourcery.com