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

Spurious error with function pointer as template argument #652

Closed
wintersteiger opened this issue Mar 3, 2021 · 2 comments · Fixed by sphinx-doc/sphinx#9122 or #681
Closed

Spurious error with function pointer as template argument #652

wintersteiger opened this issue Mar 3, 2021 · 2 comments · Fixed by sphinx-doc/sphinx#9122 or #681
Assignees
Labels
bug Problem in existing code code Source code

Comments

@wintersteiger
Copy link

Describe the bug

For this:

/// @brief A template class
template <void (*F)()>
class C {};

Sphinx complains thusly:

| [(DefinitionError('Invalid C++ declaration: Expected "," or ">". [error at 19]\n  template<void(*)() F> C\n  -------------------^'), 'If no parameter')]
|/data/cwinter/breathe/source/index.rst:11: WARNING: Error in template parameter list.
Invalid C++ declaration: Expected "," or ">". [error at 19]
  template<void(*)() F> C
  -------------------^

To Reproduce

Copy source snippet above into .h file and run Sphinx with Breathe extension enabled (see project files)

$ sphinx-autobuild source build

Expected behavior

Don't throw an error and produce the right type names. (When the error is thrown some types are assigned names with PhonyNameDueToError.)

Your project

sphinx-templates.zip

Environment info

  • OS: Ubuntu 18.04
  • Python version: 3.8.0
  • Sphinx version: 3.5.1
  • Sphinx extensions: breathe
  • Extra tools: doxygen 1.9.2

(From sphinx-doc/sphinx#8953)

@jakobandersen
Copy link
Collaborator

This is quite an icky bug. The XML for C is

<compounddef id="classC" kind="class" language="C++" prot="public">
  <compoundname>C</compoundname>
  <includes refid="test_8hpp" local="no">test.hpp</includes>
  <templateparamlist>
    <param>
      <type>void(*)()</type>
      <declname>F</declname>
      <defname>F</defname>
    </param>
  </templateparamlist>
  ...
</compounddef>

I don't see a generic way of getting the parameter name F in the correct part of the type void (*)() without parsing the type, in the general case.
I suggest using the Sphinx C++ parser to get the AST to assemble the paramter the right way.

@wintersteiger
Copy link
Author

Yes, I think it's impossible to do this without parsing the type. I'm not familiar with the Sphinx C++ parser - is that in some way configurable by the end-user or would this require changes to the parser implementation?

jakobandersen added a commit to jakobandersen/breathe that referenced this issue Apr 20, 2021
Uses internals in the C++ domain.
Needs Sphinx 4.1.

Fixes breathe-doc#652
jakobandersen added a commit to jakobandersen/breathe that referenced this issue Apr 20, 2021
Uses internals in the C++ domain.
Needs Sphinx 4.1.

Fixes breathe-doc#652
jakobandersen added a commit to jakobandersen/breathe that referenced this issue Apr 20, 2021
Uses internals in the C++ domain.
Needs Sphinx 4.1.

Fixes breathe-doc#652
@vermeeren vermeeren added bug Problem in existing code code Source code labels Apr 23, 2021
vermeeren pushed a commit to jakobandersen/breathe that referenced this issue Apr 23, 2021
Uses internals in the C++ domain.
Needs Sphinx 4.1.

Fixes breathe-doc#652
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
3 participants