diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index 4edb0ebbb99..c789d008939 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -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() ); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java index 19683408148..7a5c52d0e90 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java @@ -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