summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/format-strings.c
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2016-09-14 20:20:14 +0000
committerStephen Hines <srhines@google.com>2016-09-14 20:20:14 +0000
commit6a17e5158e0da4ccf5b2c95336bcae7f3fbc8dc1 (patch)
tree3d16a6fe9f81a60c428cd3dd9a76fd05a4061758 /clang/test/Sema/format-strings.c
parentc0899b961a5fa73ae9b594ef0e47302e811482bd (diff)
downloadbcm5719-llvm-6a17e5158e0da4ccf5b2c95336bcae7f3fbc8dc1.tar.gz
bcm5719-llvm-6a17e5158e0da4ccf5b2c95336bcae7f3fbc8dc1.zip
Revert "Do not warn about format strings that are indexed string literals."
Summary: This reverts r281527 because I messed up the attribution. Reviewers: srhines Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24579 llvm-svn: 281530
Diffstat (limited to 'clang/test/Sema/format-strings.c')
-rw-r--r--clang/test/Sema/format-strings.c35
1 files changed, 0 insertions, 35 deletions
diff --git a/clang/test/Sema/format-strings.c b/clang/test/Sema/format-strings.c
index a6b3a699364..5559710c603 100644
--- a/clang/test/Sema/format-strings.c
+++ b/clang/test/Sema/format-strings.c
@@ -652,38 +652,3 @@ void test_format_security_pos(char* string) {
// expected-note@-1{{treat the string as an argument to avoid this}}
}
#pragma GCC diagnostic warning "-Wformat-nonliteral"
-
-void test_char_pointer_arithmetic(int b) {
- const char s1[] = "string";
- const char s2[] = "%s string";
-
- printf(s1 - 1); // expected-warning {{format string is not a string literal (potentially insecure)}}
- // expected-note@-1{{treat the string as an argument to avoid this}}
-
- printf(s1 + 2); // no-warning
- printf(s2 + 2); // no-warning
-
- const char s3[] = "%s string";
- printf((s3 + 2) - 2); // expected-warning{{more '%' conversions than data arguments}}
- // expected-note@-2{{format string is defined here}}
- printf(2 + s2); // no-warning
- printf(6 + s2 - 2); // no-warning
- printf(2 + (b ? s1 : s2)); // no-warning
-
- const char s5[] = "string %s";
- printf(2 + (b ? s2 : s5)); // expected-warning{{more '%' conversions than data arguments}}
- // expected-note@-2{{format string is defined here}}
- printf(2 + (b ? s2 : s5), ""); // no-warning
- printf(2 + (b ? s1 : s2 - 2), ""); // no-warning
-
- const char s6[] = "%s string";
- printf(2 + (b ? s1 : s6 - 2)); // expected-warning{{more '%' conversions than data arguments}}
- // expected-note@-2{{format string is defined here}}
- printf(1 ? s2 + 2 : s2); // no-warning
- printf(0 ? s2 : s2 + 2); // no-warning
- printf(2 + s2 + 5 * 3 - 16, ""); // expected-warning{{data argument not used}}
-
- const char s7[] = "%s string %s %s";
- printf(s7 + 3, ""); // expected-warning{{more '%' conversions than data arguments}}
- // expected-note@-2{{format string is defined here}}
-}
OpenPOWER on IntegriCloud