]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c: avoid double-negative in warning message [PR94370]
authorDavid Malcolm <dmalcolm@redhat.com>
Tue, 26 Nov 2024 15:39:48 +0000 (10:39 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Tue, 26 Nov 2024 15:39:48 +0000 (10:39 -0500)
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 <dmalcolm@redhat.com>
gcc/c/c-typeck.cc
gcc/testsuite/gcc.dg/format/proto.c

index a23d83bf41fed02d4c29da24351d2d5ecb1880e2..f465123bfab02a24850b07b5894df3fe8865cee3 100644 (file)
@@ -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);
index 2556400b10c4d10883a951ee095933a180bf217c..f29e331c814448ef5fda78aca1b4c0913160ff72 100644 (file)
@@ -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" }