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] |
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?
Attachment:
diff-lookup-inline-friend-1
Description: application/java-vm
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |