aboutsummaryrefslogtreecommitdiff
path: root/test/SemaCXX/format-strings.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2012-02-10 19:13:51 +0000
committerTed Kremenek <kremenek@apple.com>2012-02-10 19:13:51 +0000
commite3d8e737e18f0ce95d87be03f74b35413443173c (patch)
treead436e17053c43ae627d18d72319be67a6a61508 /test/SemaCXX/format-strings.cpp
parent3ac109cd17151bb8ad3a40b0cbb0e1923cd6c4a0 (diff)
Enhance checking for null format string literal to take into account __null. Fixes <rdar://problem/8269537>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150260 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/format-strings.cpp')
-rw-r--r--test/SemaCXX/format-strings.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/SemaCXX/format-strings.cpp b/test/SemaCXX/format-strings.cpp
index 8b0b00d04e..456167dfc9 100644
--- a/test/SemaCXX/format-strings.cpp
+++ b/test/SemaCXX/format-strings.cpp
@@ -39,3 +39,14 @@ void h(int *i) {
printf(foo.gettext("%d"), i); // expected-warning{{format specifies type 'int' but the argument has type 'int *'}}
printf(Foo::gettext_static("%d"), i); // expected-warning{{format specifies type 'int' but the argument has type 'int *'}}
}
+
+// Test handling __null for format string literal checking.
+extern "C" {
+ int test_null_format(const char *format, ...) __attribute__((__format__ (__printf__, 1, 2)));
+}
+
+void rdar8269537(const char *f)
+{
+ test_null_format(__null); // no-warning
+ test_null_format(f); // expected-warning {{not a string literal}}
+}