Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for template method pointer parameter issue #449

Closed
wants to merge 2 commits into from
Closed

Fix for template method pointer parameter issue #449

wants to merge 2 commits into from

Conversation

darryllawson
Copy link
Contributor

I have found that Breathe does not cope with a template method pointer parameter.

The method signature of bad() below causes the issue.

/**
 * A class.
 */
class C {
public:
    /**
     * Set a callback. This causes a breathe error.
     *
     * \tparam OWNER Class the declares \p callback.
     * \param owner Reference to the object to call \p callback on.
     * \param callback Pointer to callback method.
     */
    template <typename OWNER>
    void bad(OWNER& owner, void (OWNER::*callback)(void));


    /**
     * No error from this because does not have method pointer param.
     *
     * \tparam OWNER Class the declares \p callback.
     * \param owner Reference to the object to call \p callback on.
     * \param v Some parameter.
     */
    template <typename OWNER>
    void fine(OWNER& owner, int v);
};

This is the Sphinx source to reproduce the error:

Welcome to breathe-issue's documentation!
=========================================

Doco for C:

.. doxygenclass:: C
    :members:

And this is the warning reported by Sphinx:

index.rst:6: WARNING: Error when parsing function declaration.
If the function has no return type:
  Error in declarator or parameters and qualifiers
  Invalid definition: Expected identifier in nested name, got keyword: void [error at 28]
    template<typename OWNER>void C::bad(OWNER & owner, void(OWNER::*)(void) callback)
    ----------------------------^
If the function has a return type:
  Error in declarator or parameters and qualifiers
  If pointer to member declarator:
    Invalid definition: Expected '::' in pointer to member (function). [error at 35]
      template<typename OWNER>void C::bad(OWNER & owner, void(OWNER::*)(void) callback)
      -----------------------------------^
  If declarator-id:
    Invalid definition: Expecting "," or ")" in parameters_and_qualifiers, got "c". [error at 72]
      template<typename OWNER>void C::bad(OWNER & owner, void(OWNER::*)(void) callback)
      ------------------------------------------------------------------------^
looking for now-outdated files... none found

The proposed fix is just a tweak to the regex that is trying to match a function pointer parameter type.

Please let me know if there is anything else I can do to help on this.

Thanks for providing Breathe too!

@vermeeren vermeeren self-assigned this Aug 1, 2019
@vermeeren vermeeren added bug Problem in existing code code Source code labels Aug 1, 2019
vermeeren added a commit that referenced this pull request Aug 1, 2019
Fix for template method pointer parameter issue
@vermeeren
Copy link
Collaborator

Hi, thanks for the patch, the modified regex seems fine.

Merged manually to cleanup the commits, will bump version and release breathe v4.13.1 in a bit.

@vermeeren vermeeren closed this Aug 1, 2019
vermeeren added a commit that referenced this pull request Aug 1, 2019
@darryllawson
Copy link
Contributor Author

Thank you so much for the lightning fast turn around! And for your broader efforts on Breathe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Problem in existing code code Source code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants