re PR c++/59483 (A nested lambda fails to find a protected name with qualified name)
[gcc.git] / gcc / cp / search.c
index c3eed90f6c3632b5a9ade786e0c09e3a2444131d..424b26cd3e1b059b34e5941776411a5d2ab6cea1 100644 (file)
@@ -917,9 +917,11 @@ accessible_p (tree type, tree decl, bool consider_local_p)
       /* Figure out where the reference is occurring.  Check to see if
         DECL is private or protected in this scope, since that will
         determine whether protected access is allowed.  */
-      if (current_class_type)
+      tree ct = current_nonlambda_class_type ();
+      if (ct)
        protected_ok = protected_accessible_p (decl,
-                                              current_class_type, binfo);
+                                              ct,
+                                              binfo);
 
       /* Now, loop through the classes of which we are a friend.  */
       if (!protected_ok)