view gcc/testsuite/c-c++-common/Wtautological-compare-ranges.c @ 19:2b5abeee2509 default tip

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
parents 1830386684a0
children
line wrap: on
line source

/* { dg-do compile } */
/* { dg-options "-Wtautological-compare -fdiagnostics-show-caret" } */

#define FOO foo

void
fn1 (int foo)
{
  if (foo == foo); /* { dg-warning "self-comparison always evaluates to true" } */
  /* { dg-begin-multiline-output "" }
   if (foo == foo);
           ^~
     { dg-end-multiline-output "" { target c } } */
  /* { dg-begin-multiline-output "" }
   if (foo == foo);
       ~~~ ^~ ~~~
     { dg-end-multiline-output "" { target c++ } } */
}

void
fn2 (int foo)
{
  if (FOO == FOO); /* { dg-warning "self-comparison always evaluates to true" } */
  /* { dg-begin-multiline-output "" }
   if (FOO == FOO);
           ^~
     { dg-end-multiline-output "" } */
}

void
fn3 (int foo)
{
  if ((foo & 16) == 10); /* { dg-warning "bitwise comparison always evaluates to false" } */
  /* { dg-begin-multiline-output "" }
   if ((foo & 16) == 10);
                  ^~
     { dg-end-multiline-output "" { target c } } */
  /* { dg-begin-multiline-output "" }
   if ((foo & 16) == 10);
       ~~~~~~~~~~ ^~ ~~
     { dg-end-multiline-output "" { target c++ } } */
}