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]

Re: [C++ PATCH] Fix PR19258 (incorrect scope for friend defined in-class)

Kriang Lerdsuwanakij wrote:

This is a patch for mainline that fixes PR19258.  The 3.4 branch is
also affected by the bug but it requires more changes in the parser
to correctly defer parsing of default argument until the enclosing
class is complete.

The bug is that the scope is not properly setup for friend functions
defined inside a class.  Thus in the following testcase, the function
'ff' has lexical scope inside class 'X' but the global scope is
incorrectly used.

  class X {
    template<class T> friend int ff(T*, int y=anX.x) { return y; }
    int f() { return ff(&anX); }

    static X anX;
    int x;

The fix is simply adjusting push/pop_access_scope to use
DECL_FRIEND_CONTEXT when it is available.  Tested on i686-pc-linux-gnu.
OK for the mainline?


Can you persuade your mailer to mark the attachement as text, rather
than 'application/x-java-vm', which is a blatant lie :)


Nathan Sidwell    ::   ::     CodeSourcery LLC    ::

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