From f2e7ffec5465b4f52005e82555b3bbebb1ea258a Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Mon, 1 Jun 2015 10:24:02 -0700 Subject: [PATCH] Bug 469023 - UnsupportedOperationException in CPPVisitor.createBinding Change-Id: I10653fc6a23364d0977d3f7dc6e92b84812bf5bb --- .../core/dom/parser/cpp/semantics/CPPVisitor.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java index c3e27ab96e9..4f3c31e7d5e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java @@ -549,8 +549,9 @@ public class CPPVisitor extends ASTQueries { } } if (scope instanceof ICPPClassScope && isFriend && !qualified) { - while (scope instanceof ICPPClassScope) + while (scope instanceof ICPPClassScope) { scope = (ICPPScope) getParentScope(scope, elabType.getTranslationUnit()); + } } if (scope != null) { binding = scope.getBinding(elabType.getName(), false); @@ -2500,8 +2501,9 @@ public class CPPVisitor extends ASTQueries { private static IScope getParentScope(IScope scope, IASTTranslationUnit unit) throws DOMException { IScope parentScope= scope.getParent(); - // the index cannot return the translation unit as parent scope - if (parentScope == null && scope instanceof IIndexScope && unit != null) { + // Replace the global scope from index with the global scope of the translation unit. + if ((parentScope == null || parentScope.getKind() == EScopeKind.eGlobal) && + scope instanceof IIndexScope && unit != null) { parentScope= unit.getScope(); } return parentScope;