From: Bob Wilson Date: Thu, 3 May 2012 23:38:51 +0000 (+0000) Subject: Add a test for r156092. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=927a57cb8fb4134dec68997a476d84a15b29f9a8;p=clang Add a test for r156092. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156132 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Sema/Inputs/format-unused-system-args.h b/test/Sema/Inputs/format-unused-system-args.h new file mode 100644 index 0000000000..3a6b1654fb --- /dev/null +++ b/test/Sema/Inputs/format-unused-system-args.h @@ -0,0 +1,8 @@ +// "System header" for testing that -Wformat-extra-args does not apply to +// arguments specified in system headers. + +#define PRINT2(fmt, a1, a2) \ + printf((fmt), (a1), (a2)) + +#define PRINT1(fmt, a1) \ + PRINT2((fmt), (a1), 0) diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c index 086c5c6d6f..7e968899ac 100644 --- a/test/Sema/format-strings.c +++ b/test/Sema/format-strings.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral %s +// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral -isystem %S/Inputs %s #include typedef __typeof(sizeof(int)) size_t; @@ -521,3 +521,10 @@ void test_other_formats() { dateformat(""); // expected-warning{{format string is empty}} dateformat(str); // no-warning (using strftime non literal is not unsafe) } + +// Do not warn about unused arguments coming from system headers. +// +#include +void test_unused_system_args(int x) { + PRINT1("%d\n", x); // no-warning{{extra argument is system header is OK}} +}