This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ PATCH] Fix friend class name lookup part 3/n (PR3332)


Kriang Lerdsuwanakij wrote:
Hi

This is a revised version of the fix for friend name injection part 2:

http://gcc.gnu.org/ml/gcc-patches/2004-10/msg02056.html

Now it is submitted here as part 3 for ease of understanding (but should
be applied together with part 2 and some formatting changes suggested
earlier).  This patch also fixes PR3332.


This patch introduces new functions push_inner_scope and pop_inner_scope that setup chain of binding levels directly for declarations like below

class N::C::D { ... };

where N and C are previously declared class or namespace. They are used
in cp_parser_class_specifier. The function push_scope/pop_scope formerly
used there do not work well in this situation since they set up information suitable for doing scoped name lookup but not for pushing name.
Names may be pushed to outer scopes via friend declaration (although they
are hidden until actually declared).



Note that we have to treat template parameter scope specially in push/pop_inner_scope. For example:

template <class T> class N::C::D { ... };

we already have
{template parm}
but after push_inner_scope, the binding chain should be {namespace N} {template parm} {class C}
so that name lookup of 'T' find the template parameter rather than a name
in the namespace N (according to 14.6.1/6).



Tested on i686-pc-linux-gnu. OK for mainline?

This looks ok. I presume that we could migtate push_scope & pop_scope to use this new interface, and remove the OUTER param from push_inner_scope (it's always current_scope (), right?).

I'd like to run this by Mark, just to make sure.

nathan

--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]