From 14f7d3e16c69900b12c74278793c6f6d0133bcb7 Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Thu, 2 Apr 2015 01:25:36 -0400 Subject: [PATCH] Bug 419614 - Work around a stack overflow caused by a circular reference between inline namespaces Change-Id: I1e55b0ddb47f888dab777ff4d5ea8f9a6e4d2e10 Signed-off-by: Nathan Ridge --- .../dom/parser/cpp/semantics/CPPSemantics.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java index ea25c117c41..ab80e3ef356 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java @@ -231,6 +231,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Conversions.UDCMod import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Cost.Rank; import org.eclipse.cdt.internal.core.index.IIndexScope; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; /** * Name resolution @@ -1075,12 +1076,24 @@ public class CPPSemantics { return false; } - private static void lookupInlineNamespaces(LookupData data, ICPPNamespaceScope namespace) throws DOMException { + private static void lookupInlineNamespaces(LookupData data, ICPPNamespaceScope namespace) + throws DOMException { + lookupInlineNamespaces(data, namespace, new HashSet()); + } + + private static void lookupInlineNamespaces(LookupData data, ICPPNamespaceScope namespace, + Set visited) throws DOMException { if (namespace instanceof ICPPInternalNamespaceScope) { ICPPInternalNamespaceScope ns= (ICPPInternalNamespaceScope) namespace; + visited.add(ns); for (ICPPInternalNamespaceScope inline : ns.getInlineNamespaces()) { + if (visited.contains(inline)) { + CCorePlugin.log(IStatus.WARNING, + "Detected circular reference between inline namespaces"); //$NON-NLS-1$ + continue; + } mergeResults(data, getBindingsFromScope(inline, data), true); - lookupInlineNamespaces(data, inline); + lookupInlineNamespaces(data, inline, visited); nominateNamespaces(data, inline); } }