From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vk1-xa33.google.com (mail-vk1-xa33.google.com [IPv6:2607:f8b0:4864:20::a33]) by sourceware.org (Postfix) with ESMTPS id 10BD43858D33 for ; Mon, 20 Nov 2023 19:13:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 10BD43858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gwmail.gwu.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gwmail.gwu.edu ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 10BD43858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::a33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700507584; cv=none; b=oKp2XSGu4zo5u94WiD/48WA01UFvqWJT8BF2omdPjXCB/tD7ODW06TLdjNO9DdX2vqqgsL6oBmqSsPLHEgc98cVtOYR59AivMFkMSz6p/i7S67RKffRmtHgowl7jIaxiJdIKSLKESBtNB53AkjY2lEJtAptofjYBjyfHbY/XD4o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700507584; c=relaxed/simple; bh=I4AB7DE+EtAHTsQOny6XpfmkYcTqg4AvZYEEoqKhCF4=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=oF1boPvJiJ1oaxCFvLF93CvkezY8sTIeE9SHTgP1bI5BGSG462/z8xMw/SlrLC1z2tHVzFXc3t0WaKxEX9I2y0MCnAw+u0j2zu2yJCsC4nGFUnvlBx2tuddgnHBlVXxZ7mqeKkFiSJOZlS2QmRvaCjK/YiPfMhCu+AT7/7XufYc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-vk1-xa33.google.com with SMTP id 71dfb90a1353d-4af8f20034cso1689762e0c.3 for ; Mon, 20 Nov 2023 11:13:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gwmail.gwu.edu; s=google; t=1700507580; x=1701112380; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=z1PKnQDY7wrzLAsdO71lDWL9cubg5wMwHJB7adx6h1U=; b=QeMGLYQUSCUFKcs2pVmB5ti/9e6RIvKU7SeKXmoqTzza9oqUiSCmFIryD6Y6M2Xl9p 0oq76t+CjdSFMkdtCKgp1MiOe/V6csL7EjVdUgfaMxor+HOu296g+FNwVhgVHk01b6kx bJv9KQG+TUAHZXBCSFDzw7QVIPJVELQLJpPbqpXEkr5o9HvsM4U1HLlEJ/gDwv8XBDMb Qi2JtxRnXAhJN7SuOqluUb6N0sqOqKf3BEd5swOgMzxsQZ+OhrN5N93TrIAJmNGaticE hNnI+tm/EcAiDUFzxxnMTp2CrOSSAdHV4HQLN7SGOyxxZRyrVGOsuDgNRWIeQbQYIbGn uKDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700507580; x=1701112380; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z1PKnQDY7wrzLAsdO71lDWL9cubg5wMwHJB7adx6h1U=; b=fam2U0Fw17ZQUCAIHHsCiukwaseqhSQn7TU7Lqpjoqg9UuQzQ+vQ68v+nLMSbrLKz5 Mg+nhtHioqi+bt/xcwe/YdxGfEwo/haiM4E7acgumDvEvVp//FSgLng0588urHNtcaYM rlzZI7CdpZhyEZ9zduUMA21khvHZ7p1uqSFlfhZIIIOU0FbNyp7T13cpxhAU+4ywnIuF U6xRsriNOj2majMsZrzs8yNQKna6aNAa8SJcgofYrL/4iMuXQLNfEgvqY74eBjZoSqwK IVxXc98ch+VdBV446Afcrn+XYKOkkoMcnNeUD/D/pys+et47zOCA8nfI/N+4QhxeZz3U +3Gw== X-Gm-Message-State: AOJu0Yz3xgfjibytD3DmuxUwsCmEd03Sg7mCYg1jw7c9bfTKdU1TY8R+ UfGNDCDriOrkYbPYhuuMXIS6cmolie1M55VGzWC+3tvkS8byVDlE9po= X-Google-Smtp-Source: AGHT+IHU2Mx+2K8v/zgYQ26sivLUojihYEh/CJSyTtRk3GdMDKgWlPYlOsXxHJ+Tta8Yv+zYUgYT8wDhatDToKprR6o= X-Received: by 2002:a1f:de82:0:b0:49a:bff1:23 with SMTP id v124-20020a1fde82000000b0049abff10023mr6889744vkg.5.1700507579722; Mon, 20 Nov 2023 11:12:59 -0800 (PST) MIME-Version: 1.0 References: <700d70e4a2874645ddb67a8a335131d83b242e69.1700473918.git.fweimer@redhat.com> In-Reply-To: <700d70e4a2874645ddb67a8a335131d83b242e69.1700473918.git.fweimer@redhat.com> From: Eric Gallager Date: Mon, 20 Nov 2023 14:12:48 -0500 Message-ID: Subject: Re: [PATCH v3 11/11] c: Add new -Wdeclaration-missing-parameter-type permerror To: Florian Weimer Cc: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, Nov 20, 2023 at 4:58=E2=80=AFAM Florian Weimer = wrote: > > This used to be a warning, enabled by default, without its own option. Right, I meant to ask: why create a new option of -Wdeclaration-missing-parameter-type instead of reusing the existing -Wmissing-parameter-type for this? > > A subsequent change could improve diagnostics and provide spelling > hints for declarations like =E2=80=9Cvoid function (int32t);=E2=80=9D. > > gcc/c-family/ > > * c.opt (Wdeclaration-missing-parameter-type): New. > > gcc/c/ChangeLog: > > PR other/44209 > * c-decl.cc (grokparms): Issue permerror for > OPT_Wdeclaration_missing_parameter_type instead of a pedwarn. > > gcc/ChangeLog: > > * doc/invoke.texi (Warning Options): Document > -Wdeclaration-missing-parameter-type. > > gcc/testsuite/ChangeLog: > > * gcc.dg/permerror-default.c (missing_parameter_type): > Expect error. > * gcc.dg/permerror-fpermissive.c (missing_parameter_type): > Expect -Wdeclaration-missing-parameter-type warning. > * gcc.dg/permerror-gnu89-nopermissive.c (missing_parameter_type): > Expect -Wdeclaration-missing-parameter-type error. > * gcc.dg/permerror-gnu89-pedantic.c (missing_parameter_type): > Likewise. > * gcc.dg/permerror-gnu89.c (missing_parameter_type): > Expect -Wdeclaration-missing-parameter-type warning. > * gcc.dg/permerror-noerror.c: Add > -Wno-error=3Ddeclaration-missing-parameter-type to build flags. > (missing_parameter_type): Expect > -Wdeclaration-missing-parameter-type warning. > * gcc.dg/permerror-nowarning.c: Build with > -Wno-declaration-missing-parameter-type. Remove previously > expected warning. > * gcc.dg/permerror-fpermissive-nowarning.c: Likewise. > * gcc.dg/permerror-pedantic.c (missing_parameter_type): > Expect -Wdeclaration-missing-parameter-type error. > * gcc.dg/permerror-system.c (missing_parameter_type): > Likewise. > --- > gcc/c-family/c.opt | 4 ++++ > gcc/c/c-decl.cc | 6 ++++-- > gcc/doc/invoke.texi | 17 ++++++++++++++++- > gcc/testsuite/gcc.dg/permerror-default.c | 2 +- > .../gcc.dg/permerror-fpermissive-nowarning.c | 7 +------ > gcc/testsuite/gcc.dg/permerror-fpermissive.c | 2 +- > .../gcc.dg/permerror-gnu89-nopermissive.c | 2 +- > gcc/testsuite/gcc.dg/permerror-gnu89-pedantic.c | 2 +- > gcc/testsuite/gcc.dg/permerror-gnu89.c | 2 +- > gcc/testsuite/gcc.dg/permerror-noerror.c | 4 ++-- > gcc/testsuite/gcc.dg/permerror-nowarning.c | 7 +------ > gcc/testsuite/gcc.dg/permerror-pedantic.c | 2 +- > gcc/testsuite/gcc.dg/permerror-system.c | 2 ++ > 13 files changed, 36 insertions(+), 23 deletions(-) > > diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt > index b10c6057cd1..723e8c3e27b 100644 > --- a/gcc/c-family/c.opt > +++ b/gcc/c-family/c.opt > @@ -591,6 +591,10 @@ Wdeclaration-after-statement > C ObjC Var(warn_declaration_after_statement) Init(-1) Warning > Warn when a declaration is found after a statement. > > +Wdeclaration-missing-parameter-type > +C ObjC Var(warn_declaration_missing_parameter) Warning Init(1) > +Warn for missing parameter types in function declarations. > + > Wdelete-incomplete > C++ ObjC++ Var(warn_delete_incomplete) Init(1) Warning > Warn when deleting a pointer to incomplete type. > diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc > index d16958113a8..3d9bee54259 100644 > --- a/gcc/c/c-decl.cc > +++ b/gcc/c/c-decl.cc > @@ -8337,8 +8337,10 @@ grokparms (struct c_arg_info *arg_info, bool funcd= ef_flag) > { > if (!funcdef_flag) > { > - pedwarn (input_location, 0, "parameter names (without types) in= " > - "function declaration"); > + permerror_opt (input_location, > + OPT_Wdeclaration_missing_parameter_type, > + "parameter names (without types) in " > + "function declaration"); > arg_info->parms =3D NULL_TREE; > } > else > diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi > index be33da71c44..7f5da45dcea 100644 > --- a/gcc/doc/invoke.texi > +++ b/gcc/doc/invoke.texi > @@ -504,7 +504,8 @@ Objective-C and Objective-C++ Dialects}. > > @item C and Objective-C-only Warning Options > @gccoptlist{-Wbad-function-cast -Wmissing-declarations > --Wmissing-parameter-type -Wmissing-prototypes -Wmissing-variable-declara= tions > +-Wmissing-parameter-type -Wdeclaration-missing-parameter-type > +-Wmissing-prototypes -Wmissing-variable-declarations > -Wnested-externs -Wold-style-declaration -Wold-style-definition > -Wstrict-prototypes -Wtraditional -Wtraditional-conversion > -Wdeclaration-after-statement -Wpointer-sign} > @@ -9734,6 +9735,20 @@ void foo(bar) @{ @} > > This warning is also enabled by @option{-Wextra}. > > +@opindex Wno-declaration-missing-parameter-type > +@opindex Wdeclaration-missing-parameter-type > +@item -Wno-declaration-missing-parameter-type @r{(C and Objective-C only= )} > +Do not warn if a function declaration contains a parameter name without > +a type. Such function declarations do not provide a function prototype > +and prevent most type checking in function calls. > + > +This warning is enabled by default. In C99 and later dialects of C, it > +is treated as an error. The error can be downgraded to a warning using > +@option{-fpermissive} (along with certain other errors), or for this > +error alone, with @option{-Wno-error=3Ddeclaration-missing-parameter-typ= e}. > + > +This warning is upgraded to an error by @option{-pedantic-errors}. > + > @opindex Wmissing-prototypes > @opindex Wno-missing-prototypes > @item -Wmissing-prototypes @r{(C and Objective-C only)} > diff --git a/gcc/testsuite/gcc.dg/permerror-default.c b/gcc/testsuite/gcc= .dg/permerror-default.c > index 45b58b0131d..c674d689081 100644 > --- a/gcc/testsuite/gcc.dg/permerror-default.c > +++ b/gcc/testsuite/gcc.dg/permerror-default.c > @@ -19,7 +19,7 @@ implicit_int_4 (i) /* { dg-error "return type defaults = to 'int' \\\[-Wimplicit-i > (const) 0; /* { dg-error "type defaults to 'int' in type name \\\[-Wim= plicit-int\\\]" } */ > } > > -extern int missing_parameter_type (i); /* { dg-warning "parameter names = \\\(without types\\\) in function declaration\n" } */ > +extern int missing_parameter_type (i); /* { dg-error "parameter names \\= \(without types\\\) in function declaration \\\[-Wdeclaration-missing-param= eter-type\\\]" } */ > > > int * > diff --git a/gcc/testsuite/gcc.dg/permerror-fpermissive-nowarning.c b/gcc= /testsuite/gcc.dg/permerror-fpermissive-nowarning.c > index f15b21ef43d..d07c8636677 100644 > --- a/gcc/testsuite/gcc.dg/permerror-fpermissive-nowarning.c > +++ b/gcc/testsuite/gcc.dg/permerror-fpermissive-nowarning.c > @@ -1,11 +1,6 @@ > -/* { dg-options "-fpermissive -Wno-implicit-function-declaration -Wno-im= plicit-int -Wno-int-conversion -Wno-incompatible-pointer-types -Wno-return-= mismatch" } */ > +/* { dg-options "-fpermissive -Wno-implicit-function-declaration -Wno-im= plicit-int -Wno-int-conversion -Wno-incompatible-pointer-types -Wno-return-= mismatch -Wno-declaration-missing-parameter-type" } */ > > /* This test checks that permerrors can be disabled using -Wno-* options= even > if -fpermissive is used. */ > > #include "permerror-default.c" > - > -/* Ideally, we do not want to see any warnings here, but this warning is= not > - yet controlled by its own option. */ > - > -/* { dg-warning "parameter names \\\(without types\\\) in function decla= ration\n" "" { target *-*-* } 22 } */ > diff --git a/gcc/testsuite/gcc.dg/permerror-fpermissive.c b/gcc/testsuite= /gcc.dg/permerror-fpermissive.c > index 139f35ad1c0..fd3020d75ee 100644 > --- a/gcc/testsuite/gcc.dg/permerror-fpermissive.c > +++ b/gcc/testsuite/gcc.dg/permerror-fpermissive.c > @@ -19,7 +19,7 @@ implicit_int_4 (i) /* { dg-warning "return type default= s to 'int' \\\[-Wimplicit > (const) 0; /* { dg-warning "type defaults to 'int' in type name \\\[-W= implicit-int\\\]" } */ > } > > -extern int missing_parameter_type (i); /* { dg-warning "parameter names = \\\(without types\\\) in function declaration\n" } */ > +extern int missing_parameter_type (i); /* { dg-warning "parameter names = \\\(without types\\\) in function declaration \\\[-Wdeclaration-missing-par= ameter-type\\\]" } */ > > > int * > diff --git a/gcc/testsuite/gcc.dg/permerror-gnu89-nopermissive.c b/gcc/te= stsuite/gcc.dg/permerror-gnu89-nopermissive.c > index 93504b94139..aba4b2498f7 100644 > --- a/gcc/testsuite/gcc.dg/permerror-gnu89-nopermissive.c > +++ b/gcc/testsuite/gcc.dg/permerror-gnu89-nopermissive.c > @@ -19,7 +19,7 @@ implicit_int_4 (i) /* { dg-bogus "-Wimplicit-int" } */ > (const) 0; /* { dg-bogus "-Wimplicit-int" } */ > } > > -extern int missing_parameter_type (i); /* { dg-warning "parameter names = \\\(without types\\\) in function declaration\n" } */ > +extern int missing_parameter_type (i); /* { dg-error "parameter names \\= \(without types\\\) in function declaration \\\[-Wdeclaration-missing-param= eter-type\\\]" } */ > > > int * > diff --git a/gcc/testsuite/gcc.dg/permerror-gnu89-pedantic.c b/gcc/testsu= ite/gcc.dg/permerror-gnu89-pedantic.c > index 465a16f5f9a..ef4dbfc86c5 100644 > --- a/gcc/testsuite/gcc.dg/permerror-gnu89-pedantic.c > +++ b/gcc/testsuite/gcc.dg/permerror-gnu89-pedantic.c > @@ -19,7 +19,7 @@ implicit_int_4 (i) /* { dg-bogus "-Wimplicit-int" } */ > (const) 0; /* { dg-bogus "-Wimplicit-int" } */ > } > > -extern int missing_parameter_type (i); /* { dg-error "parameter names \\= \(without types\\\) in function declaration\n" } */ > +extern int missing_parameter_type (i); /* { dg-error "parameter names \\= \(without types\\\) in function declaration \\\[-Wdeclaration-missing-param= eter-type\\\]" } */ > > > int * > diff --git a/gcc/testsuite/gcc.dg/permerror-gnu89.c b/gcc/testsuite/gcc.d= g/permerror-gnu89.c > index 66f7789269f..83792ecfaac 100644 > --- a/gcc/testsuite/gcc.dg/permerror-gnu89.c > +++ b/gcc/testsuite/gcc.dg/permerror-gnu89.c > @@ -19,7 +19,7 @@ implicit_int_4 (i) /* { dg-bogus "-Wimplicit-int" } */ > (const) 0; /* { dg-bogus "-Wimplicit-int" } */ > } > > -extern int missing_parameter_type (i); /* { dg-warning "parameter names = \\\(without types\\\) in function declaration\n" } */ > +extern int missing_parameter_type (i); /* { dg-warning "parameter names = \\\(without types\\\) in function declaration \\\[-Wdeclaration-missing-par= ameter-type\\\]" } */ > > > int * > diff --git a/gcc/testsuite/gcc.dg/permerror-noerror.c b/gcc/testsuite/gcc= .dg/permerror-noerror.c > index cd1c2013cb5..fc68dfa8bb9 100644 > --- a/gcc/testsuite/gcc.dg/permerror-noerror.c > +++ b/gcc/testsuite/gcc.dg/permerror-noerror.c > @@ -1,4 +1,4 @@ > -/* { dg-options "-Wno-error=3Dimplicit-function-declaration -Wno-error= =3Dimplicit-int -Wno-error=3Dint-conversion -Wno-error=3Dincompatible-point= er-types -Wno-error=3Dreturn-mismatch" } */ > +/* { dg-options "-Wno-error=3Dimplicit-function-declaration -Wno-error= =3Dimplicit-int -Wno-error=3Dint-conversion -Wno-error=3Dincompatible-point= er-types -Wno-error=3Dreturn-mismatch -Wno-error=3Ddeclaration-missing-para= meter-type" } */ > > /* This test should emulate the effect of -fpermissive by adding all the > -Wno-error=3D options that are implied by -fpermissive. It needs to = be > @@ -19,7 +19,7 @@ implicit_int_4 (i) /* { dg-warning "return type default= s to 'int' \\\[-Wimplicit > (const) 0; /* { dg-warning "type defaults to 'int' in type name \\\[-W= implicit-int\\\]" } */ > } > > -extern int missing_parameter_type (i); /* { dg-warning "parameter names = \\\(without types\\\) in function declaration\n" } */ > +extern int missing_parameter_type (i); /* { dg-warning "parameter names = \\\(without types\\\) in function declaration \\\[-Wdeclaration-missing-par= ameter-type\\\]" } */ > > > int * > diff --git a/gcc/testsuite/gcc.dg/permerror-nowarning.c b/gcc/testsuite/g= cc.dg/permerror-nowarning.c > index da6bd08245d..b1cf7990127 100644 > --- a/gcc/testsuite/gcc.dg/permerror-nowarning.c > +++ b/gcc/testsuite/gcc.dg/permerror-nowarning.c > @@ -1,10 +1,5 @@ > -/* { dg-options "-Wno-implicit-function-declaration -Wno-implicit-int -W= no-int-conversion -Wno-incompatible-pointer-types -Wno-return-mismatch" } *= / > +/* { dg-options "-Wno-implicit-function-declaration -Wno-implicit-int -W= no-int-conversion -Wno-incompatible-pointer-types -Wno-return-mismatch -Wno= -declaration-missing-parameter-type" } */ > > /* This test checks that permerrors can be disabled using -Wno-* options= . */ > > #include "permerror-default.c" > - > -/* Ideally, we do not want to see any warnings here, but this warning is= not > - yet controlled by its own option. */ > - > -/* { dg-warning "parameter names \\\(without types\\\) in function decla= ration\n" "" { target *-*-* } 22 } */ > diff --git a/gcc/testsuite/gcc.dg/permerror-pedantic.c b/gcc/testsuite/gc= c.dg/permerror-pedantic.c > index 95dda18acd4..2380bb2583c 100644 > --- a/gcc/testsuite/gcc.dg/permerror-pedantic.c > +++ b/gcc/testsuite/gcc.dg/permerror-pedantic.c > @@ -19,7 +19,7 @@ implicit_int_4 (i) /* { dg-error "return type defaults = to 'int' \\\[-Wimplicit-i > (const) 0; /* { dg-error "type defaults to 'int' in type name \\\[-Wim= plicit-int\\\]" } */ > } > > -extern int missing_parameter_type (i); /* { dg-error "parameter names \\= \(without types\\\) in function declaration\n" } */ > +extern int missing_parameter_type (i); /* { dg-error "parameter names \\= \(without types\\\) in function declaration \\\[-Wdeclaration-missing-param= eter-type\\\]" } */ > > > int * > diff --git a/gcc/testsuite/gcc.dg/permerror-system.c b/gcc/testsuite/gcc.= dg/permerror-system.c > index bd923138461..790e4f03d66 100644 > --- a/gcc/testsuite/gcc.dg/permerror-system.c > +++ b/gcc/testsuite/gcc.dg/permerror-system.c > @@ -17,6 +17,8 @@ > /* { dg-error "type of 'i' defaults to 'int' \\\[-Wimplicit-int\\\]" "" = { target *-*-*} 16 } */ > /* { dg-error "type defaults to 'int' in type name \\\[-Wimplicit-int\\\= ]" "" { target *-*-* } 19 } */ > > +/* { dg-error "parameter names \\\(without types\\\) in function declara= tion \\\[-Wdeclaration-missing-parameter-type\\\]" "" { target *-*-* } 22 }= */ > + > /* { dg-error "pointer/integer type mismatch in conditional expression \= \\[-Wint-conversion\\\]" "" { target *-*-* } 29 } */ > /* { dg-error "pointer/integer type mismatch in conditional expression \= \\[-Wint-conversion\\\]" "" { target *-*-* } 30 } */ > /* { dg-error "passing argument 1 of 'f2' makes pointer from integer wit= hout a cast \\\[-Wint-conversion\\\]" "" { target *-*-* } 31 } */ > -- > 2.42.0 >