* [C++ Patch] Remove cp_parser_parameter_declaration_list parameter
@ 2018-05-21 19:50 Paolo Carlini
2018-05-21 20:37 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Paolo Carlini @ 2018-05-21 19:50 UTC (permalink / raw)
To: gcc-patches; +Cc: Jason Merrill
[-- Attachment #1: Type: text/plain, Size: 387 bytes --]
Hi,
I noticed a few days ago that the second parameter of the function is
redundant, we can just rely on the return value possibly being
error_mark_node (I even ran the testsuite with the function instrumented
with a gcc_assert (*is_error == (parameters == error_mark_node);
immediately before the return, at some point). Tested x86_64-linux.
Thanks, Paolo.
////////////////////
[-- Attachment #2: CL_cp_parser_parameter_declaration_list --]
[-- Type: text/plain, Size: 220 bytes --]
2018-05-21 Paolo Carlini <paolo.carlini@oracle.com>
* parser.c (cp_parser_parameter_declaration_list): Remove
bool* parameter.
(cp_parser_parameter_declaration_clause): Adjust.
(cp_parser_cache_defarg): Likewise.
[-- Attachment #3: patch_cp_parser_parameter_declaration_list --]
[-- Type: text/plain, Size: 2930 bytes --]
Index: parser.c
===================================================================
--- parser.c (revision 260280)
+++ parser.c (working copy)
@@ -2235,7 +2235,7 @@ static void cp_parser_type_specifier_seq
static tree cp_parser_parameter_declaration_clause
(cp_parser *);
static tree cp_parser_parameter_declaration_list
- (cp_parser *, bool *);
+ (cp_parser *);
static cp_parameter_declarator *cp_parser_parameter_declaration
(cp_parser *, bool, bool *);
static tree cp_parser_default_argument
@@ -21191,7 +21209,6 @@ cp_parser_parameter_declaration_clause (cp_parser*
tree parameters;
cp_token *token;
bool ellipsis_p;
- bool is_error;
temp_override<bool> cleanup
(parser->auto_is_implicit_function_template_parm_p);
@@ -21239,12 +21256,12 @@ cp_parser_parameter_declaration_clause (cp_parser*
}
/* Parse the parameter-declaration-list. */
- parameters = cp_parser_parameter_declaration_list (parser, &is_error);
+ parameters = cp_parser_parameter_declaration_list (parser);
/* If a parse error occurred while parsing the
parameter-declaration-list, then the entire
parameter-declaration-clause is erroneous. */
- if (is_error)
- return NULL;
+ if (parameters == error_mark_node)
+ return NULL_TREE;
/* Peek at the next token. */
token = cp_lexer_peek_token (parser->lexer);
@@ -21284,11 +21301,10 @@ cp_parser_parameter_declaration_clause (cp_parser*
Returns a representation of the parameter-declaration-list, as for
cp_parser_parameter_declaration_clause. However, the
- `void_list_node' is never appended to the list. Upon return,
- *IS_ERROR will be true iff an error occurred. */
+ `void_list_node' is never appended to the list. */
static tree
-cp_parser_parameter_declaration_list (cp_parser* parser, bool *is_error)
+cp_parser_parameter_declaration_list (cp_parser* parser)
{
tree parameters = NULL_TREE;
tree *tail = ¶meters;
@@ -21295,8 +21311,6 @@ static tree
bool saved_in_unbraced_linkage_specification_p;
int index = 0;
- /* Assume all will go well. */
- *is_error = false;
/* The special considerations that apply to a function within an
unbraced linkage specifications do not apply to the parameters
to the function. */
@@ -21338,7 +21352,6 @@ static tree
then the entire parameter-declaration-list is erroneous. */
if (decl == error_mark_node)
{
- *is_error = true;
parameters = error_mark_node;
break;
}
@@ -28958,7 +28971,9 @@ cp_parser_cache_defarg (cp_parser *parser, bool ns
{
cp_lexer_consume_token (parser->lexer);
begin_scope (sk_function_parms, NULL_TREE);
- cp_parser_parameter_declaration_list (parser, &error);
+ if (cp_parser_parameter_declaration_list (parser)
+ == error_mark_node)
+ error = true;
pop_bindings_and_leave_scope ();
}
if (!cp_parser_error_occurred (parser) && !error)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [C++ Patch] Remove cp_parser_parameter_declaration_list parameter
2018-05-21 19:50 [C++ Patch] Remove cp_parser_parameter_declaration_list parameter Paolo Carlini
@ 2018-05-21 20:37 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2018-05-21 20:37 UTC (permalink / raw)
To: Paolo Carlini; +Cc: gcc-patches
OK.
On Mon, May 21, 2018 at 3:47 PM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
> Hi,
>
> I noticed a few days ago that the second parameter of the function is
> redundant, we can just rely on the return value possibly being
> error_mark_node (I even ran the testsuite with the function instrumented
> with a gcc_assert (*is_error == (parameters == error_mark_node); immediately
> before the return, at some point). Tested x86_64-linux.
>
> Thanks, Paolo.
>
> ////////////////////
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-05-21 20:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-21 19:50 [C++ Patch] Remove cp_parser_parameter_declaration_list parameter Paolo Carlini
2018-05-21 20:37 ` Jason Merrill
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).