Commit c443f3d5 by Nathan Sidwell Committed by Nathan Sidwell

decl.c (xref_tag_1): Don't frob ts_lambda scope here.

	* decl.c (xref_tag_1): Don't frob ts_lambda scope here.
	* name-lookup.c (pushtag_1): Deal with ts_lambda scope.

From-SVN: r247909
parent 2cd47092
2017-05-11 Nathan Sidwell <nathan@acm.org> 2017-05-11 Nathan Sidwell <nathan@acm.org>
* decl.c (xref_tag_1): Don't frob ts_lambda scope here.
* name-lookup.c (pushtag_1): Deal with ts_lambda scope.
* cp-tree.h (pushdecl, pushdecl_maybe_friend, pushtag, * cp-tree.h (pushdecl, pushdecl_maybe_friend, pushtag,
pushtag_top_level_maybe_friend, pushtag_top_level_maybe_friend,
pushdecl_top_level_and_finish): Move declarations to ... pushdecl_top_level_and_finish): Move declarations to ...
......
...@@ -13514,12 +13514,10 @@ lookup_and_check_tag (enum tag_types tag_code, tree name, ...@@ -13514,12 +13514,10 @@ lookup_and_check_tag (enum tag_types tag_code, tree name,
static tree static tree
xref_tag_1 (enum tag_types tag_code, tree name, xref_tag_1 (enum tag_types tag_code, tree name,
tag_scope orig_scope, bool template_header_p) tag_scope scope, bool template_header_p)
{ {
enum tree_code code; enum tree_code code;
tree t;
tree context = NULL_TREE; tree context = NULL_TREE;
tag_scope scope;
gcc_assert (identifier_p (name)); gcc_assert (identifier_p (name));
...@@ -13539,19 +13537,12 @@ xref_tag_1 (enum tag_types tag_code, tree name, ...@@ -13539,19 +13537,12 @@ xref_tag_1 (enum tag_types tag_code, tree name,
gcc_unreachable (); gcc_unreachable ();
} }
if (orig_scope == ts_lambda)
scope = ts_current;
else
scope = orig_scope;
/* In case of anonymous name, xref_tag is only called to /* In case of anonymous name, xref_tag is only called to
make type node and push name. Name lookup is not required. */ make type node and push name. Name lookup is not required. */
if (anon_aggrname_p (name)) tree t = NULL_TREE;
t = NULL_TREE; if (scope != ts_lambda && !anon_aggrname_p (name))
else t = lookup_and_check_tag (tag_code, name, scope, template_header_p);
t = lookup_and_check_tag (tag_code, name,
scope, template_header_p);
if (t == error_mark_node) if (t == error_mark_node)
return error_mark_node; return error_mark_node;
...@@ -13617,9 +13608,8 @@ xref_tag_1 (enum tag_types tag_code, tree name, ...@@ -13617,9 +13608,8 @@ xref_tag_1 (enum tag_types tag_code, tree name,
{ {
t = make_class_type (code); t = make_class_type (code);
TYPE_CONTEXT (t) = context; TYPE_CONTEXT (t) = context;
if (orig_scope == ts_lambda) if (scope == ts_lambda)
/* Remember that we're declaring a lambda to avoid bogus errors /* Mark it as a lambda type. */
in push_template_decl. */
CLASSTYPE_LAMBDA_EXPR (t) = error_mark_node; CLASSTYPE_LAMBDA_EXPR (t) = error_mark_node;
t = pushtag (name, t, scope); t = pushtag (name, t, scope);
} }
......
...@@ -6079,7 +6079,9 @@ pushtag_1 (tree name, tree type, tag_scope scope) ...@@ -6079,7 +6079,9 @@ pushtag_1 (tree name, tree type, tag_scope scope)
view of the language. */ view of the language. */
|| (b->kind == sk_template_parms || (b->kind == sk_template_parms
&& (b->explicit_spec_p || scope == ts_global)) && (b->explicit_spec_p || scope == ts_global))
/* Pushing into a class is ok for lambdas or when we want current */
|| (b->kind == sk_class || (b->kind == sk_class
&& scope != ts_lambda
&& (scope != ts_current && (scope != ts_current
/* We may be defining a new type in the initializer /* We may be defining a new type in the initializer
of a static member variable. We allow this when of a static member variable. We allow this when
...@@ -6102,9 +6104,10 @@ pushtag_1 (tree name, tree type, tag_scope scope) ...@@ -6102,9 +6104,10 @@ pushtag_1 (tree name, tree type, tag_scope scope)
tree cs = current_scope (); tree cs = current_scope ();
if (scope == ts_current if (scope == ts_current
|| scope == ts_lambda
|| (cs && TREE_CODE (cs) == FUNCTION_DECL)) || (cs && TREE_CODE (cs) == FUNCTION_DECL))
context = cs; context = cs;
else if (cs != NULL_TREE && TYPE_P (cs)) else if (cs && TYPE_P (cs))
/* When declaring a friend class of a local class, we want /* When declaring a friend class of a local class, we want
to inject the newly named class into the scope to inject the newly named class into the scope
containing the local class, not the namespace containing the local class, not the namespace
...@@ -6138,7 +6141,8 @@ pushtag_1 (tree name, tree type, tag_scope scope) ...@@ -6138,7 +6141,8 @@ pushtag_1 (tree name, tree type, tag_scope scope)
if (b->kind == sk_class) if (b->kind == sk_class)
{ {
if (!TYPE_BEING_DEFINED (current_class_type)) if (!TYPE_BEING_DEFINED (current_class_type)
&& scope != ts_lambda)
return error_mark_node; return error_mark_node;
if (!PROCESSING_REAL_TEMPLATE_DECL_P ()) if (!PROCESSING_REAL_TEMPLATE_DECL_P ())
...@@ -6189,6 +6193,7 @@ pushtag_1 (tree name, tree type, tag_scope scope) ...@@ -6189,6 +6193,7 @@ pushtag_1 (tree name, tree type, tag_scope scope)
vec_safe_push (local_classes, type); vec_safe_push (local_classes, type);
} }
} }
if (b->kind == sk_class if (b->kind == sk_class
&& !COMPLETE_TYPE_P (current_class_type)) && !COMPLETE_TYPE_P (current_class_type))
{ {
......
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