mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 12:03:16 +02:00
handle typedefs of functions
This commit is contained in:
parent
e465c18c34
commit
573d7a0dff
2 changed files with 14 additions and 2 deletions
|
@ -3308,5 +3308,15 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
|
|
||||||
assertNotNull( dtor.getInitializer() );
|
assertNotNull( dtor.getInitializer() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testTypedefFunction() throws Exception {
|
||||||
|
IASTTranslationUnit tu = parse( "typedef int foo (int);", ParserLanguage.CPP ); //$NON-NLS-1$
|
||||||
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
|
tu.accept( col );
|
||||||
|
|
||||||
|
IBinding binding = col.getName(0).resolveBinding();
|
||||||
|
assertTrue( binding instanceof ITypedef );
|
||||||
|
assertTrue( ((ITypedef)binding).getType() instanceof IFunctionType );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -465,8 +465,10 @@ public class CPPVisitor {
|
||||||
return function;
|
return function;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
IASTSimpleDeclaration simpleDecl = ( parent instanceof IASTSimpleDeclaration ) ? (IASTSimpleDeclaration)parent : null;
|
||||||
if( scope instanceof ICPPClassScope ){
|
if( simpleDecl != null && simpleDecl.getDeclSpecifier().getStorageClass() == IASTDeclSpecifier.sc_typedef ){
|
||||||
|
binding = new CPPTypedef( name );
|
||||||
|
} else if( scope instanceof ICPPClassScope ){
|
||||||
if( isConstructor( scope, declarator) )
|
if( isConstructor( scope, declarator) )
|
||||||
binding = template ? (ICPPConstructor) new CPPConstructorTemplate( name )
|
binding = template ? (ICPPConstructor) new CPPConstructorTemplate( name )
|
||||||
: new CPPConstructor( (ICPPASTFunctionDeclarator) declarator );
|
: new CPPConstructor( (ICPPASTFunctionDeclarator) declarator );
|
||||||
|
|
Loading…
Add table
Reference in a new issue