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: [PATCH,c++] convert cp_parser.unparsed_function_queues &co. to VECs


On 06/30/2010 03:55 PM, Nathan Froyd wrote:
       /* Friends must all go through the overload machinery,
          even though they may not technically be overloaded.

          Note that because classes all wind up being top-level
          in their scope, their friend wind up in top-level scope as well.  */
       if (funcdef_flag)
         SET_DECL_FRIEND_CONTEXT (decl, current_class_type);

What happens if you remove the if?

If I set funcdef_flag to true at the start of do_friend when f is getting defined, things work as expected. grokdeclarator attempts to grok f in FIELD context, which explains why funcdef_flag doesn't get set in grokdeclarator.

And it shouldn't get set, because f is not being defined, only declared.


What's the right fix?  Presumably the test shouldn't be removed in
do_friend...should grokdeclarator be checking declarator->kind?

Why presumably? The comment for DECL_FRIEND_CONTEXT doesn't specify that it's only set for definitions.


But I would be sure to test that we give the appropriate errors if you have a friend declaration followed by a global definition that refers to static members of the type without explicit qualification.

Jason


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