(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
pragma-diag-4.c
       1  /* { dg-do compile } */
       2  /* { dg-options "-Wsign-compare -Werror=sign-compare -Werror=switch-enum" } */
       3  /* { dg-message "warnings being treated as errors" "" {target "*-*-*"} 0 } */
       4  
       5  int bar()
       6  {
       7    unsigned x = 0;
       8    int y = 1;
       9  
      10    /* generates an error - ok */
      11    x += x < y ? 1 : 0; /* { dg-error "comparison" } */
      12  
      13  #pragma GCC diagnostic push
      14  #pragma GCC diagnostic ignored "-Wsign-compare"
      15    /* generates no diagnostic - ok */
      16    x += x < y ? 1 : 0;
      17  #pragma GCC diagnostic pop
      18  
      19    x += x < y ? 1 : 0; /* { dg-error "comparison" } */
      20  
      21    return x;
      22  }
      23  
      24  enum EE { ONE, TWO };
      25  
      26  int f (enum EE e)
      27  {
      28    int r = 0;
      29  
      30  #pragma GCC diagnostic push
      31  #pragma GCC diagnostic ignored "-Wswitch-enum"
      32  
      33    switch (e)
      34      {
      35      case ONE:
      36        r = 1;
      37        break;
      38      }
      39  #pragma GCC diagnostic pop
      40  
      41    switch (e) /* { dg-error "switch" } */
      42      {
      43      case ONE:
      44        r = 1;
      45        break;
      46      }
      47    return r;
      48  }