From a5843c1e7e5e51f9bc0f81444171cbe88abe9ff4 Mon Sep 17 00:00:00 2001 From: John Camelon Date: Thu, 19 May 2005 18:47:41 +0000 Subject: [PATCH] Fixed Bug 90641 [Parser] function decl vs ctor initializer ambiguity Fixed Bug 81806 [Parser2] [Ambiguity] Constructor Initializer is mistaken as function prototype Fixed Bug 94779 [Ambiguity] declarator with initializer parsed as function declarator --- .../tests/ast2/AST2CPPSpecFailingTest.java | 21 -- .../parser/tests/ast2/AST2CPPSpecTest.java | 20 +- .../core/parser/tests/ast2/AST2CPPTests.java | 15 +- .../tests/ast2/CompleteParser2Tests.java | 30 +-- .../parser/AbstractGNUSourceCodeParser.java | 32 ++- .../core/dom/parser/c/CASTAmbiguity.java | 39 +--- .../core/dom/parser/c/GNUCSourceParser.java | 8 - .../core/dom/parser/cpp/CPPASTAmbiguity.java | 40 +--- .../dom/parser/cpp/CPPASTCatchHandler.java | 7 + .../cpp/CPPASTCompositeTypeSpecifier.java | 18 +- .../cpp/CPPASTDeclarationStatement.java | 13 +- .../CPPASTExplicitTemplateInstantiation.java | 13 +- .../dom/parser/cpp/CPPASTForStatement.java | 7 + .../dom/parser/cpp/CPPASTIfStatement.java | 6 + .../cpp/CPPASTLinkageSpecification.java | 17 +- .../parser/cpp/CPPASTNamespaceDefinition.java | 17 +- .../parser/cpp/CPPASTTemplateDeclaration.java | 13 +- .../cpp/CPPASTTemplateSpecialization.java | 13 +- .../dom/parser/cpp/CPPASTTranslationUnit.java | 16 +- .../dom/parser/cpp/CPPASTWhileStatement.java | 6 + .../dom/parser/cpp/GNUCPPSourceParser.java | 201 +++++++++++++----- 21 files changed, 375 insertions(+), 177 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecFailingTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecFailingTest.java index 077e7f1eb25..a45fff06e6f 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecFailingTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecFailingTest.java @@ -224,27 +224,6 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest { } } - /** - [--Start Example(CPP 8.5-2): - int f(int); - int a = 2; - int b = f(a); - int c(b); - --End Example] - */ - public void test8_5s2() { // TODO raised bug 90641 - StringBuffer buffer = new StringBuffer(); - buffer.append("int f(int);\n"); //$NON-NLS-1$ - buffer.append("int a = 2;\n"); //$NON-NLS-1$ - buffer.append("int b = f(a);\n"); //$NON-NLS-1$ - buffer.append("int c(b);\n"); //$NON-NLS-1$ - try { - parse(buffer.toString(), ParserLanguage.CPP, true, 0); - assertTrue(false); - } catch (Exception e) { - } - } - /** [--Start Example(CPP 8.5.2-1): char msg[] = "Syntax error on line %s\n"; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java index bc8374a6583..3c937c4eb2f 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java @@ -12511,5 +12511,23 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { buffer.append("int ef(D&);\n"); //$NON-NLS-1$ buffer.append("int ff(X&);\n"); //$NON-NLS-1$ parse(buffer.toString(), ParserLanguage.CPP, true, 0); - } + } + + /** + [--Start Example(CPP 8.5-2): + int f(int); + int a = 2; + int b = f(a); + int c(b); + --End Example] + * @throws ParserException + */ + public void test8_5s2() throws ParserException { // 90641 + StringBuffer buffer = new StringBuffer(); + buffer.append("int f(int);\n"); //$NON-NLS-1$ + buffer.append("int a = 2;\n"); //$NON-NLS-1$ + buffer.append("int b = f(a);\n"); //$NON-NLS-1$ + buffer.append("int c(b);\n"); //$NON-NLS-1$ + parse(buffer.toString(), ParserLanguage.CPP, true, 0); + } } 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 125578c2f44..bf5c65422fb 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 @@ -3340,10 +3340,10 @@ public class AST2CPPTests extends AST2BaseTest { public void testBug90498_1() throws Exception { IASTTranslationUnit tu = parse( - "typedef INT ( FOO ) (INT);", ParserLanguage.CPP); //$NON-NLS-1$ + "typedef int INT;\ntypedef INT ( FOO ) (INT);", ParserLanguage.CPP); //$NON-NLS-1$ IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu - .getDeclarations()[0]; + .getDeclarations()[1]; IASTDeclSpecifier declSpec = decl.getDeclSpecifier(); assertTrue(declSpec instanceof ICPPASTNamedTypeSpecifier); assertEquals(((ICPPASTNamedTypeSpecifier) declSpec).getName() @@ -4344,4 +4344,15 @@ public class AST2CPPTests extends AST2BaseTest { assertSame( str, col.getName(7).resolveBinding() ); assertSame( str, col.getName(9).resolveBinding() ); } + + public void testBug94779() throws Exception { + StringBuffer buffer = new StringBuffer(); + buffer.append( "void f( int t ){\n" ); + buffer.append( "int s ( t );\n" ); + buffer.append( "}\n" ); + IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP ); + IASTDeclarationStatement ds = (IASTDeclarationStatement) ((IASTCompoundStatement)((IASTFunctionDefinition)tu.getDeclarations()[0]).getBody()).getStatements()[0]; + IASTDeclarator d = ((IASTSimpleDeclaration)ds.getDeclaration()).getDeclarators()[0]; + assertTrue( d.getName().resolveBinding() instanceof IVariable ); + } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java index 291e14fc27f..6dc26ac684b 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java @@ -19,7 +19,9 @@ import junit.framework.TestCase; import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement; +import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; +import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; import org.eclipse.cdt.core.dom.ast.IASTIdExpression; import org.eclipse.cdt.core.dom.ast.IASTIfStatement; @@ -832,21 +834,21 @@ public class CompleteParser2Tests extends TestCase { public void testBug41520() throws Exception { - /*IASTTranslationUnit tu =*/ parse( "const int x = 666; const int y( x );"); //$NON-NLS-1$ + IASTTranslationUnit tu = parse( "const int x = 666; const int y( x );"); //$NON-NLS-1$ -// IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[1]; -// IASTDeclarator dtor = decl.getDeclarators()[0]; -// assertFalse( dtor instanceof IASTFunctionDeclarator ); -// assertNotNull( dtor.getInitializer() ); -// -// CPPNameCollector col = new CPPNameCollector(); -// tu.accept( col ); -// -// assertEquals( col.size(), 3 ); -// IVariable x = (IVariable) col.getName(0).resolveBinding(); -// IVariable y = (IVariable) col.getName(1).resolveBinding(); -// assertNotNull(y); -// assertInstances( col, x, 2 ); + IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[1]; + IASTDeclarator dtor = decl.getDeclarators()[0]; + assertFalse( dtor instanceof IASTFunctionDeclarator ); + assertNotNull( dtor.getInitializer() ); + + CPPNameCollector col = new CPPNameCollector(); + tu.accept( col ); + + assertEquals( col.size(), 3 ); + IVariable x = (IVariable) col.getName(0).resolveBinding(); + IVariable y = (IVariable) col.getName(1).resolveBinding(); + assertNotNull(y); + assertInstances( col, x, 2 ); } public void testNewXReferences() throws Exception diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java index bdd18f77271..19847fb3245 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java @@ -398,7 +398,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { throw backtrack; } - protected IToken simpleDeclarationMark; private static final IASTNode[] EMPTY_NODE_ARRAY = new IASTNode[0]; @@ -494,11 +493,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { errorHandling(); } - /** - */ - protected void throwAwayMarksForInitializerClause() { - simpleDeclarationMark = null; - } /** * @return TODO @@ -1590,6 +1584,32 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { return expressionStatement; } + if (ds.getDeclaration() instanceof IASTAmbiguousDeclaration ) + { + IASTAmbiguousDeclaration amb = (IASTAmbiguousDeclaration) ds.getDeclaration(); + IASTDeclaration [] ambDs = amb.getDeclarations(); + int ambCount = 0; + for( int i = 0; i < ambDs.length; ++i ) + { + if (ambDs[i] instanceof IASTSimpleDeclaration + && ((IASTSimpleDeclaration) ambDs[i]) + .getDeclSpecifier() instanceof IASTSimpleDeclSpecifier + && ((IASTSimpleDeclSpecifier) ((IASTSimpleDeclaration) ambDs[i]).getDeclSpecifier()).getType() == IASTSimpleDeclSpecifier.t_unspecified) { + ++ambCount; + } + } + if ( ambCount == ambDs.length ) + { + backup(mark); + while (true) { + if (consume() == lastTokenOfExpression) + break; + } + + return expressionStatement; + } + } + if (ds.getDeclaration() instanceof IASTSimpleDeclaration && ((IASTSimpleDeclaration) ds.getDeclaration()) .getDeclSpecifier() instanceof IASTNamedTypeSpecifier) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguity.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguity.java index 679c299ebeb..d5f937aa082 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguity.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguity.java @@ -46,34 +46,6 @@ public abstract class CASTAmbiguity extends CASTNode { } - /** - * @param names - * @param j - * @throws DOMException - */ - protected void clearCache(IASTName[] names, int j) { - IScope scope = CPPVisitor.getContainingScope( names[j] ); - try { - scope.flushCache(); - } catch (DOMException e) { - } - } - - /** - * @param visitor - * @param nodes - * @param bestIndex - * @return - */ - protected boolean reduceAmbiguity(ASTVisitor visitor, IASTNode[] nodes, int bestIndex) { - IASTAmbiguityParent owner = (IASTAmbiguityParent) getParent(); - IASTNode s = nodes[bestIndex]; - owner.replace(this, nodes[bestIndex]); - if (!s.accept(visitor)) - return false; - return true; - } - protected abstract IASTNode [] getNodes(); public boolean accept(ASTVisitor visitor) { @@ -83,6 +55,7 @@ public abstract class CASTAmbiguity extends CASTNode { for( int i = 0; i < nodez.length; ++i ) { IASTNode s = nodez[i]; + s.accept(visitor); CASTNameCollector resolver = new CASTNameCollector(); s.accept( resolver ); IASTName [] names = resolver.getNames(); @@ -93,7 +66,11 @@ public abstract class CASTAmbiguity extends CASTNode { IBinding b = names[j].resolveBinding(); if( b == null || b instanceof IProblemBinding ) ++issues[i]; - clearCache(names, j); + IScope scope = CPPVisitor.getContainingScope( names[j] ); + try { + scope.flushCache(); + } catch (DOMException e) { + } } catch( Throwable t ) { @@ -112,7 +89,9 @@ public abstract class CASTAmbiguity extends CASTNode { } } - return reduceAmbiguity(visitor, nodez, bestIndex); + IASTAmbiguityParent owner = (IASTAmbiguityParent) getParent(); + owner.replace(this, nodez[bestIndex]); + return true; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java index 4c75e3cd0dd..d9a387655cc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java @@ -139,18 +139,10 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { supportGCCStyleDesignators = config.supportGCCStyleDesignators(); } - /** - * @param d - */ - protected void throwAwayMarksForInitializerClause() { - simpleDeclarationMark = null; - } - protected IASTInitializer optionalCInitializer() throws EndOfFileException, BacktrackException { if (LT(1) == IToken.tASSIGN) { consume(IToken.tASSIGN); - throwAwayMarksForInitializerClause(); return cInitializerClause(Collections.EMPTY_LIST); } return null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguity.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguity.java index d31465f7a10..9926acccfa4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguity.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguity.java @@ -42,33 +42,6 @@ public abstract class CPPASTAmbiguity extends CPPASTNode { } } - /** - * @param name - * @throws DOMException - */ - protected void clearCache(IASTName name) { - IScope scope = CPPVisitor.getContainingScope(name); - try { - scope.flushCache(); - } catch (DOMException de) {} - } - - /** - * @param visitor - * @param nodes - * @param bestIndex - * @return - */ - protected boolean reduceAmbiguity(ASTVisitor visitor, IASTNode[] nodes, - int bestIndex) { - IASTAmbiguityParent owner = (IASTAmbiguityParent) getParent(); - IASTNode s = nodes[bestIndex]; - owner.replace(this, nodes[bestIndex]); - if (!s.accept(visitor)) - return false; - return true; - } - protected abstract IASTNode[] getNodes(); public boolean accept(ASTVisitor visitor) { @@ -77,6 +50,7 @@ public abstract class CPPASTAmbiguity extends CPPASTNode { Arrays.fill(issues, 0); for (int i = 0; i < nodez.length; ++i) { IASTNode s = nodez[i]; + s.accept( visitor ); CPPASTNameCollector resolver = new CPPASTNameCollector(); s.accept(resolver); IASTName[] names = resolver.getNames(); @@ -89,8 +63,12 @@ public abstract class CPPASTAmbiguity extends CPPASTNode { ++issues[i]; } } - if (names.length > 0) - clearCache(names[0]); + if (names.length > 0) { + IScope scope = CPPVisitor.getContainingScope(names[0]); + try { + scope.flushCache(); + } catch (DOMException de) {} + } } int bestIndex = 0; int bestValue = issues[0]; @@ -101,7 +79,9 @@ public abstract class CPPASTAmbiguity extends CPPASTNode { } } - return reduceAmbiguity(visitor, nodez, bestIndex); + IASTAmbiguityParent owner = (IASTAmbiguityParent) getParent(); + owner.replace(this, nodez[bestIndex]); + return true; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCatchHandler.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCatchHandler.java index 85885a14ae7..1db523fa515 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCatchHandler.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCatchHandler.java @@ -89,5 +89,12 @@ public class CPPASTCatchHandler extends CPPASTNode implements other.setParent( child.getParent() ); body = (IASTStatement) other; } + if( declaration == child ) + { + other.setParent( child.getParent() ); + other.setPropertyInParent( child.getPropertyInParent() ); + declaration = (IASTDeclaration) other; + } + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompositeTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompositeTypeSpecifier.java index 85ba6365f69..f7cd2d43860 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompositeTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompositeTypeSpecifier.java @@ -13,15 +13,17 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; import org.eclipse.cdt.core.parser.util.ArrayUtil; +import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; /** * @author jcamelon */ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier - implements ICPPASTCompositeTypeSpecifier { + implements ICPPASTCompositeTypeSpecifier, IASTAmbiguityParent { private int k; private IASTName n; @@ -139,4 +141,18 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier return r_definition; return r_unclear; } + + public void replace(IASTNode child, IASTNode other) { + if( declarations == null ) return; + for( int i = 0; i < declarations.length; ++i ) + { + if( declarations[i] == null ) continue; + if( declarations[i] == child ) + { + other.setParent( child.getParent() ); + other.setPropertyInParent( child.getPropertyInParent() ); + declarations[i] = (IASTDeclaration) other; + } + } + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarationStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarationStatement.java index d7f9c2ba7ee..e642d18fe8d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarationStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarationStatement.java @@ -13,12 +13,14 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement; +import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; /** * @author jcamelon */ public class CPPASTDeclarationStatement extends CPPASTNode implements - IASTDeclarationStatement { + IASTDeclarationStatement, IASTAmbiguityParent { private IASTDeclaration declaration; @@ -47,4 +49,13 @@ public class CPPASTDeclarationStatement extends CPPASTNode implements if( declaration != null ) if( !declaration.accept( action ) ) return false; return true; } + + public void replace(IASTNode child, IASTNode other) { + if( declaration == child ) + { + other.setParent( child.getParent() ); + other.setPropertyInParent( child.getPropertyInParent() ); + declaration = (IASTDeclaration) other; + } + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTExplicitTemplateInstantiation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTExplicitTemplateInstantiation.java index df13ab2917b..a39d009cc13 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTExplicitTemplateInstantiation.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTExplicitTemplateInstantiation.java @@ -12,13 +12,15 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; +import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation; +import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; /** * @author jcamelon */ public class CPPASTExplicitTemplateInstantiation extends CPPASTNode implements - ICPPASTExplicitTemplateInstantiation { + ICPPASTExplicitTemplateInstantiation, IASTAmbiguityParent { private IASTDeclaration declaration; @@ -49,4 +51,13 @@ public class CPPASTExplicitTemplateInstantiation extends CPPASTNode implements return true; } + + public void replace(IASTNode child, IASTNode other) { + if( declaration == child ) + { + other.setParent( child.getParent() ); + other.setPropertyInParent( child.getPropertyInParent() ); + declaration = (IASTDeclaration) other; + } + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTForStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTForStatement.java index 7f0122986eb..11e40658e84 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTForStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTForStatement.java @@ -152,5 +152,12 @@ public class CPPASTForStatement extends CPPASTNode implements IASTForStatement, other.setParent( child.getParent() ); initialExpression = (IASTExpression) other; } + if( initDeclaration == child ) + { + other.setParent( child.getParent() ); + other.setPropertyInParent( child.getPropertyInParent() ); + initDeclaration = (IASTDeclaration) other; + } + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTIfStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTIfStatement.java index ef5dca28e35..684b8fe001e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTIfStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTIfStatement.java @@ -98,6 +98,12 @@ public class CPPASTIfStatement extends CPPASTNode implements ICPPASTIfStatement, other.setPropertyInParent( child.getPropertyInParent() ); elseClause = (IASTStatement) other; } + if( condDecl == child ) + { + other.setParent( child.getParent() ); + other.setPropertyInParent( child.getPropertyInParent() ); + condDecl = (IASTDeclaration) other; + } } public IASTDeclaration getConditionDeclaration() { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLinkageSpecification.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLinkageSpecification.java index 1a7edc725cb..a4caa53545c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLinkageSpecification.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLinkageSpecification.java @@ -12,14 +12,16 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; +import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification; import org.eclipse.cdt.core.parser.util.ArrayUtil; +import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; /** * @author jcamelon */ public class CPPASTLinkageSpecification extends CPPASTNode implements - ICPPASTLinkageSpecification { + ICPPASTLinkageSpecification, IASTAmbiguityParent { private String literal; /* (non-Javadoc) @@ -68,4 +70,17 @@ public class CPPASTLinkageSpecification extends CPPASTNode implements return true; } + public void replace(IASTNode child, IASTNode other) { + if( declarations == null ) return; + for( int i = 0; i < declarations.length; ++i ) + { + if( declarations[i] == null ) continue; + if( declarations[i] == child ) + { + other.setParent( child.getParent() ); + other.setPropertyInParent( child.getPropertyInParent() ); + declarations[i] = (IASTDeclaration) other; + } + } + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamespaceDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamespaceDefinition.java index 3fd07f11f86..31861b9af77 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamespaceDefinition.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamespaceDefinition.java @@ -14,17 +14,19 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace; import org.eclipse.cdt.core.parser.util.ArrayUtil; +import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; /** * @author jcamelon */ public class CPPASTNamespaceDefinition extends CPPASTNode implements - ICPPASTNamespaceDefinition { + ICPPASTNamespaceDefinition, IASTAmbiguityParent { private IASTName name; @@ -95,4 +97,17 @@ public class CPPASTNamespaceDefinition extends CPPASTNode implements return r_unclear; } + public void replace(IASTNode child, IASTNode other) { + if( declarations == null ) return; + for( int i = 0; i < declarations.length; ++i ) + { + if( declarations[i] == null ) continue; + if( declarations[i] == child ) + { + other.setParent( child.getParent() ); + other.setPropertyInParent( child.getPropertyInParent() ); + declarations[i] = (IASTDeclaration) other; + } + } + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateDeclaration.java index a01e6d76bd6..6ef94586f2e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateDeclaration.java @@ -12,16 +12,18 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; +import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope; import org.eclipse.cdt.core.parser.util.ArrayUtil; +import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; /** * @author jcamelon */ public class CPPASTTemplateDeclaration extends CPPASTNode implements - ICPPASTTemplateDeclaration { + ICPPASTTemplateDeclaration, IASTAmbiguityParent { private boolean exported; private IASTDeclaration declaration; @@ -97,4 +99,13 @@ public class CPPASTTemplateDeclaration extends CPPASTNode implements templateScope = new CPPTemplateScope( this ); return templateScope; } + + public void replace(IASTNode child, IASTNode other) { + if( declaration == child ) + { + other.setParent( child.getParent() ); + other.setPropertyInParent( child.getPropertyInParent() ); + declaration = (IASTDeclaration) other; + } + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateSpecialization.java index 580e9cc0e42..6a81d2ecbea 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateSpecialization.java @@ -12,16 +12,18 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; +import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope; +import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; /** * @author jcamelon */ public class CPPASTTemplateSpecialization extends CPPASTNode implements - ICPPASTTemplateSpecialization, ICPPASTTemplateDeclaration { + ICPPASTTemplateSpecialization, ICPPASTTemplateDeclaration, IASTAmbiguityParent { private IASTDeclaration declaration; private ICPPTemplateScope templateScope; @@ -87,4 +89,13 @@ public class CPPASTTemplateSpecialization extends CPPASTNode implements templateScope = new CPPTemplateScope( this ); return templateScope; } + + public void replace(IASTNode child, IASTNode other) { + if( declaration == child ) + { + other.setParent( child.getParent() ); + other.setPropertyInParent( child.getPropertyInParent() ); + declaration = (IASTDeclaration) other; + } + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java index da715958056..49bf1311fe7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java @@ -48,6 +48,7 @@ import org.eclipse.cdt.core.parser.ast.IASTEnumerator; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTPreprocessorSelectionResult; +import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; import org.eclipse.cdt.internal.core.dom.parser.IRequiresLocationInformation; import org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver; import org.eclipse.cdt.internal.core.parser.scanner2.InvalidPreprocessorNodeException; @@ -56,7 +57,7 @@ import org.eclipse.cdt.internal.core.parser.scanner2.InvalidPreprocessorNodeExce * @author jcamelon */ public class CPPASTTranslationUnit extends CPPASTNode implements - ICPPASTTranslationUnit, IRequiresLocationInformation { + ICPPASTTranslationUnit, IRequiresLocationInformation, IASTAmbiguityParent { private IASTDeclaration[] decls = new IASTDeclaration[32]; private ICPPNamespace binding = null; @@ -487,4 +488,17 @@ public class CPPASTTranslationUnit extends CPPASTNode implements return resolver.getContainingFilename( offset ); } + public void replace(IASTNode child, IASTNode other) { + if( decls == null ) return; + for( int i = 0; i < decls.length; ++i ) + { + if( decls[i] == null ) continue; + if( decls[i] == child ) + { + other.setParent( child.getParent() ); + other.setPropertyInParent( child.getPropertyInParent() ); + decls[i] = (IASTDeclaration) other; + } + } + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTWhileStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTWhileStatement.java index 96068c86e5b..a829c53444c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTWhileStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTWhileStatement.java @@ -96,6 +96,12 @@ public class CPPASTWhileStatement extends CPPASTNode implements other.setParent( child.getParent() ); condition = (IASTExpression) other; } + if( condition2 == child ) + { + other.setParent( child.getParent() ); + other.setPropertyInParent( child.getPropertyInParent() ); + condition2 = (IASTDeclaration) other; + } } } 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 8eff6cc302c..aab4309f4f2 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 @@ -143,6 +143,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser; import org.eclipse.cdt.internal.core.dom.parser.BacktrackException; import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider; +import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousDeclaration; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousExpression; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousStatement; import org.eclipse.cdt.internal.core.parser.SimpleDeclarationStrategy; @@ -171,6 +172,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { private ScopeStack templateIdScopes = new ScopeStack(); + private int templateCount = 0; + protected CPPASTTranslationUnit translationUnit; private static class ScopeStack { @@ -943,8 +946,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { try { declSpecifier = declSpecifierSeq(true, true); if (LT(1) != IToken.tEOC) - declarator = declarator( - SimpleDeclarationStrategy.TRY_FUNCTION, + declarator = declarator(SimpleDeclarationStrategy.TRY_FUNCTION, forNewExpression); } catch (BacktrackException bt) { backup(mark); @@ -2123,6 +2125,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { IToken firstToken = null; boolean exported = false; boolean encounteredExtraMod = false; + ++templateCount; if (LT(1) == IToken.t_export) { exported = true; firstToken = consume(IToken.t_export); @@ -2166,14 +2169,18 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { templateInstantiation = temp; } else templateInstantiation = createTemplateInstantiation(); - IASTDeclaration d = declaration(); - ((ASTNode) templateInstantiation).setOffsetAndLength(firstToken - .getOffset(), calculateEndOffset(d) - - firstToken.getOffset()); - templateInstantiation.setDeclaration(d); - d.setParent(templateInstantiation); - d - .setPropertyInParent(ICPPASTExplicitTemplateInstantiation.OWNED_DECLARATION); + try { + IASTDeclaration d = declaration(); + ((ASTNode) templateInstantiation).setOffsetAndLength(firstToken + .getOffset(), calculateEndOffset(d) + - firstToken.getOffset()); + templateInstantiation.setDeclaration(d); + d.setParent(templateInstantiation); + d + .setPropertyInParent(ICPPASTExplicitTemplateInstantiation.OWNED_DECLARATION); + } finally { + --templateCount; + } return templateInstantiation; } consume(IToken.tLT); @@ -2182,34 +2189,46 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { consume(IToken.tGT); ICPPASTTemplateSpecialization templateSpecialization = createTemplateSpecialization(); - IASTDeclaration d = declaration(); - ((ASTNode) templateSpecialization).setOffsetAndLength(firstToken - .getOffset(), calculateEndOffset(d) - - firstToken.getOffset()); - templateSpecialization.setDeclaration(d); - d.setParent(templateSpecialization); - d - .setPropertyInParent(ICPPASTTemplateSpecialization.OWNED_DECLARATION); + try { + IASTDeclaration d = declaration(); + ((ASTNode) templateSpecialization).setOffsetAndLength( + firstToken.getOffset(), calculateEndOffset(d) + - firstToken.getOffset()); + templateSpecialization.setDeclaration(d); + d.setParent(templateSpecialization); + d + .setPropertyInParent(ICPPASTTemplateSpecialization.OWNED_DECLARATION); + } finally { + --templateCount; + } + return templateSpecialization; } try { List parms = templateParameterList(); consume(IToken.tGT); - IASTDeclaration d = declaration(); ICPPASTTemplateDeclaration templateDecl = createTemplateDeclaration(); - ((ASTNode) templateDecl).setOffsetAndLength(firstToken.getOffset(), - calculateEndOffset(d) - firstToken.getOffset()); - templateDecl.setExported(exported); - templateDecl.setDeclaration(d); - d.setParent(templateDecl); - d.setPropertyInParent(ICPPASTTemplateDeclaration.OWNED_DECLARATION); - for (int i = 0; i < parms.size(); ++i) { - ICPPASTTemplateParameter parm = (ICPPASTTemplateParameter) parms - .get(i); - templateDecl.addTemplateParamter(parm); - parm.setParent(templateDecl); - parm.setPropertyInParent(ICPPASTTemplateDeclaration.PARAMETER); + try + { + IASTDeclaration d = declaration(); + ((ASTNode) templateDecl).setOffsetAndLength(firstToken.getOffset(), + calculateEndOffset(d) - firstToken.getOffset()); + templateDecl.setExported(exported); + templateDecl.setDeclaration(d); + d.setParent(templateDecl); + d.setPropertyInParent(ICPPASTTemplateDeclaration.OWNED_DECLARATION); + for (int i = 0; i < parms.size(); ++i) { + ICPPASTTemplateParameter parm = (ICPPASTTemplateParameter) parms + .get(i); + templateDecl.addTemplateParamter(parm); + parm.setParent(templateDecl); + parm.setPropertyInParent(ICPPASTTemplateDeclaration.PARAMETER); + } + } + finally + { + --templateCount; } return templateDecl; @@ -2426,24 +2445,93 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { protected IASTDeclaration simpleDeclarationStrategyUnion() throws EndOfFileException, BacktrackException { - simpleDeclarationMark = mark(); + IToken simpleDeclarationMark = mark(); + IASTDeclaration d1 = null, d2 = null; + IToken after = null; try { - IASTDeclaration d = simpleDeclaration( - SimpleDeclarationStrategy.TRY_FUNCTION, false); - throwAwayMarksForInitializerClause(); - return d; + d1 = simpleDeclaration(SimpleDeclarationStrategy.TRY_FUNCTION, + false); + try { + after = LA(1); + } catch (EndOfFileException eof) { + after = null; + } } catch (BacktrackException bt) { - if (simpleDeclarationMark == null) - throwBacktrack(bt); - // did not work - backup(simpleDeclarationMark); - - IASTDeclaration d = simpleDeclaration( - SimpleDeclarationStrategy.TRY_VARIABLE, false); - throwAwayMarksForInitializerClause(); - return d; - + d1 = null; } + if (d1 != null) { + if( templateCount != 0 ) + return d1; + if (d1 instanceof IASTFunctionDefinition) + return d1; + if (d1 instanceof IASTSimpleDeclaration) { + IASTSimpleDeclaration sd = (IASTSimpleDeclaration) d1; + if( sd.getDeclSpecifier() instanceof ICPPASTDeclSpecifier && + ((ICPPASTDeclSpecifier)sd.getDeclSpecifier()).isFriend() ) + return d1; + if (sd.getDeclarators().length != 1) + return d1; + if (sd.getDeclarators()[0] instanceof IASTStandardFunctionDeclarator) { + IASTStandardFunctionDeclarator fd = (IASTStandardFunctionDeclarator) sd + .getDeclarators()[0]; + if (sd.getDeclSpecifier().getStorageClass() == IASTDeclSpecifier.sc_typedef) + return d1; + IASTParameterDeclaration[] parms = fd.getParameters(); + for (int i = 0; i < parms.length; ++i) { + if (!(parms[i].getDeclSpecifier() instanceof IASTNamedTypeSpecifier)) + return d1; + if (((ASTNode) parms[i].getDeclarator().getName()) + .getLength() > 0) + return d1; + IASTDeclarator d = parms[i].getDeclarator(); + while (d.getNestedDeclarator() != null) + d = d.getNestedDeclarator(); + if (((ASTNode) d.getName()).getLength() > 0) + return d1; + } + } else + return d1; + } + } + + // did not work + backup(simpleDeclarationMark); + + try { + d2 = simpleDeclaration(SimpleDeclarationStrategy.TRY_VARIABLE, + false); + if (after != null && after != LA(1)) { + backup(after); + return d1; + } + } catch (BacktrackException be) { + d2 = null; + if (d1 == null) + throwBacktrack(be); + } + + if (d2 == null && d1 != null) { + backup(after); + return d1; + } + + if (d1 == null && d2 != null) + return d2; + + IASTAmbiguousDeclaration result = createAmbiguousDeclaration(); + ((CPPASTNode) result).setOffsetAndLength((ASTNode) d1); + result.addDeclaration(d1); + d1.setParent(result); + d1.setPropertyInParent(IASTAmbiguousDeclaration.SUBDECLARATION); + result.addDeclaration(d2); + d2.setParent(result); + d2.setPropertyInParent(IASTAmbiguousDeclaration.SUBDECLARATION); + return result; + + } + + protected IASTAmbiguousDeclaration createAmbiguousDeclaration() { + return new CPPASTAmbiguousDeclaration(); } /** @@ -3475,7 +3563,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { if (LT(1) == IToken.tASSIGN) { consume(IToken.tASSIGN); - throwAwayMarksForInitializerClause(); try { return initializerClause(); } catch (EndOfFileException eof) { @@ -4996,7 +5083,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { IASTNode condition = null; try { condition = cppStyleCondition(); // TODO should be while - // condition + // condition if (LT(1) == IToken.tEOC) { // Completing in the condition ICPPASTIfStatement new_if = createIfStatement(); @@ -5040,15 +5127,15 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { ICPPASTIfStatement new_if_statement = createIfStatement(); ((ASTNode) new_if_statement).setOffset(so); if (condition != null && condition instanceof IASTExpression) // shouldn't - // be - // possible - // but - // failure - // in - // condition() - // makes - // it - // so + // be + // possible + // but + // failure + // in + // condition() + // makes + // it + // so { new_if_statement .setConditionExpression((IASTExpression) condition);