Debian Codegraph @

gcc/testsuite/g++.dg/warn/Wformat-2.C

raw
1 // PR c++/84076
2 // { dg-do compile }
3 // { dg-options "-Wformat" }
4
5 struct S { ~S (); };
6 struct T { T (); T (const T &); };
7
8 void
9 foo ()
10 {
11 S s;
12 T t;
13 __builtin_printf ("%s\n", s); // { dg-warning "format '%s' expects argument of type 'char\\*', but argument 2 has type 'S'" }
14 __builtin_printf ("%s\n", t); // { dg-warning "format '%s' expects argument of type 'char\\*', but argument 2 has type 'T'" }
15 __builtin_printf ("%s\n", &s);// { dg-warning "format '%s' expects argument of type 'char\\*', but argument 2 has type 'S\\*'" }
16 __builtin_printf ("%s\n", &t);// { dg-warning "format '%s' expects argument of type 'char\\*', but argument 2 has type 'T\\*'" }
17 }