| Submitter | Nathan Froyd |
|---|---|
| Date | Dec. 2, 2010, 5:22 p.m. |
| Message ID | <20101202172251.GA18963@nightcrawler> |
| Download | mbox | patch |
| Permalink | /patch/74001/ |
| State | New |
| Headers | show |
Comments
On Thu, 2 Dec 2010, Nathan Froyd wrote: > PR c/45062 > * c-decl.c (grokparms): Set arg_info->parms to NULL_TREE when > !funcdef_flag. OK, presuming it fixes an existing testcase in the testsuite, or with a new testcase added.
On Thu, Dec 02, 2010 at 05:30:19PM +0000, Joseph S. Myers wrote: > On Thu, 2 Dec 2010, Nathan Froyd wrote: > > PR c/45062 > > * c-decl.c (grokparms): Set arg_info->parms to NULL_TREE when > > !funcdef_flag. > > OK, presuming it fixes an existing testcase in the testsuite, or with a > new testcase added. It does, gcc.dg/pr14963.c. Thanks for the quick review. -Nathan
Patch
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index b1055b0..ac8f020 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -6131,9 +6131,13 @@ grokparms (struct c_arg_info *arg_info, bool funcdef_flag) else if (arg_types && TREE_CODE (TREE_VALUE (arg_types)) == IDENTIFIER_NODE) { if (!funcdef_flag) - pedwarn (input_location, 0, "parameter names (without types) in function declaration"); + { + pedwarn (input_location, 0, "parameter names (without types) in function declaration"); + arg_info->parms = NULL_TREE; + } + else + arg_info->parms = arg_info->types; - arg_info->parms = arg_info->types; arg_info->types = 0; return 0; }
The patch below fixes PR 45062, a bit of DECL_CHAIN fallout. The problem was that in grokparms, we did: else if (arg_types && TREE_CODE (TREE_VALUE (arg_types)) == IDENTIFIER_NODE) { if (!funcdef_flag) pedwarn (input_location, 0, "parameter names (without types) in function declaration"); arg_info->parms = arg_info->types; arg_info->types = 0; return 0; } which is somewhat dodgy, as arg_info->parms is logically a list of DECLs and we were setting it to a TREE_LIST. With the stricter checking provided by DECL_CHAIN, we blew up later on. The approach I took was simply to NULL out ->parms in the pedwarn case. It would have been nice to NULL it out regardless, but K&R argument list handling groks ->parms as TREE_LIST, so the assignment needs to remain in the non-pedwarn case. Tested on x86_64-unknown-linux-gnu. OK to commit? -Nathan PR c/45062 * c-decl.c (grokparms): Set arg_info->parms to NULL_TREE when !funcdef_flag.