Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2015-04-02 05:25:36 +0000
committerNathan Ridge2015-04-02 05:25:36 +0000
commit14f7d3e16c69900b12c74278793c6f6d0133bcb7 (patch)
tree80ae9c310749e061056812c31d6a340b18a2bb4a
parent184730559ba91c4554d4e9a5479662066f727893 (diff)
downloadorg.eclipse.cdt-14f7d3e16c69900b12c74278793c6f6d0133bcb7.tar.gz
org.eclipse.cdt-14f7d3e16c69900b12c74278793c6f6d0133bcb7.tar.xz
org.eclipse.cdt-14f7d3e16c69900b12c74278793c6f6d0133bcb7.zip
Bug 419614 - Work around a stack overflow caused by a circular reference
between inline namespaces Change-Id: I1e55b0ddb47f888dab777ff4d5ea8f9a6e4d2e10 Signed-off-by: Nathan Ridge <zeratul976@hotmail.com>
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java17
1 files 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<ICPPInternalNamespaceScope>());
+ }
+
+ private static void lookupInlineNamespaces(LookupData data, ICPPNamespaceScope namespace,
+ Set<ICPPInternalNamespaceScope> 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);
}
}

Back to the top