[cfe-commits] r86129 - in /cfe/trunk: lib/Sema/Sema.h lib/Sema/SemaCXXCast.cpp lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaOverload.cpp test/SemaTemplate/instantiate-complete.cpp utils/C++Tests/LLVM-Syntax/lit.local.cfg

John McCall rjmccall at apple.com
Fri Nov 6 01:24:32 PST 2009


Chris Lattner wrote:
> This last part (known non-negative) involves a bunch of adhoc stuff  
> using fold to determine whether something is non-negative, allowing it  
> to catch things like 'abs' idioms etc.  We don't need to be this smart  
> imo :), but it would be nice to catch integer literals.
>   

We actually do catch anything that isIntegerConstantExpression can 
resolve to a constant.

Anyway, I've gone ahead and implemented all of these except...

> 		  /* Do not warn if the unsigned quantity is an enumeration
> 		     constant and its maximum value would fit in the result
> 		     if the result were signed.  */
>   

...which could easily be done if we care about it.

> Nearby they also have an interesting warning that I've never seen  
> generated:
>
>
> 	      /* Warn if two unsigned values are being compared in a size
> 		 larger than their original size, and one (and only one) is the
> 		 result of a `~' operator.  This comparison will always fail.
>
> 		 Also warn if one operand is a constant, and the constant
> 		 does not have all bits set that are set in the ~ operand
> 		 when it is extended.  */
>
> which results in:
> 			    warning (0, "comparison of promoted ~unsigned with constant");
>   

That is indeed a very interesting warning.

John.



More information about the cfe-commits mailing list