(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
format/
pr80619.c
       1  /* PR c/80619 - bad fix-it hint for GCC %lu directive with int argument: %wu
       2     { dg-do compile }
       3     { dg-options "-Wall -fdiagnostics-show-caret" } */
       4  
       5  void T (const char*, ...) __attribute__ ((format (__gcc_diag__, 1, 2)));
       6  
       7  void test_suggested_modifier (void)
       8  {
       9    T ("%ld", 0);     // { dg-warning "format '%ld' expects argument of type 'long int', but argument 2 has type 'int'" }
      10    /* { dg-begin-multiline-output "" }
      11     T ("%ld", 0);
      12         ~~^   ~
      13           |   |
      14           |   int
      15           long int
      16         %d
      17     { dg-end-multiline-output "" } */
      18  
      19    T ("%li", 0);     // { dg-warning "format '%li' expects argument of type 'long int', but argument 2 has type 'int'" }
      20    /* { dg-begin-multiline-output "" }
      21     T ("%li", 0);
      22         ~~^   ~
      23           |   |
      24           |   int
      25           long int
      26         %i
      27         { dg-end-multiline-output "" } */
      28  
      29    T ("%lu", 0);     // { dg-warning "format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'int'" }
      30    /* { dg-begin-multiline-output "" }
      31     T ("%lu", 0);
      32         ~~^   ~
      33           |   |
      34           |   int
      35           long unsigned int
      36         %u
      37         { dg-end-multiline-output "" } */
      38  
      39    T ("%lx", 0);     // { dg-warning "format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'int'" }
      40    /* { dg-begin-multiline-output "" }
      41     T ("%lx", 0);
      42         ~~^   ~
      43           |   |
      44           |   int
      45           long unsigned int
      46         %x
      47         { dg-end-multiline-output "" } */
      48  
      49    T ("%lli", 0);    // { dg-warning "format '%lli' expects argument of type 'long long int', but argument 2 has type 'int'" }
      50    /* { dg-begin-multiline-output "" }
      51     T ("%lli", 0);
      52         ~~~^   ~
      53            |   |
      54            |   int
      55            long long int
      56         %i
      57         { dg-end-multiline-output "" } */
      58  
      59    T ("%llo", 0);    // { dg-warning "format '%llo' expects argument of type 'long long unsigned int', but argument 2 has type 'int'" }
      60    /* { dg-begin-multiline-output "" }
      61     T ("%llo", 0);
      62         ~~~^   ~
      63            |   |
      64            |   int
      65            long long unsigned int
      66         %o
      67         { dg-end-multiline-output "" } */
      68  
      69    T ("%llu", 0);    // { dg-warning "format '%llu' expects argument of type 'long long unsigned int', but argument 2 has type 'int'" }
      70    /* { dg-begin-multiline-output "" }
      71     T ("%llu", 0);
      72         ~~~^   ~
      73            |   |
      74            |   int
      75            long long unsigned int
      76         %u
      77         { dg-end-multiline-output "" } */
      78  
      79    T ("%llx", 0);    // { dg-warning "format '%llx' expects argument of type 'long long unsigned int', but argument 2 has type 'int'" }
      80    /* { dg-begin-multiline-output "" }
      81     T ("%llx", 0);
      82         ~~~^   ~
      83            |   |
      84            |   int
      85            long long unsigned int
      86         %x
      87         { dg-end-multiline-output "" } */
      88  }
      89