[PATCH] D87176: [clang] Enable selectively turning on/off format-insufficient-args warning

Jan Korous via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 28 16:25:10 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG1e86d637eb4f: [clang] Selectively ena/disa-ble format-insufficient-args warning (authored by jkorous).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87176/new/

https://reviews.llvm.org/D87176

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/Misc/warning-wall.c
  clang/test/Sema/warn-printf-insufficient-data-args.c


Index: clang/test/Sema/warn-printf-insufficient-data-args.c
===================================================================
--- /dev/null
+++ clang/test/Sema/warn-printf-insufficient-data-args.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify=WARNING-ON %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-format-insufficient-args -verify=WARNING-OFF %s
+
+
+int printf(const char * format, ...);
+
+int main(void) {
+  int patatino = 42;
+  printf("%i %i", patatino); // WARNING-ON-warning {{more '%' conversions than data arguments}}
+  // WARNING-OFF-no-diagnostics
+}
Index: clang/test/Misc/warning-wall.c
===================================================================
--- clang/test/Misc/warning-wall.c
+++ clang/test/Misc/warning-wall.c
@@ -9,6 +9,7 @@
 CHECK-NEXT:      -Wdelete-non-abstract-non-virtual-dtor
 CHECK-NEXT:      -Wdelete-abstract-non-virtual-dtor
 CHECK-NEXT:    -Wformat
+CHECK-NEXT:      -Wformat-insufficient-args
 CHECK-NEXT:      -Wformat-extra-args
 CHECK-NEXT:      -Wformat-zero-length
 CHECK-NEXT:      -Wnonnull
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8921,7 +8921,7 @@
   "array %0 declared here">;
 
 def warn_printf_insufficient_data_args : Warning<
-  "more '%%' conversions than data arguments">, InGroup<Format>;
+  "more '%%' conversions than data arguments">, InGroup<FormatInsufficientArgs>;
 def warn_printf_data_arg_not_used : Warning<
   "data argument not used by format string">, InGroup<FormatExtraArgs>;
 def warn_format_invalid_conversion : Warning<
Index: clang/include/clang/Basic/DiagnosticGroups.td
===================================================================
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -239,6 +239,7 @@
 def GNUFlexibleArrayInitializer : DiagGroup<"gnu-flexible-array-initializer">;
 def GNUFlexibleArrayUnionMember : DiagGroup<"gnu-flexible-array-union-member">;
 def GNUFoldingConstant : DiagGroup<"gnu-folding-constant">;
+def FormatInsufficientArgs : DiagGroup<"format-insufficient-args">;
 def FormatExtraArgs : DiagGroup<"format-extra-args">;
 def FormatZeroLength : DiagGroup<"format-zero-length">;
 
@@ -849,7 +850,8 @@
 def FormatTypeConfusion : DiagGroup<"format-type-confusion">;
 def Format : DiagGroup<"format",
                        [FormatExtraArgs, FormatZeroLength, NonNull,
-                        FormatSecurity, FormatY2K, FormatInvalidSpecifier]>,
+                        FormatSecurity, FormatY2K, FormatInvalidSpecifier,
+                        FormatInsufficientArgs]>,
              DiagCategory<"Format String Issue">;
 def FormatNonLiteral : DiagGroup<"format-nonliteral">;
 def Format2 : DiagGroup<"format=2",


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87176.294825.patch
Type: text/x-patch
Size: 2884 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200928/10f04dcf/attachment.bin>


More information about the cfe-commits mailing list