public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] c : Changed warning message for -Wstrict-prototypes [PR92209]
@ 2022-03-11 10:49 Krishna Narayanan
  2022-03-11 20:55 ` Joseph Myers
  0 siblings, 1 reply; 3+ messages in thread
From: Krishna Narayanan @ 2022-03-11 10:49 UTC (permalink / raw)
  To: gcc-patches

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  <krishnanarayanan132002@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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] c : Changed warning message for -Wstrict-prototypes [PR92209]
  2022-03-11 10:49 [PATCH] c : Changed warning message for -Wstrict-prototypes [PR92209] Krishna Narayanan
@ 2022-03-11 20:55 ` Joseph Myers
  2022-03-12  3:01   ` Eric Gallager
  0 siblings, 1 reply; 3+ messages in thread
From: Joseph Myers @ 2022-03-11 20:55 UTC (permalink / raw)
  To: Krishna Narayanan; +Cc: gcc-patches

On Fri, 11 Mar 2022, Krishna Narayanan via Gcc-patches wrote:

> 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.

Why do you think your proposed wording is better than the existing 
wording?  I think the existing wording is accurate and the proposed 
wording is inaccurate - "must specify the argument types" is not an 
accurate description of any requirement in the C language, using "must" at 
all generally seems questionable in the wording of a warning message.

Also, I don't think this change is anything to do with the PR you mention 
("Imprecise column number for -Wstrict-prototypes"), so it's wrong to 
mention that PR number in the proposed commit message.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] c : Changed warning message for -Wstrict-prototypes [PR92209]
  2022-03-11 20:55 ` Joseph Myers
@ 2022-03-12  3:01   ` Eric Gallager
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Gallager @ 2022-03-12  3:01 UTC (permalink / raw)
  To: Joseph Myers
  Cc: Krishna Narayanan, gcc-patches, Manuel López-Ibáñez

On Fri, Mar 11, 2022 at 3:55 PM Joseph Myers <joseph@codesourcery.com> wrote:
>
> On Fri, 11 Mar 2022, Krishna Narayanan via Gcc-patches wrote:
>
> > 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.
>
> Why do you think your proposed wording is better than the existing
> wording?  I think the existing wording is accurate and the proposed
> wording is inaccurate - "must specify the argument types" is not an
> accurate description of any requirement in the C language, using "must" at
> all generally seems questionable in the wording of a warning message.
>
> Also, I don't think this change is anything to do with the PR you mention
> ("Imprecise column number for -Wstrict-prototypes"), so it's wrong to
> mention that PR number in the proposed commit message.
>

The proposed wording comes from one of the comments in the mentioned
PR; see Manu's reply in comment #1:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92209#c1

> --
> Joseph S. Myers
> joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-03-12  3:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-11 10:49 [PATCH] c : Changed warning message for -Wstrict-prototypes [PR92209] Krishna Narayanan
2022-03-11 20:55 ` Joseph Myers
2022-03-12  3:01   ` Eric Gallager

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).