Fariborz Jahanian | 7395c79 | 2014-02-07 19:25:10 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -verify -fsyntax-only %s |
Fariborz Jahanian | f1c2502 | 2009-05-20 17:41:43 +0000 | [diff] [blame] | 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 | |
Aaron Ballman | b724338 | 2013-07-23 19:30:11 +0000 | [diff] [blame] | 8 | extern void fc1 (const NSString *) __attribute__((format_arg)); // expected-error {{'format_arg' attribute takes one argument}} |
| 9 | extern void fc2 (const NSString *) __attribute__((format_arg())); // expected-error {{'format_arg' attribute takes one argument}} |
| 10 | extern void fc3 (const NSString *) __attribute__((format_arg(1, 2))); // expected-error {{'format_arg' attribute takes one argument}} |
Fariborz Jahanian | f1c2502 | 2009-05-20 17:41:43 +0000 | [diff] [blame] | 11 | |
Aaron Ballman | 853273f | 2015-11-04 16:09:04 +0000 | [diff] [blame] | 12 | struct s1 { int i; } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to non-K&R-style functions}} |
| 13 | union u1 { int i; } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to non-K&R-style functions}} |
| 14 | enum e1 { E1V0 } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to non-K&R-style functions}} |
Fariborz Jahanian | f1c2502 | 2009-05-20 17:41:43 +0000 | [diff] [blame] | 15 | |
| 16 | extern NSString *ff3 (const NSString *) __attribute__((format_arg(3-2))); |
Douglas Gregor | d2472d4 | 2013-05-02 23:25:32 +0000 | [diff] [blame] | 17 | extern NSString *ff4 (const NSString *) __attribute__((format_arg(foo))); // expected-error {{use of undeclared identifier 'foo'}} |
Fariborz Jahanian | f1c2502 | 2009-05-20 17:41:43 +0000 | [diff] [blame] | 18 | |
| 19 | /* format_arg formats must take and return a string. */ |
| 20 | extern NSString *fi0 (int) __attribute__((format_arg(1))); // expected-error {{format argument not a string type}} |
| 21 | extern NSString *fi1 (NSString *) __attribute__((format_arg(1))); |
| 22 | |
| 23 | extern NSString *fi2 (NSString *) __attribute__((format_arg(1))); |
| 24 | |
| 25 | extern int fi3 (const NSString *) __attribute__((format_arg(1))); // expected-error {{function does not return NSString}} |
| 26 | extern NSString *fi4 (const NSString *) __attribute__((format_arg(1))); |
| 27 | extern NSString *fi5 (const NSString *) __attribute__((format_arg(1))); |