From 051ba1b4c59eda267c740f86f2876dae65b29c05 Mon Sep 17 00:00:00 2001 From: Jakob Lykke Andersen Date: Thu, 11 Oct 2018 22:33:11 +0200 Subject: [PATCH] C++, fix assertion on multiple duplicate symbols If a symbol was declared more than 2 times, it would crash. Fixes sphinx-doc/sphinx#5496. --- CHANGES | 1 + sphinx/domains/cpp.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGES b/CHANGES index 00ebf1e76..1b1827117 100644 --- a/CHANGES +++ b/CHANGES @@ -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 -------- diff --git a/sphinx/domains/cpp.py b/sphinx/domains/cpp.py index a3be2276f..9c8b3a3c6 100644 --- a/sphinx/domains/cpp.py +++ b/sphinx/domains/cpp.py @@ -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.