Skip to content

Commit fddbd7d

Browse files
Add new duplicate_declaration.{c,cpp} warning types (#13173)
Co-authored-by: Adam Turner <[email protected]>
1 parent 504eeca commit fddbd7d

File tree

6 files changed

+17
-0
lines changed

6 files changed

+17
-0
lines changed

CHANGES.rst

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ Deprecated
1818
Features added
1919
--------------
2020

21+
* Add a new ``duplicate_declaration`` warning type,
22+
with ``duplicate_declaration.c`` and ``duplicate_declaration.cpp`` subtypes.
23+
Patch by Julien Lecomte and Adam Turner.
24+
2125
Bugs fixed
2226
----------
2327

doc/usage/configuration.rst

+5
Original file line numberDiff line numberDiff line change
@@ -1374,6 +1374,8 @@ Options for warning control
13741374
* ``config.cache``
13751375
* ``docutils``
13761376
* ``download.not_readable``
1377+
* ``duplicate_declaration.c``
1378+
* ``duplicate_declaration.cpp``
13771379
* ``epub.unknown_project_files``
13781380
* ``epub.duplicated_toc_entry``
13791381
* ``i18n.inconsistent_references``
@@ -1444,6 +1446,9 @@ Options for warning control
14441446
.. versionadded:: 8.0
14451447
Added ``misc.copy_overwrite``.
14461448

1449+
.. versionadded:: 8.2
1450+
Added ``duplicate_declaration.c`` and ``duplicate_declaration.cpp``.
1451+
14471452

14481453
Builder options
14491454
===============

sphinx/domains/c/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ def handle_signature(self, sig: str, signode: TextElement) -> ASTDeclaration:
284284
self.display_object_type,
285285
sig,
286286
location=signode,
287+
type='duplicate_declaration',
288+
subtype='c',
287289
)
288290

289291
if ast.objectType == 'enumerator':

sphinx/domains/c/_symbol.py

+2
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,8 @@ def merge_with(
548548
our_child.declaration.directiveType,
549549
name,
550550
location=(other_child.docname, other_child.line),
551+
type='duplicate_declaration',
552+
subtype='c',
551553
)
552554
else:
553555
# Both have declarations, and in the same docname.

sphinx/domains/cpp/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,8 @@ def handle_signature(self, sig: str, signode: desc_signature) -> ASTDeclaration:
397397
self.display_object_type,
398398
sig,
399399
location=signode,
400+
type='duplicate_declaration',
401+
subtype='cpp',
400402
)
401403

402404
if ast.objectType == 'enumerator':

sphinx/domains/cpp/_symbol.py

+2
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,8 @@ def unconditional_add(self: Symbol, other_child: Symbol) -> None:
895895
our_child.declaration.directiveType,
896896
name,
897897
location=(other_child.docname, other_child.line),
898+
type='duplicate_declaration',
899+
subtype='cpp',
898900
)
899901
else:
900902
our_object_type = our_child.declaration.objectType

0 commit comments

Comments
 (0)