From: David Malcolm Date: Tue, 26 Nov 2024 15:39:48 +0000 (-0500) Subject: c: avoid double-negative in warning message [PR94370] X-Git-Tag: basepoints/gcc-16~3853 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5134bad11b9a71f869abbb7f3d37b669c6ba138b;p=thirdparty%2Fgcc.git c: avoid double-negative in warning message [PR94370] gcc/c/ChangeLog: PR c/94370 * c-typeck.cc (c_build_functype_attribute_variant): Reword warning message to avoid double-negative. gcc/testsuite/ChangeLog: PR c/94370 * gcc.dg/format/proto.c: Update wording of message. Signed-off-by: David Malcolm --- diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index a23d83bf41fe..f465123bfab0 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -567,8 +567,8 @@ c_build_functype_attribute_variant (tree ntype, tree otype, tree attrs) && lookup_attribute ("format", attrs)) { warning_at (input_location, OPT_Wattributes, - "%qs attribute cannot be applied to a function that " - "does not take variable arguments", "format"); + "%qs attribute can only be applied to variadic functions", + "format"); attrs = remove_attribute ("format", attrs); } return c_build_type_attribute_variant (ntype, attrs); diff --git a/gcc/testsuite/gcc.dg/format/proto.c b/gcc/testsuite/gcc.dg/format/proto.c index 2556400b10c4..f29e331c8144 100644 --- a/gcc/testsuite/gcc.dg/format/proto.c +++ b/gcc/testsuite/gcc.dg/format/proto.c @@ -18,7 +18,7 @@ FMT (3, 4) void print3 (); FMT (3, 4) void print3 (); FMT (1, 2) void print4 (); - void print4 (void); // { dg-warning "'format' attribute cannot be applied to a function that does not take variable arguments" } + void print4 (void); // { dg-warning "'format' attribute can only be applied to variadic functions" } void print5 (); FMT (1, 2) void print5 (void); // { dg-warning "\\\[-Wattributes" } @@ -59,7 +59,7 @@ FMT (3, 4) void (*pfprint3)(); FMT (3, 4) void (*pfprint3)(); FMT (1, 2) void (*pfprint4)(); - void (*pfprint4)(void); // { dg-warning "'format' attribute cannot be applied to a function that does not take variable arguments" } + void (*pfprint4)(void); // { dg-warning "'format' attribute can only be applied to variadic functions" } void (*pfprint5)(); FMT (1, 2) void (*pfprint5)(void); // { dg-warning "\\\[-Wattributes" }