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

Function declaration parsing error depending on the order of static and constrexpr #717

Closed
gomezzz opened this issue Jul 27, 2021 · 2 comments · Fixed by #720
Closed

Function declaration parsing error depending on the order of static and constrexpr #717

gomezzz opened this issue Jul 27, 2021 · 2 comments · Fixed by #720

Comments

@gomezzz
Copy link

gomezzz commented Jul 27, 2021

The following function declaration

[[nodiscard]] constexpr static auto getNeededAttr(std::false_type) { return getNeededAttr(); }

leads to this error:

WARNING: Error when parsing function declaration.
If the function has no return type:
  Error in declarator or parameters-and-qualifiers
  Invalid C++ declaration: Expected identifier in nested name, got keyword: static [error at 30]
    static inline constexpr static auto getNeededAttr (std::false_type)
    ------------------------------^
If the function has a return type:
  Invalid C++ declaration: Expected identifier in nested name, got keyword: static [error at 30]
    static inline constexpr static auto getNeededAttr (std::false_type)
    ------------------------------^

However, simply switching constexpr and static s.t.

[[nodiscard]] static constexpr auto getNeededAttr(std::false_type) { return getNeededAttr(); }

solves the problem. This happens with breathe 4.30. Both versions compile fine with clang.

Another example of a function where this happened is

[[nodiscard]] constexpr static std::array<typename Debris::AttributeNames, 0> getComputedAttr() {
   return std::array<typename Debris::AttributeNames, 0>{/*Nothing*/};
 };

Let me know if you require any additional info :)

jakobandersen added a commit to jakobandersen/breathe that referenced this issue Jul 27, 2021
jakobandersen added a commit to jakobandersen/breathe that referenced this issue Jul 27, 2021
@jakobandersen
Copy link
Collaborator

I get the same problem with Doxygen 1.9.1. Which version did you happen to use?
It looks like Doxygen generates strange XML depending on the order of the decl-specifiers:
For the first version (here called f1):

      <memberdef kind="function" id="test_8hpp_1a11e87c94126e34afdd9b4e0d84163949" prot="public" static="yes" constexpr="yes" const="no" explicit="no" inline="no" virt="non-virtual">
        <type>constexpr static auto</type>
        <definition>constexpr static auto f1</definition>
        <argsstring>(std::false_type)</argsstring>

Notice both static and constexpr are in the <type> field, which they shouldn't, as the attributes of the <memberdef> has that info.
For the second version (here called f2):

      <memberdef kind="function" id="test_8hpp_1ae071a908bccdee2c4c63dc1c4cd2558a" prot="public" static="yes" constexpr="yes" const="no" explicit="no" inline="no" virt="non-virtual">
        <type>constexpr auto</type>
        <definition>static constexpr auto f2</definition>
        <argsstring>(std::false_type)</argsstring>

No static, but constexpr is still there.

I have posted PR #720 which should fix this extra static.
While the constexpr part should be fixed as well, the XML parser doesn't handle it, so it all turns out good in the end (for now).

@gomezzz
Copy link
Author

gomezzz commented Jul 28, 2021

I was also using Doxygen 1.9.1

jakobandersen added a commit to jakobandersen/breathe that referenced this issue Sep 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants