Tested on Linux X86-64. Note that I have not bootstrapped this patch.
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index c3eed90..6907533 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -917,9 +917,10 @@ 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)
+      if (current_nonlambda_class_type ())
        protected_ok = protected_accessible_p (decl,
-                                              current_class_type, binfo);
+                                              current_nonlambda_class_type (),
+                                              binfo);
 
       /* Now, loop through the classes of which we are a friend.  */
       if (!protected_ok)
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 7e144a6..06acd4e 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -1837,8 +1837,8 @@ check_accessibility_of_qualified_id (tree decl,
         `this'.  */
       if (DECL_NONSTATIC_MEMBER_P (decl)
          && current_class_ptr
-         && DERIVED_FROM_P (scope, current_class_type))
-       qualifying_type = current_class_type;
+         && DERIVED_FROM_P (scope, current_nonlambda_class_type ()))
+       qualifying_type = current_nonlambda_class_type ();
       /* Otherwise, use the type indicated by the
         nested-name-specifier.  */
       else
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-59483.C 
b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-59483.C
new file mode 100644
index 0000000..fa79df9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-59483.C
@@ -0,0 +1,31 @@
+// PR c++/59483
+// { dg-do compile { target c++11 } }
+
+struct X 
+{ 
+protected: 
+  int i; 
+};  
+
+struct Y : X 
+{ 
+  Y() 
+  { 
+    [&]{ X::i = 3; }(); 
+  }
+};
+
+template <class T>
+struct Y2 : T
+{
+  Y2() 
+  { 
+    [&]{ T::i = 3; }(); 
+  }
+};
+
+int main()
+{
+  Y y;
+  Y2<X> y2;
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-61148.C 
b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-61148.C
new file mode 100644
index 0000000..32bb734
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-61148.C
@@ -0,0 +1,33 @@
+// PR c++/61148
+// { dg-do compile { target c++11 } }
+
+class DB 
+{
+protected:
+  void foo() {};
+};
+
+class DC : public DB 
+{
+public:
+  DC() 
+  {
+    [this]() {DB::foo();}();
+  };
+};
+
+template <class T>
+class DC2 : public T
+{
+public:
+  DC2() 
+  {
+    [this]() {T::foo();}();
+  };
+};
+
+int main(void)
+{
+  DC x;
+  DC2<DB> x2;
+}

Attachment: pr59483_pr61148.changelog
Description: Binary data



Reply via email to