Commit 9485d254 by Paolo Carlini Committed by Paolo Carlini

parser.c (cp_parser_lambda_introducer, [...]): Use cp_parser_lookup_name_simple.

2013-08-19  Paolo Carlini  <paolo.carlini@oracle.com>

	* parser.c (cp_parser_lambda_introducer, cp_parser_decltype_expr):
	Use cp_parser_lookup_name_simple.

2013-08-19  Paolo Carlini  <paolo.carlini@oracle.com>

	* name-lookup.h (pop_bindings_and_leave_scope): Declare.
	* name-lookup.c (pop_bindings_and_leave_scope): Define.
	* parser.c (cp_parser_lambda_declarator_opt,
	cp_parser_direct_declarator, cp_parser_cache_defarg): Use it.

From-SVN: r201839
parent d33d9e47
2013-08-19 Paolo Carlini <paolo.carlini@oracle.com>
* parser.c (cp_parser_lambda_introducer, cp_parser_decltype_expr):
Use cp_parser_lookup_name_simple.
2013-08-19 Paolo Carlini <paolo.carlini@oracle.com>
* name-lookup.h (pop_bindings_and_leave_scope): Declare.
* name-lookup.c (pop_bindings_and_leave_scope): Define.
* parser.c (cp_parser_lambda_declarator_opt,
cp_parser_direct_declarator, cp_parser_cache_defarg): Use it.
2013-08-17 Jason Merrill <jason@redhat.com>
PR c++/58083
......
......@@ -392,6 +392,17 @@ pop_binding (tree id, tree decl)
}
}
/* Remove the bindings for the decls of the current level and leave
the current scope. */
void
pop_bindings_and_leave_scope (void)
{
for (tree t = getdecls (); t; t = DECL_CHAIN (t))
pop_binding (DECL_NAME (t), t);
leave_scope ();
}
/* Strip non dependent using declarations. */
tree
......
......@@ -89,6 +89,7 @@ typedef struct GTY(()) cxx_saved_binding {
extern tree identifier_type_value (tree);
extern void set_identifier_type_value (tree, tree);
extern void pop_binding (tree, tree);
extern void pop_bindings_and_leave_scope (void);
extern tree constructor_name (tree);
extern bool constructor_name_p (tree, tree);
......
......@@ -8710,14 +8710,7 @@ cp_parser_lambda_introducer (cp_parser* parser, tree lambda_expr)
/* Turn the identifier into an id-expression. */
capture_init_expr
= cp_parser_lookup_name
(parser,
capture_id,
none_type,
/*is_template=*/false,
/*is_namespace=*/false,
/*check_dependency=*/true,
/*ambiguous_decls=*/NULL,
= cp_parser_lookup_name_simple (parser, capture_id,
capture_token->location);
if (capture_init_expr == error_mark_node)
......@@ -8809,7 +8802,6 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr)
tree param_list = void_list_node;
tree attributes = NULL_TREE;
tree exception_spec = NULL_TREE;
tree t;
/* The lambda-declarator is optional, but must begin with an opening
parenthesis if present. */
......@@ -8824,7 +8816,7 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr)
/* Default arguments shall not be specified in the
parameter-declaration-clause of a lambda-declarator. */
for (t = param_list; t; t = TREE_CHAIN (t))
for (tree t = param_list; t; t = TREE_CHAIN (t))
if (TREE_PURPOSE (t))
pedwarn (DECL_SOURCE_LOCATION (TREE_VALUE (t)), OPT_Wpedantic,
"default argument specified for lambda parameter");
......@@ -8853,10 +8845,7 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr)
/* The function parameters must be in scope all the way until after the
trailing-return-type in case of decltype. */
for (t = current_binding_level->names; t; t = DECL_CHAIN (t))
pop_binding (DECL_NAME (t), t);
leave_scope ();
pop_bindings_and_leave_scope ();
}
/* Create the function call operator.
......@@ -11583,12 +11572,7 @@ cp_parser_decltype_expr (cp_parser *parser,
if (identifier_p (expr))
/* Lookup the name we got back from the id-expression. */
expr = cp_parser_lookup_name (parser, expr,
none_type,
/*is_template=*/false,
/*is_namespace=*/false,
/*check_dependency=*/true,
/*ambiguous_decls=*/NULL,
expr = cp_parser_lookup_name_simple (parser, expr,
id_expr_start_token->location);
if (expr
......@@ -16741,7 +16725,6 @@ cp_parser_direct_declarator (cp_parser* parser,
tree params;
unsigned saved_num_template_parameter_lists;
bool is_declarator = false;
tree t;
/* In a member-declarator, the only valid interpretation
of a parenthesis is the start of a
......@@ -16830,9 +16813,7 @@ cp_parser_direct_declarator (cp_parser* parser,
}
/* Remove the function parms from scope. */
for (t = current_binding_level->names; t; t = DECL_CHAIN (t))
pop_binding (DECL_NAME (t), t);
leave_scope();
pop_bindings_and_leave_scope ();
if (is_declarator)
/* Repeat the main loop. */
......@@ -24101,7 +24082,6 @@ cp_parser_cache_defarg (cp_parser *parser, bool nsdmi)
the default argument; otherwise the default
argument continues. */
bool error = false;
tree t;
/* Set ITALP so cp_parser_parameter_declaration_list
doesn't decide to commit to this parse. */
......@@ -24123,9 +24103,7 @@ cp_parser_cache_defarg (cp_parser *parser, bool nsdmi)
{
begin_scope (sk_function_parms, NULL_TREE);
cp_parser_parameter_declaration_list (parser, &error);
for (t = current_binding_level->names; t; t = DECL_CHAIN (t))
pop_binding (DECL_NAME (t), t);
leave_scope ();
pop_bindings_and_leave_scope ();
}
if (!cp_parser_error_occurred (parser) && !error)
done = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment