mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-07 16:26:11 +02:00
bug 92791: more problem reporting from C
This commit is contained in:
parent
8668326658
commit
cd54f2cfa5
2 changed files with 32 additions and 3 deletions
|
@ -3067,4 +3067,18 @@ public class AST2Tests extends AST2BaseTest {
|
|||
assertSame( bs[1], S1 );
|
||||
assertSame( bs[2], S4 );
|
||||
}
|
||||
|
||||
public void test92791() throws Exception {
|
||||
IASTTranslationUnit tu = parse( "int x, y; x * y;", ParserLanguage.C ); //$NON-NLS-1$
|
||||
CNameCollector col = new CNameCollector();
|
||||
tu.accept( col );
|
||||
|
||||
assertTrue( col.getName(2).resolveBinding() instanceof IProblemBinding );
|
||||
|
||||
tu = parse( "void f() { typedef int x; int y; x * y; }", ParserLanguage.C ); //$NON-NLS-1$
|
||||
col = new CNameCollector();
|
||||
tu.accept( col );
|
||||
|
||||
assertTrue( col.getName(3).resolveBinding() instanceof IProblemBinding );
|
||||
}
|
||||
}
|
|
@ -815,14 +815,22 @@ public class CVisitor {
|
|||
} else if( node instanceof IASTIdExpression ){
|
||||
IASTNode blockItem = getContainingBlockItem( node );
|
||||
try {
|
||||
return (IBinding) findBinding( blockItem, ((IASTIdExpression)node).getName(), bits );
|
||||
IBinding binding = (IBinding) findBinding( blockItem, ((IASTIdExpression)node).getName(), bits );
|
||||
if( binding instanceof IType ){
|
||||
return new ProblemBinding( node, IProblemBinding.SEMANTIC_INVALID_TYPE, binding.getNameCharArray() );
|
||||
}
|
||||
return binding;
|
||||
} catch ( DOMException e ) {
|
||||
return null;
|
||||
}
|
||||
} else if( node instanceof ICASTTypedefNameSpecifier ){
|
||||
IASTNode blockItem = getContainingBlockItem( node );
|
||||
try {
|
||||
return (IBinding) findBinding( blockItem, ((ICASTTypedefNameSpecifier)node).getName(), bits );
|
||||
IBinding binding = (IBinding) findBinding( blockItem, ((ICASTTypedefNameSpecifier)node).getName(), bits );
|
||||
if( binding instanceof IType )
|
||||
return binding;
|
||||
else if( binding != null )
|
||||
return new ProblemBinding( node, IProblemBinding.SEMANTIC_INVALID_TYPE, binding.getNameCharArray() );
|
||||
} catch ( DOMException e ) {
|
||||
return null;
|
||||
}
|
||||
|
@ -848,9 +856,16 @@ public class CVisitor {
|
|||
name = ((ICASTElaboratedTypeSpecifier)declSpec).getName();
|
||||
} else if( declSpec instanceof ICASTCompositeTypeSpecifier ){
|
||||
name = ((ICASTCompositeTypeSpecifier)declSpec).getName();
|
||||
} else if( declSpec instanceof ICASTTypedefNameSpecifier ){
|
||||
name = ((ICASTTypedefNameSpecifier)declSpec).getName();
|
||||
}
|
||||
if( name != null ){
|
||||
return name.resolveBinding();
|
||||
IBinding binding = name.resolveBinding();
|
||||
if( binding instanceof IType )
|
||||
return binding;
|
||||
else if( binding != null )
|
||||
return new ProblemBinding( node, IProblemBinding.SEMANTIC_INVALID_TYPE, binding.getNameCharArray() );
|
||||
return null;
|
||||
}
|
||||
} else if( node instanceof ICASTFieldDesignator ) {
|
||||
IASTNode blockItem = getContainingBlockItem( node );
|
||||
|
|
Loading…
Add table
Reference in a new issue