https://gcc.gnu.org/g:5134bad11b9a71f869abbb7f3d37b669c6ba138b

commit r15-5700-g5134bad11b9a71f869abbb7f3d37b669c6ba138b
Author: David Malcolm <dmalc...@redhat.com>
Date:   Tue Nov 26 10:39:48 2024 -0500

    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 <dmalc...@redhat.com>

Diff:
---
 gcc/c/c-typeck.cc                   | 4 ++--
 gcc/testsuite/gcc.dg/format/proto.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

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" }

Reply via email to