summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2011-02-21 00:07:51 +0000
committerChandler Carruth <chandlerc@gmail.com>2011-02-21 00:07:51 +0000
commit468b5cbd40259b97807afdcdaf49f59353fb667c (patch)
treebde3d0741cdfa37b2231991497f38f062b091067
parent15fe190027a08806181a73ca74171633e1aacd51 (diff)
downloadbcm5719-llvm-468b5cbd40259b97807afdcdaf49f59353fb667c.tar.gz
bcm5719-llvm-468b5cbd40259b97807afdcdaf49f59353fb667c.zip
Allow -Wformat to be enabled without -Wformat-security. GCC gates
-Wformat-security on -Wformat, not vice-versa. Fixes PR8486. Patch by Oleg Slezberg. llvm-svn: 126096
-rw-r--r--clang/include/clang/Basic/DiagnosticGroups.td6
-rw-r--r--clang/test/Sema/format-strings.c10
2 files changed, 14 insertions, 2 deletions
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td
index d4377c9a0b0..412fb587108 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -198,9 +198,11 @@ def Unused : DiagGroup<"unused",
DiagCategory<"Unused Entity Issue">;
// Format settings.
-def Format : DiagGroup<"format", [FormatExtraArgs, FormatZeroLength, NonNull]>,
+def FormatSecurity : DiagGroup<"format-security">;
+def Format : DiagGroup<"format",
+ [FormatExtraArgs, FormatZeroLength, NonNull,
+ FormatSecurity]>,
DiagCategory<"Format String Issue">;
-def FormatSecurity : DiagGroup<"format-security", [Format]>;
def FormatNonLiteral : DiagGroup<"format-nonliteral", [FormatSecurity]>;
def FormatY2K : DiagGroup<"format-y2k", [Format]>;
def Format2 : DiagGroup<"format=2",
diff --git a/clang/test/Sema/format-strings.c b/clang/test/Sema/format-strings.c
index be506d7c6b1..fe4f4567cbd 100644
--- a/clang/test/Sema/format-strings.c
+++ b/clang/test/Sema/format-strings.c
@@ -340,3 +340,13 @@ void posix_extensions() {
printf("%'f\n", (float) 1.0); // no-warning
printf("%'p\n", (void*) 0); // expected-warning{{results in undefined behavior with 'p' conversion specifier}}
}
+
+// PR8486
+//
+// Test what happens when -Wformat is on, but -Wformat-security is off.
+#pragma GCC diagnostic warning "-Wformat"
+#pragma GCC diagnostic ignored "-Wformat-security"
+
+void pr8486() {
+ printf("%s", 1); // expected-warning{{conversion specifies type 'char *' but the argument has type 'int'}}
+}
OpenPOWER on IntegriCloud