+2014-06-02 Ville Voutilainen <ville.voutilainen@gmail.com>
+
+ PR c++/59483
+ PR c++/61148
+ * search.c (accessible_p): Use current_nonlambda_class_type.
+ * semantics.c (check_accessibility_of_qualified_id): Likewise.
+
2014-06-02 Andrew MacLeod <amacleod@redhat.com>
* decl.c: Include builtins.h.
/* 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)
/* If the reference is to a non-static member of the
current class, treat it as if it were referenced through
`this'. */
+ tree ct;
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, ct = current_nonlambda_class_type ()))
+ qualifying_type = ct;
/* Otherwise, use the type indicated by the
nested-name-specifier. */
else
--- /dev/null
+// 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;
+}
--- /dev/null
+// 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;
+}