1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

update to previous fix for 90498.

This commit is contained in:
Andrew Niefer 2005-04-06 18:39:09 +00:00
parent 73ca558363
commit 7a42a70017
2 changed files with 19 additions and 4 deletions

View file

@ -3278,7 +3278,7 @@ public class AST2CPPTests extends AST2BaseTest {
assertEquals( expression.getSimpleType(), ICPPASTSimpleTypeConstructorExpression.t_int );
}
public void testBug90498() throws Exception {
public void testBug90498_1() throws Exception {
IASTTranslationUnit tu = parse( "typedef INT ( FOO ) (INT);", ParserLanguage.CPP ); //$NON-NLS-1$
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
@ -3292,5 +3292,21 @@ public class AST2CPPTests extends AST2BaseTest {
IASTDeclarator nested = dtor.getNestedDeclarator();
assertEquals( nested.getName().toString(), "FOO" ); //$NON-NLS-1$
}
public void testBug90498_2() throws Exception {
IASTTranslationUnit tu = parse( "int (* foo) (int) (0);", ParserLanguage.CPP ); //$NON-NLS-1$
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTDeclSpecifier declSpec = decl.getDeclSpecifier();
assertTrue( declSpec instanceof IASTSimpleDeclSpecifier );
IASTDeclarator dtor = decl.getDeclarators()[0];
assertTrue( dtor instanceof IASTFunctionDeclarator );
assertNotNull( dtor.getNestedDeclarator() );
IASTDeclarator nested = dtor.getNestedDeclarator();
assertEquals( nested.getName().toString(), "foo" ); //$NON-NLS-1$
assertNotNull( dtor.getInitializer() );
}
}

View file

@ -3521,10 +3521,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
throw eof;
}
} else if (LT(1) == IToken.tLPAREN) {
if( d instanceof IASTFunctionDeclarator ){
if( d instanceof IASTFunctionDeclarator && d.getNestedDeclarator() == null ){
//constructor initializer doesn't make sense for a function declarator,
//C++98:8.5-11 A parenthesized initializer can be a list of expressions
//only when the entity has a class type
//we must have an object to initialize, a function doesn't work.
return null;
}
// initializer in constructor