aboutsummaryrefslogtreecommitdiff
path: root/test/Sema/format-strings.c
diff options
context:
space:
mode:
authorJean-Daniel Dupas <devlists@shadowlab.org>2012-01-30 08:46:47 +0000
committerJean-Daniel Dupas <devlists@shadowlab.org>2012-01-30 08:46:47 +0000
commit34269df5db40b7c4b4f52aed579d9b3108ff79e4 (patch)
treea1f048182a96220952a7241a197ea410d00b5f0d /test/Sema/format-strings.c
parent79a64c7f8c501e3df4330db8f50a2dbc9877953b (diff)
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
Diffstat (limited to 'test/Sema/format-strings.c')
-rw-r--r--test/Sema/format-strings.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c
index 9daaf3b0a5..341fd59908 100644
--- a/test/Sema/format-strings.c
+++ b/test/Sema/format-strings.c
@@ -480,3 +480,14 @@ void printf_longlong(long long x, unsigned long long y) {
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)}}
+}