Skip to content

friend declaration in derived class does not get honored #34403

@llvmbot

Description

@llvmbot
Bugzilla Link 35055
Version trunk
OS All
Reporter LLVM Bugzilla Contributor
CC @DougGregor

Extended Description

The following produces a ".... is a protected member of..." error while the friend declaration in the derived class is honored by gcc (multiple versions upto trunk), Visual Studio (multiple versions upto VS2017) and ICC.

Are they all wrongly accepting this code, or is this a Clang only issue ?

--8<--
class AFriend;

class Foo
{
protected:
static void Bar();
};

#if 1
class DerivedFoo
: public Foo
{
friend class AFriend;
};
#endif

class AFriend
{
public:
void CallFooBar()
{
Foo::Bar();
}
};
--8<--

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partyinvalidResolved as invalid, i.e. not a bugrejects-valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions