From a6efadb09acaf1d383e0955c660420479a5982cc Mon Sep 17 00:00:00 2001 From: John Camelon Date: Thu, 25 Sep 2003 13:33:33 +0000 Subject: [PATCH] CORE Partial fix for Bug 43221 : POSTFIX_TYPENAME_IDENTIFIER not implemented TEST Updated CompleteParseASTExpressionTest::testPostfixTypenameIdentifier() for Hoda. --- .../tests/CompleteParseASTExpressionTest.java | 16 ++----- core/org.eclipse.cdt.core/parser/ChangeLog | 3 ++ .../cdt/internal/core/parser/Parser.java | 43 +++++++++++++++++-- 3 files changed, 46 insertions(+), 16 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTExpressionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTExpressionTest.java index fdd7e23c44b..b7cfd308de0 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTExpressionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTExpressionTest.java @@ -199,24 +199,14 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{ assertAllReferences( 1, createTaskList( new Task( foo ))); } - // Kind POSTFIX_TYPENAME_IDENTIFIER +// // Kind POSTFIX_TYPENAME_IDENTIFIER // public void testPostfixTypenameIdentifier() throws Exception{ -// Iterator i = parse( "class A {}; \n int foo(); int foo( A a ); \n int x = foo( typename A(); );").getDeclarations(); +// Iterator i = parse( "class A {}; \n int foo(); int foo( A a ); \n int x = foo( typename A() );").getDeclarations(); // IASTClassSpecifier cl = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); // IASTFunction f1 = (IASTFunction) i.next(); // IASTFunction f2 = (IASTFunction) i.next(); // IASTVariable x = (IASTVariable) i.next(); -// Iterator members = getDeclarations(cl); -// IASTField m = (IASTField)members.next(); -// Iterator references = callback.getReferences().iterator(); -// IASTClassReference clr= (IASTClassReference)references.next(); -// assertEquals(clr.getReferencedElement(), cl); -// IASTVariableReference ar = (IASTVariableReference)references.next(); -// assertEquals(ar.getReferencedElement(), a); -// IASTFieldReference mr = (IASTFieldReference) references.next(); -// assertEquals(mr.getReferencedElement(), m); -// IASTFunctionReference fr = (IASTFunctionReference) references.next(); -// assertEquals(fr.getReferencedElement(), f2); +// assertAllReferences( 3, createTaskList( new Task( cl, 2 ), new Task( f2) ) ); // } // Kind POSTFIX_TYPENAME_TEMPLATEID diff --git a/core/org.eclipse.cdt.core/parser/ChangeLog b/core/org.eclipse.cdt.core/parser/ChangeLog index 49c1137a335..c46e51cf79c 100644 --- a/core/org.eclipse.cdt.core/parser/ChangeLog +++ b/core/org.eclipse.cdt.core/parser/ChangeLog @@ -1,3 +1,6 @@ +2003-09-25 John Camelon + Partial fix for Bug 43221 : POSTFIX_TYPENAME_IDENTIFIER not implemented + 2003-09-24 John Camelon Fixed Bug 43106 : Symbol Table support needed to resolve types Fixed Bug 43375 : isExtern not returning true for extern declarations diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java index 8bf72628413..31945673e4a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java @@ -4082,8 +4082,45 @@ public class Parser implements IParser switch (LT(1)) { case IToken.t_typename : - consume(); //TODO: the rest of this - break; + consume(IToken.t_typename); + ITokenDuple nestedName = name(); + boolean templateTokenConsumed = false; + if( LT(1) == IToken.t_template ) + { + consume( IToken.t_template ); + templateTokenConsumed = true; + } + IToken current = mark(); + ITokenDuple templateId = null; + try + { + templateId = new TokenDuple( current, templateId() ); + } + catch( Backtrack bt ) + { + if( templateTokenConsumed ) + throw bt; + backup( current ); + } + consume( IToken.tLPAREN ); + IASTExpression expressionList = expression( scope ); + consume( IToken.tRPAREN ); + try { + firstExpression = + astFactory.createExpression( scope, + (( templateId != null )? IASTExpression.Kind.POSTFIX_TYPENAME_TEMPLATEID : IASTExpression.Kind.POSTFIX_TYPENAME_IDENTIFIER ), + expressionList, + null, + null, + null, + nestedName, + "", + null ); + } catch (ASTSemanticException ase ) { + failParse(); + throw backtrack; + } + break; // simple-type-specifier ( assignment-expression , .. ) case IToken.t_char : firstExpression = @@ -4224,7 +4261,7 @@ public class Parser implements IParser break; case IToken.tLPAREN : // function call - consume(); + consume(IToken.tLPAREN); secondExpression = expression(scope); consume(IToken.tRPAREN); try