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> 2013-08-17 Jason Merrill <jason@redhat.com>
PR c++/58083 PR c++/58083
......
...@@ -392,6 +392,17 @@ pop_binding (tree id, tree decl) ...@@ -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. */ /* Strip non dependent using declarations. */
tree tree
......
...@@ -89,6 +89,7 @@ typedef struct GTY(()) cxx_saved_binding { ...@@ -89,6 +89,7 @@ typedef struct GTY(()) cxx_saved_binding {
extern tree identifier_type_value (tree); extern tree identifier_type_value (tree);
extern void set_identifier_type_value (tree, tree); extern void set_identifier_type_value (tree, tree);
extern void pop_binding (tree, tree); extern void pop_binding (tree, tree);
extern void pop_bindings_and_leave_scope (void);
extern tree constructor_name (tree); extern tree constructor_name (tree);
extern bool constructor_name_p (tree, tree); extern bool constructor_name_p (tree, tree);
......
...@@ -8710,15 +8710,8 @@ cp_parser_lambda_introducer (cp_parser* parser, tree lambda_expr) ...@@ -8710,15 +8710,8 @@ cp_parser_lambda_introducer (cp_parser* parser, tree lambda_expr)
/* Turn the identifier into an id-expression. */ /* Turn the identifier into an id-expression. */
capture_init_expr capture_init_expr
= cp_parser_lookup_name = cp_parser_lookup_name_simple (parser, capture_id,
(parser, capture_token->location);
capture_id,
none_type,
/*is_template=*/false,
/*is_namespace=*/false,
/*check_dependency=*/true,
/*ambiguous_decls=*/NULL,
capture_token->location);
if (capture_init_expr == error_mark_node) if (capture_init_expr == error_mark_node)
{ {
...@@ -8809,7 +8802,6 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr) ...@@ -8809,7 +8802,6 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr)
tree param_list = void_list_node; tree param_list = void_list_node;
tree attributes = NULL_TREE; tree attributes = NULL_TREE;
tree exception_spec = NULL_TREE; tree exception_spec = NULL_TREE;
tree t;
/* The lambda-declarator is optional, but must begin with an opening /* The lambda-declarator is optional, but must begin with an opening
parenthesis if present. */ parenthesis if present. */
...@@ -8824,7 +8816,7 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr) ...@@ -8824,7 +8816,7 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr)
/* Default arguments shall not be specified in the /* Default arguments shall not be specified in the
parameter-declaration-clause of a lambda-declarator. */ 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)) if (TREE_PURPOSE (t))
pedwarn (DECL_SOURCE_LOCATION (TREE_VALUE (t)), OPT_Wpedantic, pedwarn (DECL_SOURCE_LOCATION (TREE_VALUE (t)), OPT_Wpedantic,
"default argument specified for lambda parameter"); "default argument specified for lambda parameter");
...@@ -8853,10 +8845,7 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr) ...@@ -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 /* The function parameters must be in scope all the way until after the
trailing-return-type in case of decltype. */ trailing-return-type in case of decltype. */
for (t = current_binding_level->names; t; t = DECL_CHAIN (t)) pop_bindings_and_leave_scope ();
pop_binding (DECL_NAME (t), t);
leave_scope ();
} }
/* Create the function call operator. /* Create the function call operator.
...@@ -11583,13 +11572,8 @@ cp_parser_decltype_expr (cp_parser *parser, ...@@ -11583,13 +11572,8 @@ cp_parser_decltype_expr (cp_parser *parser,
if (identifier_p (expr)) if (identifier_p (expr))
/* Lookup the name we got back from the id-expression. */ /* Lookup the name we got back from the id-expression. */
expr = cp_parser_lookup_name (parser, expr, expr = cp_parser_lookup_name_simple (parser, expr,
none_type, id_expr_start_token->location);
/*is_template=*/false,
/*is_namespace=*/false,
/*check_dependency=*/true,
/*ambiguous_decls=*/NULL,
id_expr_start_token->location);
if (expr if (expr
&& expr != error_mark_node && expr != error_mark_node
...@@ -16741,7 +16725,6 @@ cp_parser_direct_declarator (cp_parser* parser, ...@@ -16741,7 +16725,6 @@ cp_parser_direct_declarator (cp_parser* parser,
tree params; tree params;
unsigned saved_num_template_parameter_lists; unsigned saved_num_template_parameter_lists;
bool is_declarator = false; bool is_declarator = false;
tree t;
/* In a member-declarator, the only valid interpretation /* In a member-declarator, the only valid interpretation
of a parenthesis is the start of a of a parenthesis is the start of a
...@@ -16830,9 +16813,7 @@ cp_parser_direct_declarator (cp_parser* parser, ...@@ -16830,9 +16813,7 @@ cp_parser_direct_declarator (cp_parser* parser,
} }
/* Remove the function parms from scope. */ /* Remove the function parms from scope. */
for (t = current_binding_level->names; t; t = DECL_CHAIN (t)) pop_bindings_and_leave_scope ();
pop_binding (DECL_NAME (t), t);
leave_scope();
if (is_declarator) if (is_declarator)
/* Repeat the main loop. */ /* Repeat the main loop. */
...@@ -24101,7 +24082,6 @@ cp_parser_cache_defarg (cp_parser *parser, bool nsdmi) ...@@ -24101,7 +24082,6 @@ cp_parser_cache_defarg (cp_parser *parser, bool nsdmi)
the default argument; otherwise the default the default argument; otherwise the default
argument continues. */ argument continues. */
bool error = false; bool error = false;
tree t;
/* Set ITALP so cp_parser_parameter_declaration_list /* Set ITALP so cp_parser_parameter_declaration_list
doesn't decide to commit to this parse. */ doesn't decide to commit to this parse. */
...@@ -24123,9 +24103,7 @@ cp_parser_cache_defarg (cp_parser *parser, bool nsdmi) ...@@ -24123,9 +24103,7 @@ cp_parser_cache_defarg (cp_parser *parser, bool nsdmi)
{ {
begin_scope (sk_function_parms, NULL_TREE); begin_scope (sk_function_parms, NULL_TREE);
cp_parser_parameter_declaration_list (parser, &error); cp_parser_parameter_declaration_list (parser, &error);
for (t = current_binding_level->names; t; t = DECL_CHAIN (t)) pop_bindings_and_leave_scope ();
pop_binding (DECL_NAME (t), t);
leave_scope ();
} }
if (!cp_parser_error_occurred (parser) && !error) if (!cp_parser_error_occurred (parser) && !error)
done = true; 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