[cfe-commits] r126096 - in /cfe/trunk: include/clang/Basic/DiagnosticGroups.td test/Sema/format-strings.c

Chandler Carruth chandlerc at gmail.com
Sun Feb 20 16:07:51 PST 2011


Author: chandlerc
Date: Sun Feb 20 18:07:51 2011
New Revision: 126096

URL: http://llvm.org/viewvc/llvm-project?rev=126096&view=rev
Log:
Allow -Wformat to be enabled without -Wformat-security. GCC gates
-Wformat-security on -Wformat, not vice-versa.

Fixes PR8486. Patch by Oleg Slezberg.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticGroups.td
    cfe/trunk/test/Sema/format-strings.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=126096&r1=126095&r2=126096&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Sun Feb 20 18:07:51 2011
@@ -198,9 +198,11 @@
                         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",

Modified: cfe/trunk/test/Sema/format-strings.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings.c?rev=126096&r1=126095&r2=126096&view=diff
==============================================================================
--- cfe/trunk/test/Sema/format-strings.c (original)
+++ cfe/trunk/test/Sema/format-strings.c Sun Feb 20 18:07:51 2011
@@ -340,3 +340,13 @@
   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'}}
+}





More information about the cfe-commits mailing list