From f61f0b09a6fc9a2f3418dbb7bf2f7e1c508a3fcb Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Fri, 7 Dec 2007 12:29:22 +0000 Subject: [PATCH] Fixes 2 exceptions in name resolution, bug 211457. --- .../internal/core/dom/parser/c/CASTAmbiguity.java | 9 ++++----- .../internal/core/dom/parser/cpp/CPPVisitor.java | 15 ++++++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguity.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguity.java index 6499fb1f48c..6cbf1ad301e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguity.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguity.java @@ -1,13 +1,13 @@ /******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. + * Copyright (c) 2004, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -24,7 +24,6 @@ import org.eclipse.cdt.core.dom.ast.c.CASTVisitor; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor; public abstract class CASTAmbiguity extends CASTNode { @@ -73,7 +72,7 @@ public abstract class CASTAmbiguity extends CASTNode { IBinding b = names[j].resolveBinding(); if( b == null || b instanceof IProblemBinding ) ++issues[i]; - IScope scope = CPPVisitor.getContainingScope( names[j] ); + IScope scope = CVisitor.getContainingScope( names[j] ); if( scope != null ) { try { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java index 28ca0c9ce63..f43648e0796 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java @@ -818,6 +818,15 @@ public class CPPVisitor { } public static IScope getContainingScope( IASTName name ){ + IScope scope= getContainingScopeOrNull(name); + if (scope == null) { + return new CPPScope.CPPScopeProblem( name, IProblemBinding.SEMANTIC_BAD_SCOPE, name.toCharArray() ); + } + + return scope; + } + + private static IScope getContainingScopeOrNull(IASTName name) { IASTNode parent = name.getParent(); try { if( parent instanceof ICPPASTTemplateId ){ @@ -883,11 +892,7 @@ public class CPPVisitor { } type = CPPSemantics.getUltimateType( type, false ); if( type instanceof ICPPClassType ){ - IScope scope= ((ICPPClassType) type).getCompositeScope(); - if (scope == null) { - scope= new CPPScope.CPPScopeProblem(fieldReference, IProblemBinding.SEMANTIC_BAD_SCOPE, name.toCharArray() ); - } - return scope; + return ((ICPPClassType) type).getCompositeScope(); } } else if( parent instanceof IASTGotoStatement || parent instanceof IASTLabelStatement ){ while( !(parent instanceof IASTFunctionDefinition) ){