Hi
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?