1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fixes 2 exceptions in name resolution, bug 211457.

This commit is contained in:
Markus Schorn 2007-12-07 12:29:22 +00:00
parent 21b09a659c
commit f61f0b09a6
2 changed files with 14 additions and 10 deletions

View file

@ -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 {

View file

@ -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) ){