summaryrefslogtreecommitdiffstats
path: root/clang/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
commitcc5d1c2e4e8b874004715835982edf70de2ceff4 (patch)
tree7f89774b6127a1d04f51307ee25b83e4bb052325 /clang/test/Sema/format-strings.c
parente009a881eac3db71dd2664f547d5c64cff772cc5 (diff)
downloadbcm5719-llvm-cc5d1c2e4e8b874004715835982edf70de2ceff4.tar.gz
bcm5719-llvm-cc5d1c2e4e8b874004715835982edf70de2ceff4.zip
implement -Wformat-security properly, which is enabled by default.
This enables one specific class of non-literal format warnings. llvm-svn: 70368
Diffstat (limited to 'clang/test/Sema/format-strings.c')
-rw-r--r--clang/test/Sema/format-strings.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/test/Sema/format-strings.c b/clang/test/Sema/format-strings.c
index c7392c1f0c9..50903b0cf83 100644
--- a/clang/test/Sema/format-strings.c
+++ b/clang/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 }}
+}
OpenPOWER on IntegriCloud