re PR c/89525 (inform messages from -Wbuiltin-declaration-mismatch even with -w)
authorJakub Jelinek <jakub@redhat.com>
Thu, 28 Feb 2019 07:17:49 +0000 (08:17 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 28 Feb 2019 07:17:49 +0000 (08:17 +0100)
PR c/89525
* c-typeck.c (convert_arguments): Call inform_declaration only if
the previous warning_at call returned true.

* gcc.dg/pr89525.c: New test.

From-SVN: r269274

gcc/c/ChangeLog
gcc/c/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr89525.c [new file with mode: 0644]

index 6b26ca0f9b3f99bc9dfcbcdf9a6c4ade45b5c374..ec60ed3b81a55225cfdd3cb989c1758de47a699e 100644 (file)
@@ -1,3 +1,9 @@
+2019-02-28  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/89525
+       * c-typeck.c (convert_arguments): Call inform_declaration only if
+       the previous warning_at call returned true.
+
 2019-02-22  Thomas Schwinge  <thomas@codesourcery.com>
 
        * c-parser.c (c_parser_oacc_shape_clause): Add loc formal
index 48112006f04d37763a378dfd2d4d6b5c66d60b44..2de4d0f85fdf47698034d4bbe83d38d31cf332a0 100644 (file)
@@ -3509,12 +3509,10 @@ convert_arguments (location_t loc, vec<location_t> arg_loc, tree typelist,
 
       if (builtin_type == void_type_node)
        {
-         warning_at (loc, OPT_Wbuiltin_declaration_mismatch,
-                     "too many arguments to built-in function %qE "
-                     "expecting %d",
-                     function, parmnum);
-
-         inform_declaration (fundecl);
+         if (warning_at (loc, OPT_Wbuiltin_declaration_mismatch,
+                         "too many arguments to built-in function %qE "
+                         "expecting %d", function, parmnum))
+           inform_declaration (fundecl);
          builtin_typetail = NULL_TREE;
        }
 
@@ -3651,10 +3649,10 @@ convert_arguments (location_t loc, vec<location_t> arg_loc, tree typelist,
       for (tree t = builtin_typetail; t; t = TREE_CHAIN (t))
        ++nargs;
 
-      warning_at (loc, OPT_Wbuiltin_declaration_mismatch,
-                 "too few arguments to built-in function %qE expecting %u",
-                 function, nargs - 1);
-      inform_declaration (fundecl);
+      if (warning_at (loc, OPT_Wbuiltin_declaration_mismatch,
+                     "too few arguments to built-in function %qE "
+                     "expecting %u", function, nargs - 1))
+       inform_declaration (fundecl);
     }
 
   return error_args ? -1 : (int) parmnum;
index 21642dec1c1f86641e64af0518e01d246bc599d8..c711829816ec2fb9f63036f6443f961956d06b65 100644 (file)
@@ -1,5 +1,8 @@
 2019-02-28  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c/89525
+       * gcc.dg/pr89525.c: New test.
+
        PR c/89520
        * gcc.dg/pr89520-1.c: New test.
        * gcc.dg/pr89520-2.c: New test.
diff --git a/gcc/testsuite/gcc.dg/pr89525.c b/gcc/testsuite/gcc.dg/pr89525.c
new file mode 100644 (file)
index 0000000..099e174
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR c/89525 */
+/* { dg-do compile } */
+/* { dg-options "-w" } */
+
+double sqrt ();        /* { dg-bogus "declared here" } */
+
+void
+foo (void)
+{
+  sqrt ();
+}