diff options
author | Ville Voutilainen <ville.voutilainen@gmail.com> | 2014-06-02 23:47:55 +0300 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2014-06-02 16:47:55 -0400 |
commit | adb50dfbf65b5a8ac29bed8edd752535e6fd4a35 (patch) | |
tree | 5a5a4cf79999d2bd283fce025695d4e129b69b59 /gcc | |
parent | 9b2b72791eb7506db1e6cdd17f1201dcd9e96e64 (diff) | |
download | gcc-adb50dfbf65b5a8ac29bed8edd752535e6fd4a35.zip gcc-adb50dfbf65b5a8ac29bed8edd752535e6fd4a35.tar.gz gcc-adb50dfbf65b5a8ac29bed8edd752535e6fd4a35.tar.bz2 |
re PR c++/59483 (A nested lambda fails to find a protected name with qualified name)
PR c++/59483
PR c++/61148
* search.c (accessible_p): Use current_nonlambda_class_type.
* semantics.c (check_accessibility_of_qualified_id): Likewise.
From-SVN: r211147
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/search.c | 6 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/lambda/lambda-59483.C | 31 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/lambda/lambda-61148.C | 33 |
5 files changed, 78 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 346782e..9b439a9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +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. diff --git a/gcc/cp/search.c b/gcc/cp/search.c index c3eed90..424b26c 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -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) diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 4c13e9d..21920b4 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1836,10 +1836,11 @@ check_accessibility_of_qualified_id (tree decl, /* 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 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..b5b06d2 --- /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..879030c --- /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; +} |