Skip to content

Commit 73c1520

Browse files
committed
C++, fix parsing of defaulted fp function params
1 parent 5a3e119 commit 73c1520

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Bugs fixed
3636
* #9456: html search: abbreation marks are inserted to the search result if
3737
failed to fetch the content of the page
3838
* #9267: html theme: CSS and JS files added by theme were loaded twice
39+
* #9535 comment: C++, fix parsing of defaulted function parameters that are
40+
function pointers.
3941

4042
Testing
4143
--------

sphinx/domains/cpp.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5936,13 +5936,6 @@ def _parse_parameters_and_qualifiers(self, paramMode: str) -> ASTParametersQuali
59365936
'Expecting "," or ")" in parameters-and-qualifiers, '
59375937
'got "%s".' % self.current_char)
59385938

5939-
# TODO: why did we have this bail-out?
5940-
# does it hurt to parse the extra stuff?
5941-
# it's needed for pointer to member functions
5942-
if paramMode != 'function' and False:
5943-
return ASTParametersQualifiers(
5944-
args, None, None, None, None, None, None, None)
5945-
59465939
self.skip_ws()
59475940
const = self.skip_word_and_ws('const')
59485941
volatile = self.skip_word_and_ws('volatile')
@@ -5989,7 +5982,8 @@ def _parse_parameters_and_qualifiers(self, paramMode: str) -> ASTParametersQuali
59895982

59905983
self.skip_ws()
59915984
initializer = None
5992-
if self.skip_string('='):
5985+
# if this is a function pointer we should not swallow an initializer
5986+
if paramMode == 'function' and self.skip_string('='):
59935987
self.skip_ws()
59945988
valid = ('0', 'delete', 'default')
59955989
for w in valid:

tests/test_domain_cpp.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,9 @@ def test_domain_cpp_ast_function_definitions():
639639
# from #8960
640640
check('function', 'void f(void (*p)(int, double), int i)', {2: '1fPFvidEi'})
641641

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

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

0 commit comments

Comments
 (0)