summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Lykke Andersen <Jakob@caput.dk>2021-08-15 17:24:14 +0200
committerJakob Lykke Andersen <Jakob@caput.dk>2021-08-20 18:17:42 +0200
commit73c1520923c76835ea17f9e87af14b51dc83f2c2 (patch)
tree9f95a480fa2259e7198cad0f28cf48982d7047a1
parent5a3e119d5ef754f6f6232e4a10afdb409c9a8287 (diff)
downloadsphinx-git-73c1520923c76835ea17f9e87af14b51dc83f2c2.tar.gz
C++, fix parsing of defaulted fp function params
-rw-r--r--CHANGES2
-rw-r--r--sphinx/domains/cpp.py10
-rw-r--r--tests/test_domain_cpp.py3
3 files changed, 7 insertions, 8 deletions
diff --git a/CHANGES b/CHANGES
index 6b94312a8..55ccdf146 100644
--- a/CHANGES
+++ b/CHANGES
@@ -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
--------
diff --git a/sphinx/domains/cpp.py b/sphinx/domains/cpp.py
index 0d8aee019..f82445099 100644
--- a/sphinx/domains/cpp.py
+++ b/sphinx/domains/cpp.py
@@ -5936,13 +5936,6 @@ class DefinitionParser(BaseParser):
'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')
@@ -5989,7 +5982,8 @@ class DefinitionParser(BaseParser):
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:
diff --git a/tests/test_domain_cpp.py b/tests/test_domain_cpp.py
index b1fffb89c..ede4a2531 100644
--- a/tests/test_domain_cpp.py
+++ b/tests/test_domain_cpp.py
@@ -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"})