1 // RUN: %clang_cc1 -verify -fsyntax-only %s
4 +(instancetype)stringWithCString:(const char *)cstr __attribute__((format_arg(1)));
5 -(instancetype)initWithString:(NSString *)str __attribute__((format_arg(1)));
7 +(instancetype _Nonnull)nonNullableString:(NSString *)str __attribute__((format_arg(1)));
8 +(instancetype _Nullable)nullableString:(NSString *)str __attribute__((format_arg(1)));
12 -(instancetype)maybeString:(const char *)cstr __attribute__((format_arg(1))); // expected-error {{function does not return string type}}
15 @class NSAttributedString;
17 extern NSString *fa2 (const NSString *) __attribute__((format_arg(1)));
18 extern NSString *fa3 (NSString *) __attribute__((format_arg(1)));
20 extern void fc1 (const NSString *) __attribute__((format_arg)); // expected-error {{'format_arg' attribute takes one argument}}
21 extern void fc2 (const NSString *) __attribute__((format_arg())); // expected-error {{'format_arg' attribute takes one argument}}
22 extern void fc3 (const NSString *) __attribute__((format_arg(1, 2))); // expected-error {{'format_arg' attribute takes one argument}}
24 struct s1 { int i; } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to Objective-C methods and non-K&R-style functions}}
25 union u1 { int i; } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to}}
26 enum e1 { E1V0 } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to}}
28 extern NSString *ff3 (const NSString *) __attribute__((format_arg(3-2)));
29 extern NSString *ff4 (const NSString *) __attribute__((format_arg(foo))); // expected-error {{use of undeclared identifier 'foo'}}
31 /* format_arg formats must take and return a string. */
32 extern NSString *fi0 (int) __attribute__((format_arg(1))); // expected-error {{format argument not a string type}}
33 extern NSString *fi1 (NSString *) __attribute__((format_arg(1)));
35 extern NSString *fi2 (NSString *) __attribute__((format_arg(1)));
37 extern int fi3 (const NSString *) __attribute__((format_arg(1))); // expected-error {{function does not return NSString}}
38 extern NSString *fi4 (const NSString *) __attribute__((format_arg(1)));
39 extern NSString *fi5 (const NSString *) __attribute__((format_arg(1)));
41 extern NSAttributedString *fattrs (const NSString *) __attribute__((format_arg(1)));