[clang] Selectively ena/disa-ble format-insufficient-args warning
Differential Revision: https://reviews.llvm.org/D87176
This commit is contained in:
@@ -239,6 +239,7 @@ def ExtraSemi : DiagGroup<"extra-semi", [CXX98CompatExtraSemi,
|
||||
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 FormatPedantic : DiagGroup<"format-pedantic">;
|
||||
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",
|
||||
|
||||
@@ -8921,7 +8921,7 @@ def note_array_declared_here : Note<
|
||||
"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<
|
||||
|
||||
@@ -9,6 +9,7 @@ CHECK-NEXT: -Wdelete-non-virtual-dtor
|
||||
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
|
||||
|
||||
11
clang/test/Sema/warn-printf-insufficient-data-args.c
Normal file
11
clang/test/Sema/warn-printf-insufficient-data-args.c
Normal file
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user