diff options
author | ed <ed@FreeBSD.org> | 2009-06-02 17:58:47 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2009-06-02 17:58:47 +0000 |
commit | f27e5a09a0d815b8a4814152954ff87dadfdefc0 (patch) | |
tree | ce7d964cbb5e39695b71481698f10cb099c23d4a /test/SemaObjC/format-arg-attribute.m | |
download | FreeBSD-src-f27e5a09a0d815b8a4814152954ff87dadfdefc0.zip FreeBSD-src-f27e5a09a0d815b8a4814152954ff87dadfdefc0.tar.gz |
Import Clang, at r72732.
Diffstat (limited to 'test/SemaObjC/format-arg-attribute.m')
-rw-r--r-- | test/SemaObjC/format-arg-attribute.m | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/SemaObjC/format-arg-attribute.m b/test/SemaObjC/format-arg-attribute.m new file mode 100644 index 0000000..60cc7cb --- /dev/null +++ b/test/SemaObjC/format-arg-attribute.m @@ -0,0 +1,28 @@ +// RUN: clang-cc -verify -fsyntax-only %s + +@class NSString; + +extern NSString *fa2 (const NSString *) __attribute__((format_arg(1))); +extern NSString *fa3 (NSString *) __attribute__((format_arg(1))); + +extern void fc1 (const NSString *) __attribute__((format_arg)); // expected-error {{attribute requires 1 argument(s)}} +extern void fc2 (const NSString *) __attribute__((format_arg())); // expected-error {{attribute requires 1 argument(s)}} +extern void fc3 (const NSString *) __attribute__((format_arg(1, 2))); // expected-error {{attribute requires 1 argument(s)}} + +struct s1 { int i; } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to function types}} +union u1 { int i; } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to function types}} +// FIXME: We don't flag this yet. +enum e1 { E1V0 } __attribute__((format_arg(1))); /* { dg-error "does not apply|only applies" "format_arg on enum" } */ + +extern NSString *ff3 (const NSString *) __attribute__((format_arg(3-2))); +extern NSString *ff4 (const NSString *) __attribute__((format_arg(foo))); // expected-error {{attribute requires 1 argument(s)}} + +/* 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))); |