format ‘%i’ expects argument of type ‘int’, but argument 2 has type ‘const char * [-Wformat=]
9 printf("hello %i", msg); /* { dg-warning "format '%i' expects argument of type 'int', but argument 2 has type 'const char \\*' " } */
~^ ~~~
| |
int const char *
%s
--- ../../src/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
+++ ../../src/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
@@ -6,7 +6,7 @@
 
 void test_mismatching_types (const char *msg)
 {
-  printf("hello %i", msg);  /* { dg-warning "format '%i' expects argument of type 'int', but argument 2 has type 'const char \\*' " } */
+  printf("hello %s", msg);  /* { dg-warning "format '%i' expects argument of type 'int', but argument 2 has type 'const char \\*' " } */
 
 /* { dg-begin-multiline-output "" }
    printf("hello %i", msg);
format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int [-Wformat=]
20 printf("hello %s", 42); /* { dg-warning "format '%s' expects argument of type 'char \\*', but argument 2 has type 'int'" } */
~^ ~~
| |
| int
char *
%d
--- ../../src/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
+++ ../../src/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
@@ -17,7 +17,7 @@
    { dg-end-multiline-output "" } */
 
 
-  printf("hello %s", 42);  /* { dg-warning "format '%s' expects argument of type 'char \\*', but argument 2 has type 'int'" } */
+  printf("hello %d", 42);  /* { dg-warning "format '%s' expects argument of type 'char \\*', but argument 2 has type 'int'" } */
 /* { dg-begin-multiline-output "" }
    printf("hello %s", 42);
                  ~^   ~~
format ‘%i’ expects argument of type ‘int’, but argument 2 has type ‘long int [-Wformat=]
30 printf("hello %i", (long)0); /* { dg-warning "format '%i' expects argument of type 'int', but argument 2 has type 'long int' " } */
~^ ~~~~~~~
| |
int long int
%li
--- ../../src/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
+++ ../../src/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
@@ -27,7 +27,7 @@
                  %d
    { dg-end-multiline-output "" } */
 
-  printf("hello %i", (long)0);  /* { dg-warning "format '%i' expects argument of type 'int', but argument 2 has type 'long int' " } */
+  printf("hello %li", (long)0);  /* { dg-warning "format '%i' expects argument of type 'int', but argument 2 has type 'long int' " } */
 /* { dg-begin-multiline-output "" }
    printf("hello %i", (long)0);
                  ~^   ~~~~~~~
format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int [-Wformat=]
42 printf ("arg0: %i arg1: %s arg 2: %i", /* { dg-warning "29: format '%s'" } */
~^
|
char *
%d
43 100, 101, 102);
~~~
|
int
--- ../../src/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
+++ ../../src/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
@@ -39,7 +39,7 @@
 
 void test_multiple_arguments (void)
 {
-  printf ("arg0: %i  arg1: %s arg 2: %i", /* { dg-warning "29: format '%s'" } */
+  printf ("arg0: %i  arg1: %d arg 2: %i", /* { dg-warning "29: format '%s'" } */
           100, 101, 102);
 /* { dg-begin-multiline-output "" }
    printf ("arg0: %i  arg1: %s arg 2: %i",
format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int [-Wformat=]
59 printf ("arg0: %i arg1: %s arg 2: %i", /* { dg-warning "29: format '%s'" } */
~^
|
char *
%d
60 100, i + j, 102);
~~~~~
|
int
--- ../../src/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
+++ ../../src/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
@@ -56,7 +56,7 @@
 
 void test_multiple_arguments_2 (int i, int j)
 {
-  printf ("arg0: %i  arg1: %s arg 2: %i", /* { dg-warning "29: format '%s'" } */
+  printf ("arg0: %i  arg1: %d arg 2: %i", /* { dg-warning "29: format '%s'" } */
           100, i + j, 102);
 /* { dg-begin-multiline-output "" }
    printf ("arg0: %i  arg1: %s arg 2: %i",
format ‘%d’ expects a matching ‘int’ argument [-Wformat=]
75 printf ("before the fmt specifier" /* { dg-warning "11: format '%d' expects a matching 'int' argument" } */
^~~~~~~~~~~~~~~~~~~~~~~~~~
format string is defined here
81 "%"
~~
82 "d" /* { dg-message "12: format string is defined here" } */
~^
|
int
format ‘%i’ expects argument of type ‘int’, but argument 2 has type ‘const char * [-Wformat=]
99 printf("hello \x25\x69", msg); /* { dg-warning "format '%i' expects argument of type 'int', but argument 2 has type 'const char \\*' " } */
~~~~^~~~ ~~~
| |
int const char *
\x25s
--- ../../src/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
+++ ../../src/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
@@ -96,7 +96,7 @@
 {
   /* "%" is \x25
      "i" is \x69 */
-  printf("hello \x25\x69", msg);  /* { dg-warning "format '%i' expects argument of type 'int', but argument 2 has type 'const char \\*' " } */
+  printf("hello \x25s", msg);  /* { dg-warning "format '%i' expects argument of type 'int', but argument 2 has type 'const char \\*' " } */
 
 /* { dg-begin-multiline-output "" }
    printf("hello \x25\x69", msg);
format ‘%i’ expects argument of type ‘int’, but argument 2 has type ‘const char * [-Wformat=]
114 printf("hello \045\151", msg); /* { dg-warning "format '%i' expects argument of type 'int', but argument 2 has type 'const char \\*' " } */
~~~~^~~~ ~~~
| |
int const char *
\045s
--- ../../src/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
+++ ../../src/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
@@ -111,7 +111,7 @@
 {
   /* "%" is octal 045
      "i" is octal 151.  */
-  printf("hello \045\151", msg);  /* { dg-warning "format '%i' expects argument of type 'int', but argument 2 has type 'const char \\*' " } */
+  printf("hello \045s", msg);  /* { dg-warning "format '%i' expects argument of type 'int', but argument 2 has type 'const char \\*' " } */
 
 /* { dg-begin-multiline-output "" }
    printf("hello \045\151", msg);
format ‘%i’ expects argument of type ‘int’, but argument 2 has type ‘const char * [-Wformat=]
129 printf("prefix" "\x25" "\151" "suffix", /* { dg-warning "format '%i'" } */
^~~~~~~~
130 msg);
~~~
|
const char *
format string is defined here
129 printf("prefix" "\x25" "\151" "suffix", /* { dg-warning "format '%i'" } */
~~~~~~~~^~~~
|
int
\x25" "s
--- ../../src/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
+++ ../../src/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
@@ -126,7 +126,7 @@
 {
   /* "%" is \x25 in hex
      "i" is \151 in octal.  */
-  printf("prefix"  "\x25"  "\151"  "suffix",  /* { dg-warning "format '%i'" } */
+  printf("prefix"  "\x25"  "s"  "suffix",  /* { dg-warning "format '%i'" } */
          msg);
 /* { dg-begin-multiline-output "" }
    printf("prefix"  "\x25"  "\151"  "suffix",
pointer targets in passing argument 1 of ‘printf’ differ in signedness [-Wpointer-sign]
151 printf(u8"hello %i", msg);/* { dg-warning "format '%i' expects argument of type 'int', but argument 2 has type 'const char \\*' " } */
^~~~~~~~~~~~
|
unsigned char *
expected ‘const char * restrict’ but argument is of type ‘unsigned char *
110 extern int printf (const char *restrict, ...);
^~~~~~~~~~~~~~~~~~~~
format ‘%i’ expects argument of type ‘int’, but argument 2 has type ‘const char * [-Wformat=]
151 printf(u8"hello %i", msg);/* { dg-warning "format '%i' expects argument of type 'int', but argument 2 has type 'const char \\*' " } */
~^ ~~~
| |
int const char *
%s
--- ../../src/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
+++ ../../src/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
@@ -148,7 +148,7 @@
 
 void test_u8 (const char *msg)
 {
-  printf(u8"hello %i", msg);/* { dg-warning "format '%i' expects argument of type 'int', but argument 2 has type 'const char \\*' " } */
+  printf(u8"hello %s", msg);/* { dg-warning "format '%i' expects argument of type 'int', but argument 2 has type 'const char \\*' " } */
 /* { dg-begin-multiline-output "" }
    printf(u8"hello %i", msg);
                    ~^   ~~~
format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘long int [-Wformat=]
163 printf ("foo %s bar", long_i + long_j); /* { dg-warning "17: format '%s' expects argument of type 'char \\*', but argument 2 has type 'long int'" } */
~^ ~~~~~~~~~~~~~~~
| |
char * long int
%ld
--- ../../src/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
+++ ../../src/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
@@ -160,7 +160,7 @@
 
 void test_param (long long_i, long long_j)
 {
-  printf ("foo %s bar", long_i + long_j); /* { dg-warning "17: format '%s' expects argument of type 'char \\*', but argument 2 has type 'long int'" } */
+  printf ("foo %ld bar", long_i + long_j); /* { dg-warning "17: format '%s' expects argument of type 'char \\*', but argument 2 has type 'long int'" } */
 /* { dg-begin-multiline-output "" }
    printf ("foo %s bar", long_i + long_j);
                 ~^       ~~~~~~~~~~~~~~~
field width specifier ‘*’ expects argument of type ‘int’, but argument 2 has type ‘long int [-Wformat=]
175 printf (" %*.*d ", l, i1, i2); /* { dg-warning "14: field width specifier '\\*' expects argument of type 'int', but argument 2 has type 'long int'" } */
~^~~~ ~
| |
int long int
field width specifier ‘*’ expects argument of type ‘int’, but argument 3 has type ‘long int [-Wformat=]
188 __builtin_sprintf (d, " %*ld ", foo, foo); /* { dg-warning "28: field width specifier '\\*' expects argument of type 'int', but argument 3 has type 'long int'" } */
~^~~ ~~~
| |
int long int
field width specifier ‘*’ expects argument of type ‘int’, but argument 3 has type ‘long int [-Wformat=]
196 __builtin_sprintf (d, " %*ld ", foo + bar, foo); /* { dg-warning "28: field width specifier '\\*' expects argument of type 'int', but argument 3 has type 'long int'" } */
~^~~ ~~~~~~~~~
| |
int long int
field precision specifier ‘.*’ expects argument of type ‘int’, but argument 3 has type ‘long int [-Wformat=]
207 __builtin_sprintf (d, " %.*ld ", foo, foo); /* { dg-warning "29: field precision specifier '\\.\\*' expects argument of type 'int', but argument 3 has type 'long int'" } */
~~^~~ ~~~
| |
int long int
field precision specifier ‘.*’ expects argument of type ‘int’, but argument 3 has type ‘long int [-Wformat=]
215 __builtin_sprintf (d, " %.*ld ", foo + bar, foo); /* { dg-warning "29: field precision specifier '\\.\\*' expects argument of type 'int', but argument 3 has type 'long int'" } */
~~^~~ ~~~~~~~~~
| |
int long int
spurious trailing ‘%’ in format [-Wformat=]
226 printf("hello world %"); /* { dg-warning "23: spurious trailing" } */
^
empty left precision in gnu_strfmon format [-Wformat=]
236 strfmon (s, m, "%#.5n", d); /* { dg-warning "20: empty left precision in gnu_strfmon format" } */
^
empty precision in gnu_strfmon format [-Wformat=]
242 strfmon (s, m, "%#5.n", d); /* { dg-warning "22: empty precision in gnu_strfmon format" } */
^
repeated '+' flag in format [-Wformat=]
251 printf ("%++d", i); /* { dg-warning "14: repeated '\\+' flag in format" } */
^
conversion lacks type at end of format [-Wformat=]
260 printf (" %h"); /* { dg-warning "14:conversion lacks type at end of format" } */
^
embedded ‘\0’ in format [-Wformat-contains-nul]
269 printf (" \0 "); /* { dg-warning "13:embedded" "warning for embedded NUL" } */
^~
format ‘%i’ expects argument of type ‘int’, but argument 2 has type ‘const char * [-Wformat=]
279 printf("hello " INT_FMT " world", msg); /* { dg-warning "10: format '%i' expects argument of type 'int', but argument 2 has type 'const char \\*' " } */
^~~~~~~~ ~~~
|
const char *
format string is defined here
278 #define INT_FMT "%i" /* { dg-message "19: format string is defined here" } */
~^
|
int
%s
--- ../../src/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
+++ ../../src/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
@@ -275,7 +275,7 @@
 
 void test_macro (const char *msg)
 {
-#define INT_FMT "%i" /* { dg-message "19: format string is defined here" } */
+#define INT_FMT "%s" /* { dg-message "19: format string is defined here" } */
   printf("hello " INT_FMT " world", msg);  /* { dg-warning "10: format '%i' expects argument of type 'int', but argument 2 has type 'const char \\*' " } */
 /* { dg-begin-multiline-output "" }
    printf("hello " INT_FMT " world", msg);
format ‘%u’ expects argument of type ‘unsigned int’, but argument 2 has type ‘const char * [-Wformat=]
299 printf("hello %" PRIu32 " world", msg); /* { dg-warning "10: format '%u' expects argument of type 'unsigned int', but argument 2 has type 'const char \\*' " } */
^~~~~~~~~ ~~~
|
const char *
format string is defined here
298 #define PRIu32 "u" /* { dg-message "17: format string is defined here" } */
^
|
unsigned int
format ‘%i’ expects argument of type ‘int’, but argument 2 has type ‘const char * [-Wformat=]
317 #define FMT_STRING "hello %i world" /* { dg-line test_macro_3_macro_line } */
^~~~~~~~~~~~~~~~
format string is defined here
317 #define FMT_STRING "hello %i world" /* { dg-line test_macro_3_macro_line } */
~^
|
int
%s
--- ../../src/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
+++ ../../src/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
@@ -314,7 +314,7 @@
 
 void test_macro_3 (const char *msg)
 {
-#define FMT_STRING "hello %i world" /* { dg-line test_macro_3_macro_line } */
+#define FMT_STRING "hello %s world" /* { dg-line test_macro_3_macro_line } */
   /* { dg-warning "20: format '%i' expects argument of type 'int', but argument 2 has type 'const char \\*'" "" { target *-*-*} .-1 } */
   printf(FMT_STRING, msg);  /* { dg-message "10: in expansion of macro 'FMT_STRING" } */
 /* { dg-begin-multiline-output "" }
format ‘%i’ expects argument of type ‘int’, but argument 2 has type ‘const char * [-Wformat=]
341 #define FMT_STRING "hello %i world" /* { dg-warning "20: format '%i' expects argument of type 'int', but argument 2 has type 'const char \\*' " } */
^~~~~~~~~~~~~~~~
format string is defined here
341 #define FMT_STRING "hello %i world" /* { dg-warning "20: format '%i' expects argument of type 'int', but argument 2 has type 'const char \\*' " } */
~^
|
int
%s
--- ../../src/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
+++ ../../src/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
@@ -338,7 +338,7 @@
 
 void test_macro_4 (const char *msg)
 {
-#define FMT_STRING "hello %i world" /* { dg-warning "20: format '%i' expects argument of type 'int', but argument 2 has type 'const char \\*' " } */
+#define FMT_STRING "hello %s world" /* { dg-warning "20: format '%i' expects argument of type 'int', but argument 2 has type 'const char \\*' " } */
   printf(FMT_STRING "\n", msg);  /* { dg-message "10: in expansion of macro 'FMT_STRING" } */
 /* { dg-begin-multiline-output "" }
  #define FMT_STRING "hello %i world"
format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘double [-Wformat=]
363 __builtin_printf(" %" "d ", 0.5); /* { dg-warning "20: format .%d. expects argument of type .int., but argument 2 has type .double." } */
^~~~ ~~~
|
double
format string is defined here
363 __builtin_printf(" %" "d ", 0.5); /* { dg-warning "20: format .%d. expects argument of type .int., but argument 2 has type .double." } */
~~~~^
|
int
%" "f
--- ../../src/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
+++ ../../src/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c
@@ -360,7 +360,7 @@
 
 void test_non_contiguous_strings (void)
 {
-  __builtin_printf(" %" "d ", 0.5); /* { dg-warning "20: format .%d. expects argument of type .int., but argument 2 has type .double." } */
+  __builtin_printf(" %" "f ", 0.5); /* { dg-warning "20: format .%d. expects argument of type .int., but argument 2 has type .double." } */
                                     /* { dg-message "26: format string is defined here" "" { target *-*-* } .-1 } */
   /* { dg-begin-multiline-output "" }
    __builtin_printf(" %" "d ", 0.5);
format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘double [-Wformat=]
385 __builtin_printf(a, 0.5); /* { dg-warning "20: format .%d. expects argument of type .int., but argument 2 has type .double." } */
^ ~~~
|
double