(root)/
gcc-13.2.0/
gcc/
testsuite/
c-c++-common/
Wtautological-compare-ranges.c
       1  /* { dg-do compile } */
       2  /* { dg-options "-Wtautological-compare -fdiagnostics-show-caret" } */
       3  
       4  #define FOO foo
       5  
       6  void
       7  fn1 (int foo)
       8  {
       9    if (foo == foo); /* { dg-warning "self-comparison always evaluates to true" } */
      10    /* { dg-begin-multiline-output "" }
      11     if (foo == foo);
      12             ^~
      13       { dg-end-multiline-output "" { target c } } */
      14    /* { dg-begin-multiline-output "" }
      15     if (foo == foo);
      16         ~~~ ^~ ~~~
      17       { dg-end-multiline-output "" { target c++ } } */
      18  }
      19  
      20  void
      21  fn2 (int foo)
      22  {
      23    if (FOO == FOO); /* { dg-warning "self-comparison always evaluates to true" } */
      24    /* { dg-begin-multiline-output "" }
      25     if (FOO == FOO);
      26             ^~
      27       { dg-end-multiline-output "" } */
      28  }
      29  
      30  void
      31  fn3 (int foo)
      32  {
      33    if ((foo & 16) == 10); /* { dg-warning "bitwise comparison always evaluates to false" } */
      34    /* { dg-begin-multiline-output "" }
      35     if ((foo & 16) == 10);
      36                    ^~
      37       { dg-end-multiline-output "" { target c } } */
      38    /* { dg-begin-multiline-output "" }
      39     if ((foo & 16) == 10);
      40         ~~~~~~~~~~ ^~ ~~
      41       { dg-end-multiline-output "" { target c++ } } */
      42  }