mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
C, properly error on keywords as function parameters
This commit is contained in:
2
CHANGES
2
CHANGES
@@ -77,6 +77,8 @@ Bugs fixed
|
||||
with size explicitly set in pixels) (fixed for ``'pdflatex'/'lualatex'`` only)
|
||||
* #8911: C++: remove the longest matching prefix in
|
||||
:confval:`cpp_index_common_prefix` instead of the first that matches.
|
||||
* C, properly reject function declarations when a keyword is used
|
||||
as parameter name.
|
||||
|
||||
Testing
|
||||
--------
|
||||
|
||||
@@ -2703,6 +2703,9 @@ class DefinitionParser(BaseParser):
|
||||
declId = None
|
||||
elif named == 'single':
|
||||
if self.match(identifier_re):
|
||||
if self.matched_text in _keywords:
|
||||
self.fail("Expected identifier, "
|
||||
"got keyword: %s" % self.matched_text)
|
||||
identifier = ASTIdentifier(self.matched_text)
|
||||
declId = ASTNestedName([identifier], rooted=False)
|
||||
else:
|
||||
|
||||
@@ -417,6 +417,9 @@ def test_function_definitions():
|
||||
check('function', 'void f(int arr[const static volatile 42])', {1: 'f'},
|
||||
output='void f(int arr[static volatile const 42])')
|
||||
|
||||
with pytest.raises(DefinitionError):
|
||||
parse('function', 'void f(int for)')
|
||||
|
||||
|
||||
def test_nested_name():
|
||||
check('struct', '{key}.A', {1: "A"})
|
||||
|
||||
Reference in New Issue
Block a user