diff --git a/sphinx/domains/cpp.py b/sphinx/domains/cpp.py index b7ecc1651..7dd1d0c03 100644 --- a/sphinx/domains/cpp.py +++ b/sphinx/domains/cpp.py @@ -7017,8 +7017,7 @@ class DefinitionParser(BaseParser): declaration = self._parse_type_with_init(named=True, outer='member') elif objectType == 'function': declaration = self._parse_type(named=True, outer='function') - if templatePrefix is not None: - trailingRequiresClause = self._parse_requires_clause() + trailingRequiresClause = self._parse_requires_clause() elif objectType == 'class': declaration = self._parse_class() elif objectType == 'union': diff --git a/tests/test_domain_cpp.py b/tests/test_domain_cpp.py index 97b887b9a..9159b1851 100644 --- a/tests/test_domain_cpp.py +++ b/tests/test_domain_cpp.py @@ -891,6 +891,8 @@ def test_domain_cpp_ast_requires_clauses(): {4: 'I0EIQaa1A1BE1fvv'}) check('function', 'template requires A || B or C void f()', {4: 'I0EIQoo1Aoo1B1CE1fvv'}) + check('function', 'void f() requires A || B || C', + {4: 'IQoo1Aoo1B1CE1fv'}) check('function', 'template requires A && B || C and D void f()', {4: 'I0EIQooaa1A1Baa1C1DE1fvv'}) check('function',