From: Jason Merrill Date: Fri, 2 Oct 2009 04:33:51 +0000 (-0400) Subject: parser.c (cp_parser_lambda_expression): Compute visibility. X-Git-Tag: releases/gcc-4.5.0~3148 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e6d92cecfb2fa189ee958ea4574ffd8a1109a022;p=thirdparty%2Fgcc.git parser.c (cp_parser_lambda_expression): Compute visibility. * parser.c (cp_parser_lambda_expression): Compute visibility. (no_linkage_lambda_type_p): Remove. * cp-tree.h: Remove declaration. * tree.c (no_linkage_check): Don't call it. Don't check template args. Don't check TREE_PUBLIC Types. From-SVN: r152395 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 31e1ac6c87a7..269773532fbc 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2009-10-01 Jason Merrill + + * parser.c (cp_parser_lambda_expression): Compute visibility. + (no_linkage_lambda_type_p): Remove. + * cp-tree.h: Remove declaration. + * tree.c (no_linkage_check): Don't call it. Don't check template + args. Don't check TREE_PUBLIC Types. + 2009-10-01 Gabriel Dos Reis Jason Merrill diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index ab4a6a71abdf..fc00176c2762 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -5303,9 +5303,6 @@ extern tree cxx_omp_clause_dtor (tree, tree); extern void cxx_omp_finish_clause (tree); extern bool cxx_omp_privatize_by_reference (const_tree); -/* in parser.c */ -extern bool no_linkage_lambda_type_p (tree); - /* -- end of C++ */ #endif /* ! GCC_CP_TREE_H */ diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 950d136f3980..210d3dda0e0e 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -7005,31 +7005,6 @@ finish_lambda_scope (void) VEC_pop (tree_int, lambda_scope_stack); } -/* We want to determine the linkage of a lambda type at pushtag time, - before CLASSTYPE_LAMBDA_EXPR has been set. So this callback allows us - to find out whether the current lambda mangling scope will give us - linkage or not. */ - -bool -no_linkage_lambda_type_p (tree type) -{ - tree lambda, scope; - if (!LAMBDA_TYPE_P (type)) - return false; - - lambda = CLASSTYPE_LAMBDA_EXPR (type); - if (lambda) - scope = LAMBDA_EXPR_EXTRA_SCOPE (lambda); - else if (CLASSTYPE_TEMPLATE_INSTANTIATION (type)) - /* We can't use lambda_scope, and CLASSTYPE_TEMPLATE_INFO won't be set - yet either, so guess it's public for now. */ - return false; - else - scope = lambda_scope; - - return (scope == NULL_TREE); -} - /* Parse a lambda expression. lambda-expression: @@ -7054,6 +7029,9 @@ cp_parser_lambda_expression (cp_parser* parser) record_lambda_scope (lambda_expr); + /* Do this again now that LAMBDA_EXPR_EXTRA_SCOPE is set. */ + determine_visibility (TYPE_NAME (type)); + { /* Inside the class, surrounding template-parameter-lists do not apply. */ unsigned int saved_num_template_parameter_lists diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 19a1270b76df..1cd2bf596f8b 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1556,46 +1556,41 @@ no_linkage_check (tree t, bool relaxed_p) case RECORD_TYPE: if (TYPE_PTRMEMFUNC_P (t)) goto ptrmem; + /* Lambda types that don't have mangling scope have no linkage. We + check CLASSTYPE_LAMBDA_EXPR here rather than LAMBDA_TYPE_P because + when we get here from pushtag none of the lambda information is + set up yet, so we want to assume that the lambda has linkage and + fix it up later if not. */ + if (CLASSTYPE_LAMBDA_EXPR (t) + && LAMBDA_TYPE_EXTRA_SCOPE (t) == NULL_TREE) + return t; /* Fall through. */ case UNION_TYPE: if (!CLASS_TYPE_P (t)) return NULL_TREE; - - /* Check template type-arguments. I think that types with no linkage - can't occur in non-type arguments, though that might change with - constexpr. */ - r = CLASSTYPE_TEMPLATE_INFO (t); - if (r) - { - tree args = INNERMOST_TEMPLATE_ARGS (TI_ARGS (r)); - int i; - - for (i = TREE_VEC_LENGTH (args); i-- > 0; ) - { - tree elt = TREE_VEC_ELT (args, i); - if (TYPE_P (elt) - && (r = no_linkage_check (elt, relaxed_p), r)) - return r; - } - } /* Fall through. */ case ENUMERAL_TYPE: /* Only treat anonymous types as having no linkage if they're at namespace scope. This doesn't have a core issue number yet. */ if (TYPE_ANONYMOUS_P (t) && TYPE_NAMESPACE_SCOPE_P (t)) return t; - if (no_linkage_lambda_type_p (t)) - return t; - r = CP_TYPE_CONTEXT (t); - if (TYPE_P (r)) - return no_linkage_check (TYPE_CONTEXT (t), relaxed_p); - else if (TREE_CODE (r) == FUNCTION_DECL) + for (r = CP_TYPE_CONTEXT (t); ; ) { - if (!relaxed_p || !TREE_PUBLIC (r) || !vague_linkage_fn_p (r)) - return t; + /* If we're a nested type of a !TREE_PUBLIC class, we might not + have linkage, or we might just be in an anonymous namespace. + If we're in a TREE_PUBLIC class, we have linkage. */ + if (TYPE_P (r) && !TREE_PUBLIC (TYPE_NAME (r))) + return no_linkage_check (TYPE_CONTEXT (t), relaxed_p); + else if (TREE_CODE (r) == FUNCTION_DECL) + { + if (!relaxed_p || !vague_linkage_fn_p (r)) + return t; + else + r = CP_DECL_CONTEXT (r); + } else - return no_linkage_check (CP_DECL_CONTEXT (r), relaxed_p); + break; } return NULL_TREE;