aboutsummaryrefslogtreecommitdiff
path: root/test/Sema/format-attribute.c
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-03-07 18:43:49 +0000
committerTed Kremenek <kremenek@apple.com>2008-03-07 18:43:49 +0000
commitaa8f976111e75427fa41e0f84b78fe086ce0f4e6 (patch)
tree2c1aa2f2f279703f515f629b194b41726ffac72a /test/Sema/format-attribute.c
parent843e934ba8c6ebc00d2f6969a50af7074597e8e3 (diff)
Patch by Nuno Lopes:
Added more comments for code processing attribute "format". Added more checks for corner cases, test cases, and warnings. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48011 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/format-attribute.c')
-rw-r--r--test/Sema/format-attribute.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/Sema/format-attribute.c b/test/Sema/format-attribute.c
new file mode 100644
index 0000000000..0b166e3c4d
--- /dev/null
+++ b/test/Sema/format-attribute.c
@@ -0,0 +1,16 @@
+//RUN: clang -fsyntax-only -verify %s
+
+#include <stdarg.h>
+
+void a(const char *a, ...) __attribute__((format(printf, 1,2))); // no-error
+void b(const char *a, ...) __attribute__((format(printf, 1,1))); // expected-error {{'format' attribute parameter 3 is out of bounds}}
+void c(const char *a, ...) __attribute__((format(printf, 0,2))); // expected-error {{'format' attribute parameter 2 is out of bounds}}
+void d(const char *a, int c) __attribute__((format(printf, 1,2))); // expected-error {{format attribute requires variadic function}}
+void e(char *str, int c, ...) __attribute__((format(printf, 2,3))); // expected-error {{format argument not a string type}}
+
+typedef const char* xpto;
+void f(xpto c, va_list list) __attribute__((format(printf, 1, 0))); // no-error
+void g(xpto c) __attribute__((format(printf, 1, 0))); // no-error
+
+void y(char *str) __attribute__((format(strftime, 1,0))); // no-error
+void z(char *str, int c, ...) __attribute__((format(strftime, 1,2))); // expected-error {{strftime format attribute requires 3rd parameter to be 0}}