diff options
author | Ryan Flynn <pizza@parseerror.com> | 2009-08-06 03:00:50 +0000 |
---|---|---|
committer | Ryan Flynn <pizza@parseerror.com> | 2009-08-06 03:00:50 +0000 |
commit | 4403a5e1f956fa86d515492dbe7c7a2817d8780d (patch) | |
tree | 0a35faeffe2d9d92159c224b28961b39adb6bf9f /test/Sema/format-attribute-printf0.c | |
parent | 67d1a67f3db2f1aa69083c5c94164d6e0ee05b32 (diff) |
add support for FreeBSD's format(printf0,x,y) attribute; allows null format string.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78276 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/format-attribute-printf0.c')
-rw-r--r-- | test/Sema/format-attribute-printf0.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/Sema/format-attribute-printf0.c b/test/Sema/format-attribute-printf0.c new file mode 100644 index 0000000000..fa7eafd52f --- /dev/null +++ b/test/Sema/format-attribute-printf0.c @@ -0,0 +1,26 @@ +//RUN: clang-cc -fsyntax-only -verify %s + +#include <stdarg.h> + +// same as format(printf(...))... +void a2(const char *a, ...) __attribute__((format(printf0, 1,2))); // no-error +void b2(const char *a, ...) __attribute__((format(printf0, 1,1))); // expected-error {{'format' attribute parameter 3 is out of bounds}} +void c2(const char *a, ...) __attribute__((format(printf0, 0,2))); // expected-error {{'format' attribute parameter 2 is out of bounds}} +void d2(const char *a, int c) __attribute__((format(printf0, 1,2))); // expected-error {{format attribute requires variadic function}} +void e2(char *str, int c, ...) __attribute__((format(printf0, 2,3))); // expected-error {{format argument not a string type}} + +// FreeBSD usage +#define __printf0like(fmt,va) __attribute__((__format__(__printf0__,fmt,va))) +void null(int i, const char *a, ...) __printf0like(2,0); // no-error +void null(int i, const char *a, ...) { + if (a) + (void)0/* vprintf(...) would go here */; +} + +void callnull(void){ + null(0, 0); // no error + null(0, (char*)0); // no error + null(0, (void*)0); // no error + null(0, (int*)0); // expected-warning {{incompatible pointer types}} +} + |