mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
fix bug 95484
This commit is contained in:
parent
be56e7fcc7
commit
47c79f6013
2 changed files with 26 additions and 0 deletions
|
@ -4084,4 +4084,20 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
ICPPFunction f1 = (ICPPFunction) col.getName(0).resolveBinding();
|
||||
assertSame( f1, col.getName(4).resolveBinding() );
|
||||
}
|
||||
|
||||
public void testBug95484() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("class X { public: int bar; }; \n"); //$NON-NLS-1$
|
||||
buffer.append("void f(){ \n"); //$NON-NLS-1$
|
||||
buffer.append(" X a[10]; \n"); //$NON-NLS-1$
|
||||
buffer.append(" a[0].bar; \n"); //$NON-NLS-1$
|
||||
buffer.append("} \n"); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPField bar = (ICPPField) col.getName(1).resolveBinding();
|
||||
assertSame( bar, col.getName(6).resolveBinding() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
|||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||
|
@ -1736,6 +1737,15 @@ public class CPPVisitor {
|
|||
return new CPPBasicType( IBasicType.t_int, CPPBasicType.IS_LONG | CPPBasicType.IS_UNSIGNED );
|
||||
}
|
||||
return createType( typeidExp.getTypeId() );
|
||||
} else if( expression instanceof IASTArraySubscriptExpression ){
|
||||
IType t = getExpressionType( ((IASTArraySubscriptExpression) expression).getArrayExpression() );
|
||||
try {
|
||||
if( t instanceof IPointerType )
|
||||
return ((IPointerType)t).getType();
|
||||
else if( t instanceof IArrayType )
|
||||
return ((IArrayType)t).getType();
|
||||
} catch( DOMException e ){
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue