mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
bug 91006
recursive loop resolving typedefs
This commit is contained in:
parent
e4ecea9c92
commit
8ca6992323
3 changed files with 25 additions and 9 deletions
|
@ -3549,5 +3549,19 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
assertTrue( I8.getType() instanceof IBasicType );
|
||||
assertEquals( ((IBasicType)I8.getType()).getType(), IBasicType.t_char );
|
||||
}
|
||||
|
||||
public void testBug90623_2() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append( "typedef int I; \n"); //$NON-NLS-1$
|
||||
buffer.append( "void f11( I i ); \n"); //$NON-NLS-1$
|
||||
buffer.append( "void main(){ f a; } \n"); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP ); //$NON-NLS-1$
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept( col );
|
||||
|
||||
IASTName f = col.getName( 5 );
|
||||
f.resolvePrefix();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1324,9 +1324,11 @@ public class CPPSemantics {
|
|||
if( bindings == null || bindings.length == 0 )
|
||||
return null;
|
||||
else if( bindings.length == 1 ){
|
||||
if( bindings[0] instanceof IASTName )
|
||||
return ((IASTName) bindings[ 0 ]).resolveBinding();
|
||||
return (IBinding) bindings[0];
|
||||
if( bindings[0] instanceof IBinding )
|
||||
return (IBinding) bindings[0];
|
||||
else if( bindings[0] instanceof IASTName && ((IASTName) bindings[0]).getBinding() != null )
|
||||
return ((IASTName) bindings[ 0 ]).getBinding();
|
||||
|
||||
}
|
||||
|
||||
if( name.getPropertyInParent() != STRING_LOOKUP_PROPERTY ) {
|
||||
|
|
|
@ -99,12 +99,12 @@ public class CPPTypedef implements ITypedef, ITypeContainer, ICPPInternalBinding
|
|||
public IType getType() {
|
||||
if( type == null ){
|
||||
type = CPPVisitor.createType( (IASTDeclarator) typedefName.getParent() );
|
||||
if( type instanceof ITypedef ){
|
||||
try {
|
||||
type = ((ITypedef)type).getType();
|
||||
} catch ( DOMException e ) {
|
||||
}
|
||||
}
|
||||
// if( type instanceof ITypedef ){
|
||||
// try {
|
||||
// type = ((ITypedef)type).getType();
|
||||
// } catch ( DOMException e ) {
|
||||
// }
|
||||
// }
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue