1 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, October 2010. */
2 /* { dg-do compile } */
3 /* { dg-options "-Wall" } */
12 + (void) log: (int)level message: (const char *) my_format, ... __attribute__ ((format (printf, 2, 3)));
13 - (void) log: (int)level message: (const char *) my_format, ... __attribute__ ((format (printf, 2, 3)));
15 + (void) debug: (const char *) my_format, ... __attribute__ ((format (printf, 1, 2)));
16 - (void) debug: (const char *) my_format, ... __attribute__ ((format (printf, 1, 2)));
18 /* Just make sure a missing or invalid attribute won't crash the compiler. */
19 - (void) log2: (int)level message: (const char *) my_format, ... __attribute__ ((format (printf, 2))); /* { dg-error "wrong" } */
20 + (void) debug2: (const char *) my_format, ... __attribute__ ((format (printf))); /* { dg-error "wrong" } */
21 - (void) debug2: (const char *) my_format, ... __attribute__ ((format (printf))); /* { dg-error "wrong" } */
22 + (void) alert: (const char *) my_format __attribute__ ((format (printf, 1, 2))); /* { dg-error "args to be formatted is not ..." } */
23 - (void) alert: (const char *) my_format __attribute__ ((format (printf, 1, 2))); /* { dg-error "args to be formatted is not ..." } */
26 void test (LogObject *object)
28 [object log: 2 message: "attribute only applies to variadic functions"];
29 [object log: 2 message: "attribute %s only applies to variadic functions", "'format'"];
30 [object log: 2 message: "attribute %s only applies to variadic functions"]; /* { dg-warning "expects a matching" } */
32 [object debug: "attribute only applies to variadic functions"];
33 [object debug: "attribute %s only applies to variadic functions", "'format'"];
34 [object debug: "attribute %s only applies to variadic functions"]; /* { dg-warning "expects a matching" } */
36 [LogObject log: 2 message: "attribute only applies to variadic functions"];
37 [LogObject log: 2 message: "attribute %s only applies to variadic functions", "'format'"];
38 [LogObject log: 2 message: "attribute %s only applies to variadic functions"]; /* { dg-warning "expects a matching" } */
40 [LogObject debug: "attribute only applies to variadic functions"];
41 [LogObject debug: "attribute %s only applies to variadic functions", "'format'"];
42 [LogObject debug: "attribute %s only applies to variadic functions"]; /* { dg-warning "expects a matching" } */