]> gcc.gnu.org Git - gcc.git/commitdiff
parser.c (cp_parser_lambda_expression): Compute visibility.
authorJason Merrill <jason@redhat.com>
Fri, 2 Oct 2009 04:33:51 +0000 (00:33 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 2 Oct 2009 04:33:51 +0000 (00:33 -0400)
* 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

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/parser.c
gcc/cp/tree.c

index 31e1ac6c87a7944ab593f8b15df9bde97699aa70..269773532fbc990cbe7c6f595c5a611fb1a939a3 100644 (file)
@@ -1,3 +1,11 @@
+2009-10-01  Jason Merrill  <jason@redhat.com>
+
+       * 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  <gdr@cse.tamu.edu>
            Jason Merrill <jason@redhat.com>
 
index ab4a6a71abdf6bc8a7121a8932113582130d2095..fc00176c276235b95a807b2d5f9105ce637fb6b6 100644 (file)
@@ -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 */
index 950d136f3980aae3b380a307518a54e264390bd8..210d3dda0e0eff32e31beee04cfdec5005236bbb 100644 (file)
@@ -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
index 19a1270b76df7a6e26580bc78ecf05eb5f11d874..1cd2bf596f8b7fd91b3a508491867de47ce8b6d9 100644 (file)
@@ -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;
This page took 0.103203 seconds and 5 git commands to generate.