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 );
|
assertTrue( I8.getType() instanceof IBasicType );
|
||||||
assertEquals( ((IBasicType)I8.getType()).getType(), IBasicType.t_char );
|
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 )
|
if( bindings == null || bindings.length == 0 )
|
||||||
return null;
|
return null;
|
||||||
else if( bindings.length == 1 ){
|
else if( bindings.length == 1 ){
|
||||||
if( bindings[0] instanceof IASTName )
|
if( bindings[0] instanceof IBinding )
|
||||||
return ((IASTName) bindings[ 0 ]).resolveBinding();
|
|
||||||
return (IBinding) bindings[0];
|
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 ) {
|
if( name.getPropertyInParent() != STRING_LOOKUP_PROPERTY ) {
|
||||||
|
|
|
@ -99,12 +99,12 @@ public class CPPTypedef implements ITypedef, ITypeContainer, ICPPInternalBinding
|
||||||
public IType getType() {
|
public IType getType() {
|
||||||
if( type == null ){
|
if( type == null ){
|
||||||
type = CPPVisitor.createType( (IASTDeclarator) typedefName.getParent() );
|
type = CPPVisitor.createType( (IASTDeclarator) typedefName.getParent() );
|
||||||
if( type instanceof ITypedef ){
|
// if( type instanceof ITypedef ){
|
||||||
try {
|
// try {
|
||||||
type = ((ITypedef)type).getType();
|
// type = ((ITypedef)type).getType();
|
||||||
} catch ( DOMException e ) {
|
// } catch ( DOMException e ) {
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue