blob: 264e7a8179dab1f782e823881f426ef468170704 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -verify -fsyntax-only %s
Fariborz Jahanian5b160922009-05-20 17:41:43 +00002
3@class NSString;
4
5extern NSString *fa2 (const NSString *) __attribute__((format_arg(1)));
6extern NSString *fa3 (NSString *) __attribute__((format_arg(1)));
7
8extern void fc1 (const NSString *) __attribute__((format_arg)); // expected-error {{attribute requires 1 argument(s)}}
9extern void fc2 (const NSString *) __attribute__((format_arg())); // expected-error {{attribute requires 1 argument(s)}}
10extern void fc3 (const NSString *) __attribute__((format_arg(1, 2))); // expected-error {{attribute requires 1 argument(s)}}
11
12struct s1 { int i; } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to function types}}
13union u1 { int i; } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to function types}}
Daniel Dunbar2aa94442009-08-08 15:47:00 +000014enum e1 { E1V0 } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to function types}}
Fariborz Jahanian5b160922009-05-20 17:41:43 +000015
16extern NSString *ff3 (const NSString *) __attribute__((format_arg(3-2)));
17extern NSString *ff4 (const NSString *) __attribute__((format_arg(foo))); // expected-error {{attribute requires 1 argument(s)}}
18
19/* format_arg formats must take and return a string. */
20extern NSString *fi0 (int) __attribute__((format_arg(1))); // expected-error {{format argument not a string type}}
21extern NSString *fi1 (NSString *) __attribute__((format_arg(1)));
22
23extern NSString *fi2 (NSString *) __attribute__((format_arg(1)));
24
25extern int fi3 (const NSString *) __attribute__((format_arg(1))); // expected-error {{function does not return NSString}}
26extern NSString *fi4 (const NSString *) __attribute__((format_arg(1)));
27extern NSString *fi5 (const NSString *) __attribute__((format_arg(1)));