Hello, The following is a patch for the PR92209,which gives a warning when the function prototype does not specify its argument type.In this patch there has been a change in the warning message displayed for -Wstrict-prototypes to specify its argument types.I have also added the testcase for it. Regtested on x86_64,OK for commit? Please do review it.
2022-03-11 Krishna Narayanan <krishnanarayanan132...@gmail.com> PR c/92209 gcc/c/ *c-decl.cc (start_function): Fixed the warning message for -Wstrict-prototypes. gcc/testsuite/Changelog: *gcc.dg/pr92209.c: New test *gcc.dg/pr20368-1.c: Updated warning message --- gcc/c/c-decl.cc | 4 ++-- gcc/testsuite/gcc.dg/pr20368-1.c | 2 +- gcc/testsuite/gcc.dg/pr92209.c | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr92209.c diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc index c701f07be..1983ffb23 100644 --- a/gcc/c/c-decl.cc +++ b/gcc/c/c-decl.cc @@ -7858,7 +7858,7 @@ grokparms (struct c_arg_info *arg_info, bool funcdef_flag) if (arg_types == NULL_TREE && !funcdef_flag && !in_system_header_at (input_location)) warning (OPT_Wstrict_prototypes, - "function declaration isn%'t a prototype"); + "a function prototype must specify the argument types"); if (arg_types == error_mark_node) /* Don't set TYPE_ARG_TYPES in this case. */ @@ -9625,7 +9625,7 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator, && !prototype_p (TREE_TYPE (decl1)) && C_DECL_ISNT_PROTOTYPE (old_decl)) warning_at (loc, OPT_Wstrict_prototypes, - "function declaration isn%'t a prototype"); + "a function prototype must specify the argument types"); /* Optionally warn of any global def with no previous prototype. */ else if (warn_missing_prototypes && old_decl != error_mark_node diff --git a/gcc/testsuite/gcc.dg/pr20368-1.c b/gcc/testsuite/gcc.dg/pr20368-1.c index 4140397c1..4b4914aa6 100644 --- a/gcc/testsuite/gcc.dg/pr20368-1.c +++ b/gcc/testsuite/gcc.dg/pr20368-1.c @@ -6,7 +6,7 @@ extern __typeof (f) g; /* { dg-error "'f' undeclared here \\(not in a function\\)" } */ int -f (x) /* { dg-warning "function declaration isn't a prototype" } */ +f (x) /* { dg-warning "a function prototype must specify the argument types" } */ float x; { } diff --git a/gcc/testsuite/gcc.dg/pr92209.c b/gcc/testsuite/gcc.dg/pr92209.c new file mode 100644 index 000000000..3fae57b49 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr92209.c @@ -0,0 +1,6 @@ +/*pr92209*/ +/* { dg-do compile } */ +/* { dg-options "-Wstrict-prototypes" } */ +static int func_1(); /* { dg-warning " a function prototype must specify the argument types" } */ +int func_1(int a) + { return a; } \ No newline at end of file -- 2.25.1