Skip to content

Commit df3d647

Browse files
committed
C++, fix parsing of types prefixed with 'enum'.
Fixes breathe-doc/breathe#223.
1 parent 3fb3fdb commit df3d647

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Bugs fixed
6868
* C++, add missing support for 'friend' functions.
6969
* C++, add missing support for virtual base classes (thanks to Rapptz).
7070
* C++, add support for final classes.
71+
* C++, fix parsing of types prefixed with 'enum'.
7172

7273
Documentation
7374
-------------

sphinx/domains/cpp.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@
3838
All versions are generated and attached to elements. The newest is used for
3939
the index. All of the versions should work as permalinks.
4040
41-
See http://www.nongnu.org/hcb/ for the grammar.
41+
See http://www.nongnu.org/hcb/ for the grammar,
42+
or https://github.com/cplusplus/draft/blob/master/source/grammar.tex
43+
for the newest grammar.
4244
4345
common grammar things:
4446
template-declaration ->
@@ -2387,7 +2389,7 @@ class DefinitionParser(object):
23872389
'float', 'double', 'auto'
23882390
)
23892391

2390-
_prefix_keys = ('class', 'struct', 'union', 'typename')
2392+
_prefix_keys = ('class', 'struct', 'enum', 'union', 'typename')
23912393

23922394
def __init__(self, definition, warnEnv):
23932395
self.definition = definition.strip()

tests/test_domain_cpp.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,13 @@ def test_type_definitions():
226226
check('function', 'friend std::ostream &f(std::ostream&, int)',
227227
'f__osR.i', '1fRNSt7ostreamEi')
228228

229+
# from breathe#223
230+
check('function', 'void f(struct E e)', 'f__E', '1f1E')
231+
check('function', 'void f(class E e)', 'f__E', '1f1E')
232+
check('function', 'void f(typename E e)', 'f__E', '1f1E')
233+
check('function', 'void f(enum E e)', 'f__E', '1f1E')
234+
check('function', 'void f(union E e)', 'f__E', '1f1E')
235+
229236
check('class', 'public A', "A", "1A", output='A')
230237
check('class', 'private A', "A", "1A")
231238

0 commit comments

Comments
 (0)