[cfe-commits] r156132 - in /cfe/trunk/test/Sema: Inputs/format-unused-system-args.h format-strings.c

Bob Wilson bob.wilson at apple.com
Thu May 3 16:38:52 PDT 2012


Author: bwilson
Date: Thu May  3 18:38:51 2012
New Revision: 156132

URL: http://llvm.org/viewvc/llvm-project?rev=156132&view=rev
Log:
Add a test for r156092.

Added:
    cfe/trunk/test/Sema/Inputs/format-unused-system-args.h
Modified:
    cfe/trunk/test/Sema/format-strings.c

Added: cfe/trunk/test/Sema/Inputs/format-unused-system-args.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/Inputs/format-unused-system-args.h?rev=156132&view=auto
==============================================================================
--- cfe/trunk/test/Sema/Inputs/format-unused-system-args.h (added)
+++ cfe/trunk/test/Sema/Inputs/format-unused-system-args.h Thu May  3 18:38:51 2012
@@ -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)

Modified: cfe/trunk/test/Sema/format-strings.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings.c?rev=156132&r1=156131&r2=156132&view=diff
==============================================================================
--- cfe/trunk/test/Sema/format-strings.c (original)
+++ cfe/trunk/test/Sema/format-strings.c Thu May  3 18:38:51 2012
@@ -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 <stdarg.h>
 typedef __typeof(sizeof(int)) size_t;
@@ -521,3 +521,10 @@
   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.
+// <rdar://problem/11317765>
+#include <format-unused-system-args.h>
+void test_unused_system_args(int x) {
+  PRINT1("%d\n", x); // no-warning{{extra argument is system header is OK}}
+}





More information about the cfe-commits mailing list