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:
parent
21b09a659c
commit
f61f0b09a6
2 changed files with 14 additions and 10 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* 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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -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.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
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.IASTAmbiguityParent;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
|
|
||||||
|
|
||||||
public abstract class CASTAmbiguity extends CASTNode {
|
public abstract class CASTAmbiguity extends CASTNode {
|
||||||
|
|
||||||
|
@ -73,7 +72,7 @@ public abstract class CASTAmbiguity extends CASTNode {
|
||||||
IBinding b = names[j].resolveBinding();
|
IBinding b = names[j].resolveBinding();
|
||||||
if( b == null || b instanceof IProblemBinding )
|
if( b == null || b instanceof IProblemBinding )
|
||||||
++issues[i];
|
++issues[i];
|
||||||
IScope scope = CPPVisitor.getContainingScope( names[j] );
|
IScope scope = CVisitor.getContainingScope( names[j] );
|
||||||
if( scope != null )
|
if( scope != null )
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -818,6 +818,15 @@ public class CPPVisitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IScope getContainingScope( IASTName name ){
|
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();
|
IASTNode parent = name.getParent();
|
||||||
try {
|
try {
|
||||||
if( parent instanceof ICPPASTTemplateId ){
|
if( parent instanceof ICPPASTTemplateId ){
|
||||||
|
@ -883,11 +892,7 @@ public class CPPVisitor {
|
||||||
}
|
}
|
||||||
type = CPPSemantics.getUltimateType( type, false );
|
type = CPPSemantics.getUltimateType( type, false );
|
||||||
if( type instanceof ICPPClassType ){
|
if( type instanceof ICPPClassType ){
|
||||||
IScope scope= ((ICPPClassType) type).getCompositeScope();
|
return ((ICPPClassType) type).getCompositeScope();
|
||||||
if (scope == null) {
|
|
||||||
scope= new CPPScope.CPPScopeProblem(fieldReference, IProblemBinding.SEMANTIC_BAD_SCOPE, name.toCharArray() );
|
|
||||||
}
|
|
||||||
return scope;
|
|
||||||
}
|
}
|
||||||
} else if( parent instanceof IASTGotoStatement || parent instanceof IASTLabelStatement ){
|
} else if( parent instanceof IASTGotoStatement || parent instanceof IASTLabelStatement ){
|
||||||
while( !(parent instanceof IASTFunctionDefinition) ){
|
while( !(parent instanceof IASTFunctionDefinition) ){
|
||||||
|
|
Loading…
Add table
Reference in a new issue