This is the mail archive of the 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]

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


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

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?


Attachment: diff-friend-push-2
Description: application/java-vm

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