[C PATCH] Fix -Wbuiltin-declaration-mismatch (PR c/89525)
Jakub Jelinek
jakub@redhat.com
Wed Feb 27 23:48:00 GMT 2019
Hi!
As the following testcase shows, with -w we don't emit
-Wbuiltin-declaration-mismatch warnings (correct), but emit weird messages:
~/src/gcc/obj46/gcc/xgcc -B ~/src/gcc/obj46/gcc/ -w pr89525.c -S
pr89525.c: In function âfooâ:
pr89525.c:5:8: note: declared here
5 | double sqrt (); /* { dg-bogus "declared here" } */
| ^~~~
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?
2019-02-27 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.
* gcc.dg/pr89525.c: New test.
--- gcc/c/c-typeck.c.jj 2019-01-24 20:15:16.913439861 +0100
+++ gcc/c/c-typeck.c 2019-02-27 21:33:37.815873072 +0100
@@ -3509,12 +3509,10 @@ convert_arguments (location_t loc, vec<l
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<l
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;
--- gcc/testsuite/gcc.dg/pr89525.c.jj 2019-02-27 21:34:45.863757616 +0100
+++ gcc/testsuite/gcc.dg/pr89525.c 2019-02-27 21:34:24.232112209 +0100
@@ -0,0 +1,11 @@
+/* PR c/89525 */
+/* { dg-do compile } */
+/* { dg-options "-w" } */
+
+double sqrt (); /* { dg-bogus "declared here" } */
+
+void
+foo (void)
+{
+ sqrt ();
+}
Jakub
More information about the Gcc-patches
mailing list