1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00
- method reference after function call eg: get()->size()
This commit is contained in:
Andrew Niefer 2005-01-17 16:24:30 +00:00
parent 60e3bceae6
commit 8ee8577dc8
3 changed files with 39 additions and 3 deletions

View file

@ -1207,17 +1207,37 @@ public class CompleteParser2Tests extends TestCase {
public void testBug43679_A () throws Exception
{
parse( "struct Sample { int size() const; }; extern const Sample * getSample(); int trouble() { return getSample()->size(); } ", false ); //$NON-NLS-1$
IASTTranslationUnit tu = parse( "struct Sample { int size() const; }; extern const Sample * getSample(); int trouble() { return getSample()->size(); } " ); //$NON-NLS-1$
CPPNameCollector col = new CPPNameCollector();
CPPVisitor.visitTranslationUnit( tu, col );
assertEquals( col.size(), 7 );
ICompositeType sample = (ICompositeType) col.getName(0).resolveBinding();
ICPPMethod size = (ICPPMethod) col.getName(1).resolveBinding();
IFunction getSample = (IFunction) col.getName(3).resolveBinding();
assertInstances( col, sample, 2 );
assertInstances( col, size, 2 );
assertInstances( col, getSample, 2 );
}
public void testBug43679_B () throws Exception
{
parse( "struct Sample{int size() const; }; struct Sample; ", false ); //$NON-NLS-1$
IASTTranslationUnit tu = parse( "struct Sample{int size() const; }; struct Sample; " ); //$NON-NLS-1$
CPPNameCollector col = new CPPNameCollector();
CPPVisitor.visitTranslationUnit( tu, col );
assertEquals( col.size(), 3 );
ICompositeType sample = (ICompositeType) col.getName(0).resolveBinding();
ICPPMethod size = (ICPPMethod) col.getName(1).resolveBinding();
assertInstances( col, sample, 2 );
assertInstances( col, size, 1 );
}
public void testBug43951() throws Exception
{
parse( "class B{ B(); ~B(); }; B::B(){} B::~B(){}", false ); //$NON-NLS-1$
parse( "class B{ B(); ~B(); }; B::B(){} B::~B(){}" ); //$NON-NLS-1$
}
public void testBug44342() throws Exception {

View file

@ -31,4 +31,11 @@ public class CPPArrayType implements IArrayType, ITypeContainer {
public IType getType(){
return type;
}
public boolean equals(Object obj) {
if( obj instanceof IArrayType ){
return ((IArrayType) obj).getType().equals( type );
}
return false;
}
}

View file

@ -502,6 +502,8 @@ public class CPPVisitor {
return CPPSemantics.resolveBinding( ((IASTIdExpression)node).getName() );
} else if( node instanceof ICPPASTFieldReference ){
return CPPSemantics.resolveBinding( ((ICPPASTFieldReference)node).getFieldName() );
} else if( node instanceof IASTFunctionCallExpression ){
return resolveBinding( ((IASTFunctionCallExpression)node).getFunctionNameExpression() );
}
return null;
}
@ -1170,6 +1172,13 @@ public class CPPVisitor {
return new CPPPointerType( type );
}
} else if( expression instanceof IASTFunctionCallExpression ){
IBinding binding = resolveBinding( expression );
if( binding instanceof IFunction ){
IFunctionType fType = ((IFunction)binding).getType();
if( fType != null )
return fType.getReturnType();
}
}
return null;
}