summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/format-strings.c
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-02-14 18:57:46 +0000
committerDouglas Gregor <dgregor@apple.com>2009-02-14 18:57:46 +0000
commite711f7052e47be6daee85137e23b6c28857b9f05 (patch)
treeb87ddb4465918a765f6d440488f99bc811178494 /clang/test/Sema/format-strings.c
parent978f08d9b4852579b91a9bce765da4427f8aeedf (diff)
downloadbcm5719-llvm-e711f7052e47be6daee85137e23b6c28857b9f05.tar.gz
bcm5719-llvm-e711f7052e47be6daee85137e23b6c28857b9f05.zip
Add hook to add attributes to function declarations that we know
about, whether they are builtins or not. Use this to add the appropriate "format" attribute to NSLog, NSLogv, asprintf, and vasprintf, and to translate builtin attributes (from Builtins.def) into actual attributes on the function declaration. Use the "printf" format attribute on function declarations to determine whether we should do format string checking, rather than looking at an ad hoc list of builtins and "known" function names. Be a bit more careful about when we consider a function a "builtin" in C++. llvm-svn: 64561
Diffstat (limited to 'clang/test/Sema/format-strings.c')
-rw-r--r--clang/test/Sema/format-strings.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/test/Sema/format-strings.c b/clang/test/Sema/format-strings.c
index 9e558e93acf..707873feaf8 100644
--- a/clang/test/Sema/format-strings.c
+++ b/clang/test/Sema/format-strings.c
@@ -85,3 +85,9 @@ void check_asterisk_precision_width(int x) {
printf("%*d","foo",x); // expected-warning {{field width should have type 'int', but argument has type 'char *'}}
printf("%.*d","foo",x); // expected-warning {{field precision should have type 'int', but argument has type 'char *'}}
}
+
+void __attribute__((format(printf,1,3))) myprintf(const char*, int blah, ...);
+
+void test_myprintf() {
+ myprintf("%d", 17, 18); // okay
+}
OpenPOWER on IntegriCloud