Update on format attribute handling.
- Remove the printf0 special handling as we treat it as printf anyway.
- Perform basic checks (non-literal, empty) for all formats and not only printf/scanf.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149236 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c
index 9daaf3b..341fd59 100644
--- a/test/Sema/format-strings.c
+++ b/test/Sema/format-strings.c
@@ -480,3 +480,14 @@
printf("%Lx", x); // no-warning
printf("%Ls", "hello"); // expected-warning {{length modifier 'L' results in undefined behavior or no effect with 's' conversion specifier}}
}
+
+void __attribute__((format(strfmon,1,2))) monformat(const char *fmt, ...);
+void __attribute__((format(strftime,1,0))) dateformat(const char *fmt);
+
+// Other formats
+void test_other_formats() {
+ char *str = "";
+ monformat("", 1); // expected-warning{{format string is empty}}
+ dateformat(""); // expected-warning{{format string is empty}}
+ dateformat(str); // expected-warning{{format string is not a string literal (potentially insecure)}}
+}
diff --git a/test/SemaObjC/format-strings-objc.m b/test/SemaObjC/format-strings-objc.m
index b0c87fe..e130b18 100644
--- a/test/SemaObjC/format-strings-objc.m
+++ b/test/SemaObjC/format-strings-objc.m
@@ -97,7 +97,7 @@
printf(s2); // expected-warning {{more '%' conversions than data arguments}}
const char * const s3 = (const char *)0;
- printf(s3); // expected-warning {{format string is not a string literal}}
+ printf(s3); // no-warning (NULL is a valid format string)
NSString * const ns1 = @"constant string %s"; // expected-note {{format string is defined here}}
NSLog(ns1); // expected-warning {{more '%' conversions than data arguments}}