Skip to content

Friend constructor is recognized as member function #11756

@flooklab

Description

@flooklab

When I declare the enclosing class's constructor as friend as in the example below, that friend declaration is falsely interpreted by Doxygen as a member function of the nested class with return type friend:

// foo.h

/// Foo class.
class Foo
{
public:
    class Bar;
    Foo(bool param);
    void importantFunction(bool param) const;
};

/// Bar class.
class Foo::Bar
{
public:
    /// Constructor.
    Bar() = default;

private:
    /// Private function.
    void privateFunction() const {}

    /// Needs to be friend.
    friend Foo::Foo(bool);      // <-- here
    /// Needs to be friend too.
    friend void Foo::importantFunction(bool) const;
};

/*!
 * Constructor.
 * \param param Parameter.
 */
Foo::Foo(bool param)
{
    Bar bar;
    bar.privateFunction();
}
/*!
 * Important function.
 * \param param Parameter.
 */
void Foo::importantFunction(bool param) const
{
    Bar bar;
    bar.privateFunction();
}

In the generated output the Foo constructor is not listed in Bar's "friends" section but as a private member function of Bar. The other friend function is recognized correctly.

Logically, there is also a warning about the "undocumented return type":
foo.h:23: warning: return type of member Foo::Bar::Foo is not documented

Doxyfile configuration is the default one, except for:

EXTRACT_PRIVATE        = YES
WARN_NO_PARAMDOC       = YES

Used Doxygen version: 1.14.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions