aboutsummaryrefslogtreecommitdiff
path: root/test/Sema/format-strings.c
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-29 04:59:47 +0000
committerChris Lattner <sabre@nondot.org>2009-04-29 04:59:47 +0000
commit655f141f4d4c92eeebcc880211313e84c0a8b2f2 (patch)
tree40146d7fac51b0d0748d3ea166162da38e57ea75 /test/Sema/format-strings.c
parent1cd3e1f72c3a1c256fb6a5c3d4512bca1f1b751d (diff)
implement -Wformat-security properly, which is enabled by default.
This enables one specific class of non-literal format warnings. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70368 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/format-strings.c')
-rw-r--r--test/Sema/format-strings.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c
index c7392c1f0c..50903b0cf8 100644
--- a/test/Sema/format-strings.c
+++ b/test/Sema/format-strings.c
@@ -113,3 +113,15 @@ void test_constant_bindings(void) {
printf(s4); // expected-warning{{not a string literal}}
printf(s5); // expected-warning{{not a string literal}}
}
+
+
+// Test what happens when -Wformat-security only.
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+#pragma GCC diagnostic warning "-Wformat-security"
+
+void test9(char *P) {
+ int x;
+ printf(P); // expected-warning {{format string is not a string literal (potentially insecure)}}
+ printf(P, 42);
+ printf("%n", &x); // expected-warning {{use of '%n' in format string discouraged }}
+}