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

C++, fix parsing of defaulted function parameters that are function pointers #9553

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES
Expand Up @@ -36,6 +36,8 @@ Bugs fixed
* #9456: html search: abbreation marks are inserted to the search result if
failed to fetch the content of the page
* #9267: html theme: CSS and JS files added by theme were loaded twice
* #9535 comment: C++, fix parsing of defaulted function parameters that are
function pointers.

Testing
--------
Expand Down
10 changes: 2 additions & 8 deletions sphinx/domains/cpp.py
Expand Up @@ -5936,13 +5936,6 @@ def _parse_parameters_and_qualifiers(self, paramMode: str) -> ASTParametersQuali
'Expecting "," or ")" in parameters-and-qualifiers, '
'got "%s".' % self.current_char)

# TODO: why did we have this bail-out?
# does it hurt to parse the extra stuff?
# it's needed for pointer to member functions
if paramMode != 'function' and False:
return ASTParametersQualifiers(
args, None, None, None, None, None, None, None)

self.skip_ws()
const = self.skip_word_and_ws('const')
volatile = self.skip_word_and_ws('volatile')
Expand Down Expand Up @@ -5989,7 +5982,8 @@ def _parse_parameters_and_qualifiers(self, paramMode: str) -> ASTParametersQuali

self.skip_ws()
initializer = None
if self.skip_string('='):
# if this is a function pointer we should not swallow an initializer
if paramMode == 'function' and self.skip_string('='):
self.skip_ws()
valid = ('0', 'delete', 'default')
for w in valid:
Expand Down
3 changes: 3 additions & 0 deletions tests/test_domain_cpp.py
Expand Up @@ -639,6 +639,9 @@ def test_domain_cpp_ast_function_definitions():
# from #8960
check('function', 'void f(void (*p)(int, double), int i)', {2: '1fPFvidEi'})

# from #9535 comment
check('function', 'void f(void (*p)(int) = &foo)', {2: '1fPFviE'})


def test_domain_cpp_ast_operators():
check('function', 'void operator new()', {1: "new-operator", 2: "nwv"})
Expand Down