C++, fix assertion on multiple duplicate symbols

If a symbol was declared more than 2 times, it would crash.

Fixes sphinx-doc/sphinx#5496.
This commit is contained in:
Jakob Lykke Andersen 2018-10-11 22:33:11 +02:00
parent 9875a57622
commit 051ba1b4c5
2 changed files with 7 additions and 0 deletions

View File

@ -19,6 +19,7 @@ Bugs fixed
* #5490: latex: enumerated list causes a crash with recommonmark
* #5492: sphinx-build fails to build docs w/ Python < 3.5.2
* #3704: latex: wrong ``\label`` positioning for figures with a legend
* #5496: C++, fix assertion when a symbol is declared more than twice.
Testing
--------

View File

@ -4014,14 +4014,20 @@ class Symbol(object):
noDecl = []
withDecl = []
dupDecl = []
for s in symbols:
if s.declaration is None:
noDecl.append(s)
elif s.isRedeclaration:
dupDecl.append(s)
else:
withDecl.append(s)
if Symbol.debug_lookup:
print(" #noDecl: ", len(noDecl))
print(" #withDecl:", len(withDecl))
print(" #dupDecl: ", len(dupDecl))
if len(dupDecl) > 0:
assert len(withDecl) > 0
# assert len(noDecl) <= 1 # we should fill in symbols when they are there
# TODO: enable assertion when we at some point find out how to do cleanup
# With partial builds we may start with a large symbol tree stripped of declarations.