On Thu, Feb 6, 2014 at 1:24 PM, Marek Polacek <pola...@redhat.com> wrote:
> An obvious one, use location if available.  Can this be considered as
> a "docfix" though, thus ok for trunk?  (Not a regression.)
>
> Regtested/bootstrapped on x86_64-linux.

Ok.

Thanks,
Richard.

> 2014-02-06  Marek Polacek  <pola...@redhat.com>
>
>         PR c/60087
> c-family/
>         * c-common.c (warn_for_sign_compare): Call warning_at with location
>         instead of warning.
> testsuite/
>         * gcc.dg/pr60087.c: New test.
>
> diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c
> index 007e727..50cc848 100644
> --- gcc/c-family/c-common.c
> +++ gcc/c-family/c-common.c
> @@ -11285,8 +11285,8 @@ warn_for_sign_compare (location_t location,
>                if ((mask & constant) != mask)
>                 {
>                   if (constant == 0)
> -                   warning (OPT_Wsign_compare,
> -                            "promoted ~unsigned is always non-zero");
> +                   warning_at (location, OPT_Wsign_compare,
> +                               "promoted ~unsigned is always non-zero");
>                   else
>                     warning_at (location, OPT_Wsign_compare,
>                                 "comparison of promoted ~unsigned with 
> constant");
> diff --git gcc/testsuite/gcc.dg/pr60087.c gcc/testsuite/gcc.dg/pr60087.c
> index e69de29..9cdd589 100644
> --- gcc/testsuite/gcc.dg/pr60087.c
> +++ gcc/testsuite/gcc.dg/pr60087.c
> @@ -0,0 +1,14 @@
> +/* PR c/60087 */
> +/* { dg-do compile } */
> +/* { dg-options "-Wsign-compare" } */
> +
> +void
> +foo (unsigned int ui, int i)
> +{
> +  const unsigned char uc = 0;
> +  _Bool b;
> +  b = 0 != ~uc; /* { dg-warning "9:promoted ~unsigned is always non-zero" } 
> */
> +  b = 2 != ~uc; /* { dg-warning "9:comparison of promoted ~unsigned with 
> constant" } */
> +  b = uc == ~uc; /* { dg-warning "10:comparison of promoted ~unsigned with 
> unsigned" } */
> +  b = i == ui; /* { dg-warning "9:comparison between signed and unsigned 
> integer expressions" } */
> +}
>
>         Marek

Reply via email to