Fix printf format string checking for '%lc' (which expects a wint_t or compatible argument). Fixes PR 7981.
llvm-svn: 111978
diff --git a/clang/test/Sema/format-strings.c b/clang/test/Sema/format-strings.c
index 080e4db..2325454 100644
--- a/clang/test/Sema/format-strings.c
+++ b/clang/test/Sema/format-strings.c
@@ -286,3 +286,18 @@
printf("%-0f", 1.23); // expected-warning{{flag '0' is ignored when flag '-' is present}}
printf("%-+f", 1.23); // no-warning
}
+
+// PR 7981 - handle '%lc' (wint_t)
+#ifndef wint_t
+typedef int __darwin_wint_t;
+typedef __darwin_wint_t wint_t;
+#endif
+
+void pr7981(wint_t c, wchar_t c2) {
+ printf("%lc", c); // no-warning
+ printf("%lc", 1.0); // expected-warning{{the argument has type 'double'}}
+ printf("%lc", (char) 1); // no-warning
+ printf("%lc", &c); // expected-warning{{the argument has type 'wint_t *' (aka 'int *')}}
+ printf("%lc", c2); // no-warning
+}
+