Fariborz Jahanian | 5b16092 | 2009-05-20 17:41:43 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -verify -fsyntax-only %s |
| 2 | |
| 3 | @class NSString; |
| 4 | |
| 5 | extern NSString *fa2 (const NSString *) __attribute__((format_arg(1))); |
| 6 | extern NSString *fa3 (NSString *) __attribute__((format_arg(1))); |
| 7 | |
| 8 | extern void fc1 (const NSString *) __attribute__((format_arg)); // expected-error {{attribute requires 1 argument(s)}} |
| 9 | extern void fc2 (const NSString *) __attribute__((format_arg())); // expected-error {{attribute requires 1 argument(s)}} |
| 10 | extern void fc3 (const NSString *) __attribute__((format_arg(1, 2))); // expected-error {{attribute requires 1 argument(s)}} |
| 11 | |
| 12 | struct s1 { int i; } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to function types}} |
| 13 | union u1 { int i; } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to function types}} |
| 14 | // FIXME: We don't flag this yet. |
| 15 | enum e1 { E1V0 } __attribute__((format_arg(1))); /* { dg-error "does not apply|only applies" "format_arg on enum" } */ |
| 16 | |
| 17 | extern NSString *ff3 (const NSString *) __attribute__((format_arg(3-2))); |
| 18 | extern NSString *ff4 (const NSString *) __attribute__((format_arg(foo))); // expected-error {{attribute requires 1 argument(s)}} |
| 19 | |
| 20 | /* format_arg formats must take and return a string. */ |
| 21 | extern NSString *fi0 (int) __attribute__((format_arg(1))); // expected-error {{format argument not a string type}} |
| 22 | extern NSString *fi1 (NSString *) __attribute__((format_arg(1))); |
| 23 | |
| 24 | extern NSString *fi2 (NSString *) __attribute__((format_arg(1))); |
| 25 | |
| 26 | extern int fi3 (const NSString *) __attribute__((format_arg(1))); // expected-error {{function does not return NSString}} |
| 27 | extern NSString *fi4 (const NSString *) __attribute__((format_arg(1))); |
| 28 | extern NSString *fi5 (const NSString *) __attribute__((format_arg(1))); |