2014-02-08 03:25:10 +08:00
|
|
|
// RUN: %clang_cc1 -verify -fsyntax-only %s
|
2009-05-21 01:41:43 +08:00
|
|
|
|
|
|
|
@class NSString;
|
|
|
|
|
|
|
|
extern NSString *fa2 (const NSString *) __attribute__((format_arg(1)));
|
|
|
|
extern NSString *fa3 (NSString *) __attribute__((format_arg(1)));
|
|
|
|
|
2013-07-24 03:30:11 +08:00
|
|
|
extern void fc1 (const NSString *) __attribute__((format_arg)); // expected-error {{'format_arg' attribute takes one argument}}
|
|
|
|
extern void fc2 (const NSString *) __attribute__((format_arg())); // expected-error {{'format_arg' attribute takes one argument}}
|
|
|
|
extern void fc3 (const NSString *) __attribute__((format_arg(1, 2))); // expected-error {{'format_arg' attribute takes one argument}}
|
2009-05-21 01:41:43 +08:00
|
|
|
|
2015-11-05 00:09:04 +08:00
|
|
|
struct s1 { int i; } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to non-K&R-style functions}}
|
|
|
|
union u1 { int i; } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to non-K&R-style functions}}
|
|
|
|
enum e1 { E1V0 } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to non-K&R-style functions}}
|
2009-05-21 01:41:43 +08:00
|
|
|
|
|
|
|
extern NSString *ff3 (const NSString *) __attribute__((format_arg(3-2)));
|
2013-05-03 07:25:32 +08:00
|
|
|
extern NSString *ff4 (const NSString *) __attribute__((format_arg(foo))); // expected-error {{use of undeclared identifier 'foo'}}
|
2009-05-21 01:41:43 +08:00
|
|
|
|
|
|
|
/* format_arg formats must take and return a string. */
|
|
|
|
extern NSString *fi0 (int) __attribute__((format_arg(1))); // expected-error {{format argument not a string type}}
|
|
|
|
extern NSString *fi1 (NSString *) __attribute__((format_arg(1)));
|
|
|
|
|
|
|
|
extern NSString *fi2 (NSString *) __attribute__((format_arg(1)));
|
|
|
|
|
|
|
|
extern int fi3 (const NSString *) __attribute__((format_arg(1))); // expected-error {{function does not return NSString}}
|
|
|
|
extern NSString *fi4 (const NSString *) __attribute__((format_arg(1)));
|
|
|
|
extern NSString *fi5 (const NSString *) __attribute__((format_arg(1)));
|