| 1 |
704 |
jeremybenn |
/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, October 2010. */
|
| 2 |
|
|
/* { dg-do compile } */
|
| 3 |
|
|
/* { dg-options "-Wall" } */
|
| 4 |
|
|
|
| 5 |
|
|
#include <objc/objc.h>
|
| 6 |
|
|
#include <stdlib.h>
|
| 7 |
|
|
|
| 8 |
|
|
@interface LogObject
|
| 9 |
|
|
{
|
| 10 |
|
|
Class isa;
|
| 11 |
|
|
}
|
| 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)));
|
| 14 |
|
|
|
| 15 |
|
|
+ (void) debug: (const char *) my_format, ... __attribute__ ((format (printf, 1, 2)));
|
| 16 |
|
|
- (void) debug: (const char *) my_format, ... __attribute__ ((format (printf, 1, 2)));
|
| 17 |
|
|
|
| 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 ..." } */
|
| 24 |
|
|
@end
|
| 25 |
|
|
|
| 26 |
|
|
void test (LogObject *object)
|
| 27 |
|
|
{
|
| 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" } */
|
| 31 |
|
|
|
| 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" } */
|
| 35 |
|
|
|
| 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" } */
|
| 39 |
|
|
|
| 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" } */
|
| 43 |
|
|
}
|