From e711f7052e47be6daee85137e23b6c28857b9f05 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Sat, 14 Feb 2009 18:57:46 +0000 Subject: 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 --- clang/test/Sema/format-strings.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'clang/test/Sema/format-strings.c') 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 +} -- cgit v1.2.3