From 1fc47b91e1471210836462a9c55328fa494c00b1 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Wed, 17 Feb 2010 16:23:57 +0000 Subject: [PATCH] Bug 302412: Syntax for c++0x initializer lists --- .../cdt/core/parser/tests/ASTComparer.java | 26 +- .../core/parser/tests/ast2/AST2BaseTest.java | 8 +- .../core/parser/tests/ast2/AST2CPPTests.java | 48 +- .../tests/ast2/AST2SelectionParseTest.java | 16 +- .../cdt/core/parser/tests/ast2/AST2Tests.java | 60 +- .../parser/tests/ast2/AST2UtilOldTests.java | 138 ++-- .../core/parser/tests/ast2/AST2UtilTests.java | 32 +- .../tests/ast2/DOMLocationMacroTests.java | 78 +- .../parser/tests/ast2/DOMLocationTests.java | 20 +- .../ast2/DOMPreprocessorInformationTest.java | 9 +- .../ast2/GCCCompleteParseExtensionsTest.java | 9 +- .../append/CtorChainInitializerTest.java | 5 +- .../CtorChainInitializerTest.java | 5 +- .../remove/NewInitializerExpressionTest.java | 7 +- .../replace/CtorChainInitializerTest.java | 5 +- .../replace/InitializerTest.java | 6 +- .../replace/NewInitializerExpressionTest.java | 7 +- .../ASTWriterDeclaratorTestSource.awts | 7 +- .../.settings/.api_filters | 45 ++ .../internal/core/model/ASTStringUtil.java | 46 +- .../cdt/core/dom/ast/ASTSignatureUtil.java | 112 +-- .../dom/ast/IASTArraySubscriptExpression.java | 47 +- .../core/dom/ast/IASTBinaryExpression.java | 10 +- ...ession.java => IASTEqualsInitializer.java} | 25 +- .../cdt/core/dom/ast/IASTExpression.java | 4 +- .../dom/ast/IASTFunctionCallExpression.java | 68 +- .../cdt/core/dom/ast/IASTImplicitName.java | 4 +- .../core/dom/ast/IASTImplicitNameOwner.java | 4 +- ...alizer.java => IASTInitializerClause.java} | 16 +- .../dom/ast/IASTInitializerExpression.java | 9 +- .../cdt/core/dom/ast/IASTInitializerList.java | 38 +- .../cdt/core/dom/ast/IASTReturnStatement.java | 28 +- .../cdt/core/dom/ast/INodeFactory.java | 279 +++---- .../dom/ast/c/ICASTDesignatedInitializer.java | 60 +- .../cdt/core/dom/ast/c/ICNodeFactory.java | 46 +- .../cpp/ICPPASTArraySubscriptExpression.java | 5 +- .../ICPPASTConstructorChainInitializer.java | 77 +- .../cpp/ICPPASTConstructorInitializer.java | 54 +- .../dom/ast/cpp/ICPPASTExpressionList.java | 5 +- .../cpp/ICPPASTFunctionCallExpression.java | 5 +- .../dom/ast/cpp/ICPPASTInitializerList.java | 9 +- .../dom/ast/cpp/ICPPASTNewExpression.java | 149 ++-- ...CPPASTSimpleTypeConstructorExpression.java | 183 ++--- .../ast/cpp/ICPPASTTypenameExpression.java | 10 +- .../cdt/core/dom/ast/cpp/ICPPNodeFactory.java | 313 +++++--- .../dom/ast/gnu/IGNUASTUnaryExpression.java | 3 + .../cdt/core/parser/IInactiveCodeToken.java | 4 +- ...AmbiguousCastVsFunctionCallExpression.java | 14 +- .../core/dom/parser/ASTEqualsInitializer.java | 87 +++ .../parser/AbstractGNUSourceCodeParser.java | 107 +-- .../core/dom/parser/DeclarationOptions.java | 40 +- .../IASTAmbiguousSimpleDeclaration.java | 3 +- .../IASTInternalEnumerationSpecifier.java | 3 +- .../dom/parser/VariableReadWriteFlags.java | 6 +- .../c/CASTArraySubscriptExpression.java | 18 +- .../dom/parser/c/CASTBinaryExpression.java | 7 +- .../parser/c/CASTDesignatedInitializer.java | 70 +- .../dom/parser/c/CASTEqualsInitializer.java | 34 + .../parser/c/CASTFunctionCallExpression.java | 123 ++- .../parser/c/CASTInitializerExpression.java | 69 +- .../dom/parser/c/CASTInitializerList.java | 81 +- .../dom/parser/c/CASTReturnStatement.java | 26 +- .../core/dom/parser/c/CNodeFactory.java | 496 ++++++------ .../internal/core/dom/parser/c/CVariable.java | 14 +- .../core/dom/parser/c/GNUCSourceParser.java | 41 +- .../cpp/CPPASTArraySubscriptExpression.java | 35 +- .../parser/cpp/CPPASTBinaryExpression.java | 33 +- .../CPPASTConstructorChainInitializer.java | 91 ++- .../cpp/CPPASTConstructorInitializer.java | 121 ++- .../parser/cpp/CPPASTEqualsInitializer.java | 34 + .../cpp/CPPASTFunctionCallExpression.java | 151 ++-- .../cpp/CPPASTInitializerExpression.java | 81 +- .../dom/parser/cpp/CPPASTInitializerList.java | 121 ++- .../dom/parser/cpp/CPPASTNewExpression.java | 266 ++++--- .../dom/parser/cpp/CPPASTQualifiedName.java | 35 +- .../dom/parser/cpp/CPPASTReturnStatement.java | 44 +- ...CPPASTSimpleTypeConstructorExpression.java | 190 ++++- .../parser/cpp/CPPASTTypenameExpression.java | 127 +-- .../core/dom/parser/cpp/CPPNodeFactory.java | 713 +++++++++-------- .../cpp/CPPTemplateNonTypeParameter.java | 16 +- .../core/dom/parser/cpp/CPPUnknownScope.java | 6 +- .../core/dom/parser/cpp/CPPVariable.java | 34 +- .../dom/parser/cpp/GNUCPPSourceParser.java | 739 ++++++++++-------- .../parser/cpp/semantics/CPPSemantics.java | 110 ++- .../dom/parser/cpp/semantics/CPPVisitor.java | 93 +-- .../dom/parser/cpp/semantics/LookupData.java | 52 +- .../rewrite/astwriter/DeclaratorWriter.java | 9 +- .../rewrite/astwriter/InitializerWriter.java | 27 +- .../formatter/CodeFormatterVisitor.java | 55 +- .../cdt/utils/macho/parser/MachOParser64.java | 1 - .../ExtractConstantRefactoring.java | 16 +- .../ExtractFunctionRefactoring.java | 10 +- .../ExtractLocalVariableRefactoring.java | 10 +- 93 files changed, 3757 insertions(+), 2846 deletions(-) create mode 100644 core/org.eclipse.cdt.core/.settings/.api_filters rename core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/{cpp/ICPPASTInitializerExpression.java => IASTEqualsInitializer.java} (51%) rename core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/{cpp/ICPPASTInitializer.java => IASTInitializerClause.java} (70%) create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEqualsInitializer.java create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEqualsInitializer.java create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEqualsInitializer.java diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ASTComparer.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ASTComparer.java index 6c329290f07..fca045aba8a 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ASTComparer.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ASTComparer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 IBM Corporation and others. + * Copyright (c) 2009, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -27,17 +27,23 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; public class ASTComparer extends Assert { private static Set methodsToIgnore = new HashSet(Arrays.asList( - // prevent infinite recursion + // Prevent infinite recursion "getParent", "getTranslationUnit", "getLastName", - // original is usually frozen but copy must not be - "isFrozen", - // these methods are problematic + + // Exponential complexity + "getOperand2", // duplicates getInitOperand2() "getChildren", - "getProblem", + + // Can be different in copy + "isFrozen", "getContainingFilename", - // ignore preprocessor nodes + + // These methods are problematic + "getProblem", + + // Ignore preprocessor nodes "getMacroDefinitions", "getBuiltinMacroDefinitions", "getIncludeDirectives", @@ -45,7 +51,8 @@ public class ASTComparer extends Assert { "getMacroExpansions", "getPreprocessorProblems", "getComments", - // avoid name resolution + + // Avoid name resolution "isDeclaration", "isDefinition", "isReference", @@ -86,6 +93,9 @@ public class ASTComparer extends Assert { if(methodsToIgnore.contains(getter.getName())) continue; + if (getter.getAnnotation(Deprecated.class) != null) + continue; + try { Class returnType = getter.getReturnType(); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java index bc1f309d6c1..9166c6f7b1d 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -38,6 +38,7 @@ import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; import org.eclipse.cdt.core.dom.ast.IASTIdExpression; import org.eclipse.cdt.core.dom.ast.IASTImplicitName; import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner; +import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNodeSelector; @@ -356,6 +357,11 @@ public class AST2BaseTest extends BaseTestCase { assertEquals(num, count); } + protected void isExpressionStringEqual(IASTInitializerClause exp, String str) { + String expressionString = ASTSignatureUtil.getExpressionString((IASTExpression) exp); + assertEquals(str, expressionString); + } + protected void isExpressionStringEqual(IASTExpression exp, String str) { String expressionString = ASTSignatureUtil.getExpressionString(exp); assertEquals(str, expressionString); 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 04129664582..969649a3d68 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 @@ -35,6 +35,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; +import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpressionList; import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement; @@ -43,7 +44,6 @@ 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.IASTImplicitNameOwner; -import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression; import org.eclipse.cdt.core.dom.ast.IASTLabelStatement; import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression; import org.eclipse.cdt.core.dom.ast.IASTName; @@ -1623,9 +1623,8 @@ public class AST2CPPTests extends AST2BaseTest { String code = "int x = ::ABC::DEF::ghi;"; //$NON-NLS-1$ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP); IASTSimpleDeclaration x = (IASTSimpleDeclaration) tu.getDeclarations()[0]; - IASTInitializerExpression e = (IASTInitializerExpression) x - .getDeclarators()[0].getInitializer(); - IASTIdExpression id = (IASTIdExpression) e.getExpression(); + IASTEqualsInitializer e = (IASTEqualsInitializer) x.getDeclarators()[0].getInitializer(); + IASTIdExpression id = (IASTIdExpression) e.getInitializerClause(); ICPPASTQualifiedName name = (ICPPASTQualifiedName) id.getName(); assertTrue(name.isFullyQualified()); assertEquals(name.getNames().length, 3); @@ -4435,10 +4434,10 @@ public class AST2CPPTests extends AST2BaseTest { // } public void testBug84466() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); - ICPPASTCastExpression dynamic_cast = (ICPPASTCastExpression) ((IASTInitializerExpression) ((IASTSimpleDeclaration) ((IASTDeclarationStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu + ICPPASTCastExpression dynamic_cast = (ICPPASTCastExpression) ((IASTEqualsInitializer) ((IASTSimpleDeclaration) ((IASTDeclarationStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu .getDeclarations()[2]).getBody()).getStatements()[0]) .getDeclaration()).getDeclarators()[0].getInitializer()) - .getExpression(); + .getInitializerClause(); assertEquals(dynamic_cast.getOperator(), ICPPASTCastExpression.op_dynamic_cast); @@ -5580,8 +5579,8 @@ public class AST2CPPTests extends AST2BaseTest { public void testLongLiteral_225534() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); IASTDeclarator decltor= ((IASTSimpleDeclaration)tu.getDeclarations()[0]).getDeclarators()[0]; - IASTInitializerExpression init= (IASTInitializerExpression) decltor.getInitializer(); - ICPPASTLiteralExpression exp= (ICPPASTLiteralExpression) init.getExpression(); + IASTEqualsInitializer init= (IASTEqualsInitializer) decltor.getInitializer(); + ICPPASTLiteralExpression exp= (ICPPASTLiteralExpression) init.getInitializerClause(); ICPPBasicType type= (ICPPBasicType) exp.getExpressionType(); assertTrue(type.isLong()); } @@ -8045,5 +8044,38 @@ public class AST2CPPTests extends AST2BaseTest { f= bh.assertNonProblem("t8", 2); assertEquals("const double", ASTTypeUtil.getType(f.getType().getReturnType())); } + + // typedef int TInt; + // void test() { + // int a1= {}, a2{}; // Initializer for declarator + // int b1= {1}, b2{1}; + // + // TInt c[12]; + // c[{1,2}]; // Array subscript + // + // a1= int{}; // Functional casts + // a2= TInt{}; + // b1= int{1}; + // b2= TInt{}; + // + // new({1}) int {}; // New expression initializer + // new({1}) int {1}; + // + // a1= b1= {1}; // Assinment expression + // if (int a={2}) {} // Condition + // return {0,1,2}; // Return statement + // } + // + // struct S { + // int f; + // S(int); + // }; + // + // S::S(int a) : f{a} {} // Member initializer + + public void testInitSyntax_302412() throws Exception { + String code= getAboveComment(); + parseAndCheckBindings(code, ParserLanguage.CPP); + } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTest.java index 0c1dd6a8036..f71c1f37682 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,9 +15,9 @@ import java.io.Writer; import org.eclipse.cdt.core.dom.ast.IASTArrayModifier; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; +import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer; import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.core.dom.ast.IASTIdExpression; -import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTNode; @@ -186,17 +186,17 @@ public class AST2SelectionParseTest extends AST2SelectionParseBaseTest { int length = "argc".length(); //$NON-NLS-1$ IASTNode node = parse( code, ParserLanguage.C, offset1, length ).getParent().getParent(); assertNotNull(node); - assertTrue( node instanceof IASTInitializerExpression ); - assertEquals( ((IASTIdExpression)((IASTInitializerExpression)node).getExpression()).getName().toString(), "argc" ); //$NON-NLS-1$ - IASTName name = ((IASTIdExpression)((IASTInitializerExpression)node).getExpression()).getName(); + assertTrue( node instanceof IASTEqualsInitializer ); + assertEquals( ((IASTIdExpression)((IASTEqualsInitializer)node).getInitializerClause()).getName().toString(), "argc" ); //$NON-NLS-1$ + IASTName name = ((IASTIdExpression)((IASTEqualsInitializer)node).getInitializerClause()).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IParameter); assertEquals(((IParameter)name.resolveBinding()).getName(), "argc"); //$NON-NLS-1$ node = parse( code, ParserLanguage.CPP, offset1, length ).getParent().getParent(); assertNotNull(node); - assertTrue( node instanceof IASTInitializerExpression ); - assertEquals( ((IASTIdExpression)((IASTInitializerExpression)node).getExpression()).getName().toString(), "argc" ); //$NON-NLS-1$ - name = ((IASTIdExpression)((IASTInitializerExpression)node).getExpression()).getName(); + assertTrue( node instanceof IASTEqualsInitializer ); + assertEquals( ((IASTIdExpression)((IASTEqualsInitializer)node).getInitializerClause()).getName().toString(), "argc" ); //$NON-NLS-1$ + name = ((IASTIdExpression)((IASTEqualsInitializer)node).getInitializerClause()).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IParameter); assertEquals(((IParameter)name.resolveBinding()).getName(), "argc"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java index c135b4e3c91..87321b72d84 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java @@ -34,6 +34,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTDoStatement; import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier; +import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpressionList; import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement; @@ -47,7 +48,6 @@ import org.eclipse.cdt.core.dom.ast.IASTIdExpression; import org.eclipse.cdt.core.dom.ast.IASTIfStatement; import org.eclipse.cdt.core.dom.ast.IASTImageLocation; import org.eclipse.cdt.core.dom.ast.IASTInitializer; -import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression; import org.eclipse.cdt.core.dom.ast.IASTInitializerList; import org.eclipse.cdt.core.dom.ast.IASTLabelStatement; import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression; @@ -240,10 +240,9 @@ public class AST2Tests extends AST2BaseTest { assertEquals("z", name_z.toString()); //$NON-NLS-1$ // = x + y - IASTInitializerExpression initializer = (IASTInitializerExpression) declor_z + IASTEqualsInitializer initializer = (IASTEqualsInitializer) declor_z .getInitializer(); - IASTBinaryExpression init_z = (IASTBinaryExpression) initializer - .getExpression(); + IASTBinaryExpression init_z = (IASTBinaryExpression) initializer.getInitializerClause(); assertEquals(IASTBinaryExpression.op_plus, init_z.getOperator()); IASTIdExpression ref_x = (IASTIdExpression) init_z.getOperand1(); IASTName name_ref_x = ref_x.getName(); @@ -2038,8 +2037,8 @@ public class AST2Tests extends AST2BaseTest { .getName(); IASTName name_xy = xy.getDeclarators()[0].getName(); IASTDeclarator declarator_xy = xy.getDeclarators()[0]; - IASTInitializer[] initializers1 = ((IASTInitializerList) declarator_xy - .getInitializer()).getInitializers(); + IASTInitializer[] initializers1 = ((IASTInitializerList) ((IASTEqualsInitializer) declarator_xy.getInitializer()) + .getInitializerClause()).getInitializers(); IASTName name_y2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers1[0]) .getDesignators()[0]).getName(); @@ -2056,14 +2055,14 @@ public class AST2Tests extends AST2BaseTest { .getDeclSpecifier()).getName(); IASTName name_point = point.getDeclarators()[0].getName(); IASTDeclarator declarator_point = point.getDeclarators()[0]; - IASTInitializer[] initializers2 = ((IASTInitializerList) declarator_point - .getInitializer()).getInitializers(); + IASTInitializer[] initializers2 = ((IASTInitializerList) ((IASTEqualsInitializer) declarator_point + .getInitializer()).getInitializerClause()).getInitializers(); IASTName name_width2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers2[0]) .getDesignators()[0]).getName(); IASTName name_pos2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers2[1]) .getDesignators()[0]).getName(); - IASTName name_xy2 = ((IASTIdExpression) ((IASTUnaryExpression) ((IASTInitializerExpression) ((ICASTDesignatedInitializer) initializers2[1]) - .getOperandInitializer()).getExpression()).getOperand()) + IASTName name_xy2 = ((IASTIdExpression) ((IASTUnaryExpression) ((IASTEqualsInitializer) ((ICASTDesignatedInitializer) initializers2[1]) + .getOperandInitializer()).getInitializerClause()).getOperand()) .getName(); for (int j = 0; j < 2; ++j) { @@ -2136,13 +2135,12 @@ public class AST2Tests extends AST2BaseTest { IASTName b1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl .getDeclSpecifier()).getMembers()[1]).getDeclarators()[0] .getName(); - IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) ((IASTSimpleDeclaration) ((IASTDeclarationStatement) ((IASTCompoundStatement) f_def - .getBody()).getStatements()[0]).getDeclaration()) - .getDeclarators()[0].getInitializer()).getInitializers()[0]) + final IASTDeclarator dtor = ((IASTSimpleDeclaration) ((IASTDeclarationStatement) ((IASTCompoundStatement) f_def + .getBody()).getStatements()[0]).getDeclaration()).getDeclarators()[0]; + final IASTInitializerList initializerList = (IASTInitializerList) ((IASTEqualsInitializer)dtor.getInitializer()).getInitializerClause(); + IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializerList.getInitializers()[0]) .getDesignators()[0]).getName(); - IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) ((IASTSimpleDeclaration) ((IASTDeclarationStatement) ((IASTCompoundStatement) f_def - .getBody()).getStatements()[0]).getDeclaration()) - .getDeclarators()[0].getInitializer()).getInitializers()[1]) + IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializerList.getInitializers()[1]) .getDesignators()[0]).getName(); assertEquals(a1.resolveBinding(), a2.resolveBinding()); @@ -2177,11 +2175,11 @@ public class AST2Tests extends AST2BaseTest { IASTName b1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl .getDeclSpecifier()).getMembers()[1]).getDeclarators()[0] .getName(); - IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) S_decl - .getDeclarators()[0].getInitializer()).getInitializers()[0]) + final IASTInitializer[] initializers = ((IASTInitializerList) ((IASTEqualsInitializer) S_decl + .getDeclarators()[0].getInitializer()).getInitializerClause()).getInitializers(); + IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers[0]) .getDesignators()[0]).getName(); - IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) S_decl - .getDeclarators()[0].getInitializer()).getInitializers()[1]) + IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers[1]) .getDesignators()[0]).getName(); assertEquals(a1.resolveBinding(), a2.resolveBinding()); @@ -2219,11 +2217,11 @@ public class AST2Tests extends AST2BaseTest { IASTName b1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl .getDeclSpecifier()).getMembers()[1]).getDeclarators()[0] .getName(); - IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) x_decl - .getDeclarators()[0].getInitializer()).getInitializers()[0]) + IASTInitializer initializer = x_decl.getDeclarators()[0].getInitializer(); + initializer= (IASTInitializer) ((IASTEqualsInitializer) initializer).getInitializerClause(); + IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) initializer).getInitializers()[0]) .getDesignators()[0]).getName(); - IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) x_decl - .getDeclarators()[0].getInitializer()).getInitializers()[1]) + IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) initializer).getInitializers()[1]) .getDesignators()[0]).getName(); assertEquals(a1.resolveBinding(), a2.resolveBinding()); @@ -5483,7 +5481,7 @@ public class AST2Tests extends AST2BaseTest { final IASTFunctionDefinition fdef= getDeclaration(tu, 1); IASTFunctionDeclarator fdtor= fdef.getDeclarator(); IASTParameterDeclaration pdecl= (IASTParameterDeclaration) fdtor.getChildren()[1]; - IASTExpression expr= ((IASTInitializerExpression) pdecl.getDeclarator().getInitializer()).getExpression(); + IASTExpression expr= (IASTExpression) ((IASTEqualsInitializer) pdecl.getDeclarator().getInitializer()).getInitializerClause(); assertEquals("expr: " + exprStr, io[1].trim(), polnishNotation(expr)); assertEquals(exprStr, expr.getRawSignature()); checkOffsets(exprStr, expr); @@ -6425,7 +6423,7 @@ public class AST2Tests extends AST2BaseTest { */ private IBasicType getTypeForDeclaration(IASTDeclaration[] declarations, int index) { IASTInitializer init = ((IASTSimpleDeclaration)declarations[index]).getDeclarators()[0].getInitializer(); - return (IBasicType)((IASTInitializerExpression)init).getExpression().getExpressionType(); + return (IBasicType)((IASTExpression)((IASTEqualsInitializer)init).getInitializerClause()).getExpressionType(); } @@ -7316,4 +7314,14 @@ public class AST2Tests extends AST2BaseTest { assertEquals(i>2, ((IASTPreprocessorPragmaStatement) stmt).isPragmaOperator()); } } + + // int min(int,int); + // void test() { + // int a= (min)(1, 2); + // } + public void testFunctionNameExpression() throws Exception { + final String code = getAboveComment(); + parseAndCheckBindings(code, ParserLanguage.C, true); + parseAndCheckBindings(code, ParserLanguage.CPP, true); + } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilOldTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilOldTests.java index 23110339506..1647fc0462b 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilOldTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilOldTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,8 +11,8 @@ package org.eclipse.cdt.core.parser.tests.ast2; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; -import org.eclipse.cdt.core.dom.ast.IASTExpression; -import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression; +import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer; +import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.parser.ParserLanguage; @@ -28,77 +28,77 @@ public class AST2UtilOldTests extends AST2BaseTest { { IASTTranslationUnit tu = parse("int x = f();".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "f()" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f()" ); //$NON-NLS-1$ } // Kind PRIMARY_INTEGER_LITERAL : int public void testPrimaryIntegerLiteral() throws Exception { IASTTranslationUnit tu = parse("int x = f(1, 2+3);".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "f(1, 2 + 3)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(1, 2 + 3)" ); //$NON-NLS-1$ } // Kind PRIMARY_CHAR_LITERAL : char public void testPrimaryCharLiteral() throws Exception { IASTTranslationUnit tu = parse("int x = f('c');".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "f('c')" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f('c')" ); //$NON-NLS-1$ } // Kind PRIMARY_FLOAT_LITERAL : float public void testPrimaryFloatLiteral() throws Exception { IASTTranslationUnit tu = parse("int x = f(1.13);".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "f(1.13)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(1.13)" ); //$NON-NLS-1$ } // Kind PRIMARY_STRING_LITERAL : char* public void testPrimaryStringLiteral() throws Exception { IASTTranslationUnit tu = parse("int x = f(\"str\");".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "f(\"str\")" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(\"str\")" ); //$NON-NLS-1$ } // Kind PRIMARY_BOOLEAN_LITERAL : bool public void testPrimaryBooleanLiteral() throws Exception { IASTTranslationUnit tu = parse("int x = f(true);".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "f(true)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(true)" ); //$NON-NLS-1$ } // Kind PRIMARY_THIS : type of inner most enclosing structure scope public void testPrimaryThis() throws Exception { IASTTranslationUnit tu = parse("int x = f(this);".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "f(this)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(this)" ); //$NON-NLS-1$ } // Kind PRIMARY_BRACKETED_EXPRESSION : LHS public void testPrimaryBracketedExpression() throws Exception { IASTTranslationUnit tu = parse("int x = f(1, (2+3));".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "f(1, (2 + 3))" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(1, (2 + 3))" ); //$NON-NLS-1$ } // Kind ID_EXPRESSION : type of the ID public void testIdExpression() throws Exception { IASTTranslationUnit tu = parse("int x = f(a);".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "f(a)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(a)" ); //$NON-NLS-1$ } // Kind POSTFIX_SUBSCRIPT public void testPostfixSubscript() throws Exception { IASTTranslationUnit tu = parse("int x = f(pa[1]);".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "f(pa[1])" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(pa[1])" ); //$NON-NLS-1$ } public void testPostfixSubscriptA() throws Exception { IASTTranslationUnit tu = parse("int x = f(pa[1][2]);".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "f(pa[1][2])" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(pa[1][2])" ); //$NON-NLS-1$ } // Kind POSTFIX_FUNCTIONCALL : return type of called function @@ -106,344 +106,344 @@ public class AST2UtilOldTests extends AST2BaseTest { { IASTTranslationUnit tu = parse("int x = bar( foo( 3.0 ), foo( 5.0 ) ) ;".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "bar(foo(3.0), foo(5.0))" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "bar(foo(3.0), foo(5.0))" ); //$NON-NLS-1$ } // Kind POSTFIX_SIMPLETYPE_* : simple type public void testPostfixSimpletypesBug42823() throws Exception { IASTTranslationUnit tu = parse("int someInt = foo( int(3), short(4), double(3.0), float(4.0), char( 'a'), wchar_t( 'a' ), signed( 2 ), unsigned( 3 ), bool( false ), long( 3L ) );".toString(), ParserLanguage.CPP); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(int(3), short(4), double(3.0), float(4.0), char('a'), wchar_t('a'), signed(2), unsigned(3), bool(false), long(3L))" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(int(3), short(4), double(3.0), float(4.0), char('a'), wchar_t('a'), signed(2), unsigned(3), bool(false), long(3L))" ); //$NON-NLS-1$ } // Kind POSTFIX_DOT_IDEXPRESSION : type of member in the scope of the container public void testPostfixDotExpression() throws Exception{ IASTTranslationUnit tu = parse("class A {int m;}; \n A a; \n int foo(char); int foo( int ); \n int x = foo( a.m );".toString(), ParserLanguage.CPP); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[4]).getDeclarators()[0].getInitializer()).getExpression(), "foo(a.m)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[4]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a.m)" ); //$NON-NLS-1$ } // Kind POSTFIX_ARROW_IDEXPRESSION : type of member in the scope of the container public void testPostfixArrowExpression() throws Exception{ IASTTranslationUnit tu = parse("class A {int m;}; \n A * a; \n int foo(char); int foo( int ); \n int x = foo( a->m );".toString(), ParserLanguage.CPP); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[4]).getDeclarators()[0].getInitializer()).getExpression(), "foo(a->m)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[4]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a->m)" ); //$NON-NLS-1$ } // Kind POSTFIX_INCREMENT : LHS public void testPostfixIncrement() throws Exception { IASTTranslationUnit tu = parse("int y = foo( x++ );".toString(), ParserLanguage.CPP); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(x++)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(x++)" ); //$NON-NLS-1$ } // Kind POSTFIX_DECREMENT : LHS public void testPostfixDecrement() throws Exception { IASTTranslationUnit tu = parse("int y = foo( x-- );".toString(), ParserLanguage.CPP); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(x--)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(x--)" ); //$NON-NLS-1$ } // Kind POSTFIX_DYNAMIC_CAST public void testPostfixDynamicCast() throws Exception{ IASTTranslationUnit tu = parse("int x = foo( dynamic_cast(a) );".toString(), ParserLanguage.CPP); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(dynamic_cast(a))" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(dynamic_cast(a))" ); //$NON-NLS-1$ } // Kind POSTFIX_REINTERPRET_CAST public void testPostfixReinterpretCast() throws Exception{ IASTTranslationUnit tu = parse("int x = foo( reinterpret_cast(a) );".toString(), ParserLanguage.CPP); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(reinterpret_cast(a))" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(reinterpret_cast(a))" ); //$NON-NLS-1$ } // Kind POSTFIX_STATIC_CAST public void testPostfixStaticCast() throws Exception{ IASTTranslationUnit tu = parse("int x = foo( static_cast(a) );".toString(), ParserLanguage.CPP); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(static_cast(a))" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(static_cast(a))" ); //$NON-NLS-1$ } // Kind POSTFIX_CONST_CAST public void testPostfixConstCast() throws Exception{ IASTTranslationUnit tu = parse("int x = foo( const_cast(&a) );".toString(), ParserLanguage.CPP); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(const_cast(&a))" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(const_cast(&a))" ); //$NON-NLS-1$ } // Kind POSTFIX_TYPEID_EXPRESSION : LHS public void testPostfixTypeIdExpression() throws Exception{ IASTTranslationUnit tu = parse("int x = foo( typeid(5) );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(typeid(5))" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(typeid(5))" ); //$NON-NLS-1$ } // Kind POSTFIX_TYPEID_EXPRESSION : type of the ID public void testPostfixTypeIdExpression2() throws Exception{ IASTTranslationUnit tu = parse("int x = foo( typeid(a) );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(typeid(a))" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(typeid(a))" ); //$NON-NLS-1$ } // Kind POSTFIX_TYPEID_TYPEID : type of the ID public void testPostfixTypeIdTypeId2() throws Exception{ IASTTranslationUnit tu = parse("class A { }; int foo( int ); int x = foo( typeid(const A) );".toString(), ParserLanguage.CPP); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[2]).getDeclarators()[0].getInitializer()).getExpression(), "foo(typeid (const A))" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[2]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(typeid (const A))" ); //$NON-NLS-1$ } // Kind UNARY_INCREMENT : LHS public void testUnaryIncrement() throws Exception { IASTTranslationUnit tu = parse("int y = foo( ++x );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(++x)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(++x)" ); //$NON-NLS-1$ } // Kind UNARY_DECREMENT : LHS public void testUnaryDecrement() throws Exception { IASTTranslationUnit tu = parse("int y = foo( --x );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(--x)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(--x)" ); //$NON-NLS-1$ } // Kind UNARY_STAR_CASTEXPRESSION : LHS + t_pointer public void testUnaryStarCastExpression() throws Exception { IASTTranslationUnit tu = parse("int x = f(*pa);".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "f(*pa)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(*pa)" ); //$NON-NLS-1$ } // Kind UNARY_AMPSND_CASTEXPRESSION : LHS + t_reference public void testUnaryAmpersandCastExpression() throws Exception { IASTTranslationUnit tu = parse("int x = f(&pa);".toString(), ParserLanguage.CPP); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "f(&pa)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(&pa)" ); //$NON-NLS-1$ } // Kind UNARY_PLUS_CASTEXPRESSION : LHS public void testUnaryPlusCastExpression() throws Exception { IASTTranslationUnit tu = parse("int x = foo( +5 );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(+5)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(+5)" ); //$NON-NLS-1$ } // Kind UNARY_MINUS_CASTEXPRESSION : LHS public void testUnaryMinusCastExpression() throws Exception { IASTTranslationUnit tu = parse("int x = foo( -5 );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(-5)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(-5)" ); //$NON-NLS-1$ } // Kind UNARY_NOT_CASTEXPRESSION : LHS public void testUnaryNotCastExpression() throws Exception { IASTTranslationUnit tu = parse("int x = foo( !b );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(!b)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(!b)" ); //$NON-NLS-1$ } // Kind UNARY_TILDE_CASTEXPRESSION : LHS public void testTildeNotCastExpression() throws Exception { IASTTranslationUnit tu = parse("int y = foo( ~x );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(~x)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(~x)" ); //$NON-NLS-1$ } // Kind UNARY_SIZEOF_UNARYEXPRESSION : unsigned int public void testUnarySizeofUnaryExpression() throws Exception { IASTTranslationUnit tu = parse("int y = foo( sizeof(5) );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(sizeof (5))" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(sizeof (5))" ); //$NON-NLS-1$ } // Kind UNARY_SIZEOF_TYPEID : unsigned int public void testUnarySizeofTypeId() throws Exception { IASTTranslationUnit tu = parse("int x, y = foo( sizeof(x) );".toString(), ParserLanguage.CPP); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - final IASTExpression expression = ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[1].getInitializer()).getExpression(); + final IASTInitializerClause expression = ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[1].getInitializer()).getInitializerClause(); isExpressionStringEqual( expression, "foo(sizeof (x))" ); //$NON-NLS-1$ } // Kind NEW_TYPEID public void testNewTypeId() throws Exception { IASTTranslationUnit tu = parse("int x = foo( new A() );".toString(), ParserLanguage.CPP); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(new A())" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(new A())" ); //$NON-NLS-1$ } // Kind CASTEXPRESSION public void testCastExpression() throws Exception{ IASTTranslationUnit tu = parse("int x = foo( (A*)b );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo((A *)b)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo((A *)b)" ); //$NON-NLS-1$ } // Kind MULTIPLICATIVE_MULTIPLY : usual arithmetic conversions public void testMultiplicativeMultiply() throws Exception { IASTTranslationUnit tu = parse("int x = foo( a * b );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(a * b)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a * b)" ); //$NON-NLS-1$ } // Kind MULTIPLICATIVE_DIVIDE : usual arithmetic conversions public void testMultiplicativeDivide() throws Exception { IASTTranslationUnit tu = parse("int x = foo( b / a );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(b / a)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b / a)" ); //$NON-NLS-1$ } // Kind MULTIPLICATIVE_MODULUS : usual arithmetic conversions public void testMultiplicativeModulus() throws Exception { IASTTranslationUnit tu = parse("int x = foo( b % a );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(b % a)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b % a)" ); //$NON-NLS-1$ } // Kind ADDITIVE_PLUS : usual arithmetic conversions public void testAdditivePlus() throws Exception { IASTTranslationUnit tu = parse("int x = foo( b + a );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(b + a)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b + a)" ); //$NON-NLS-1$ } // Kind ADDITIVE_MINUS : usual arithmetic conversions public void testAdditiveMinus() throws Exception { IASTTranslationUnit tu = parse("int x = foo( b - a );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(b - a)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b - a)" ); //$NON-NLS-1$ } // Kind SHIFT_LEFT : LHS public void testShiftLeft() throws Exception { IASTTranslationUnit tu = parse("int x = foo( a << 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(a << 5)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a << 5)" ); //$NON-NLS-1$ } // Kind SHIFT_RIGHT : LHS public void testShiftRight() throws Exception { IASTTranslationUnit tu = parse("int x = foo( a >> 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(a >> 5)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a >> 5)" ); //$NON-NLS-1$ } // Kind RELATIONAL_LESSTHAN : bool public void testRelationalLessThan() throws Exception { IASTTranslationUnit tu = parse("int x = foo( b < 3 );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(b < 3)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b < 3)" ); //$NON-NLS-1$ } // Kind RELATIONAL_GREATERTHAN : bool public void testRelationalGreaterThan() throws Exception { IASTTranslationUnit tu = parse("int x = foo( b > 3 );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(b > 3)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b > 3)" ); //$NON-NLS-1$ } // Kind RELATIONAL_LESSTHANEQUALTO : bool public void testRelationalLessThanOrEqual() throws Exception { IASTTranslationUnit tu = parse("int x = foo( b <= 3 );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(b <= 3)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b <= 3)" ); //$NON-NLS-1$ } // Kind RELATIONAL_GREATERTHANEQUALTO : bool public void testRelationalGreaterThanOrEqual() throws Exception { IASTTranslationUnit tu = parse("int x = foo( b >= 3 );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(b >= 3)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b >= 3)" ); //$NON-NLS-1$ } // Kind EQUALITY_EQUALS : bool public void testEqualityEquals() throws Exception { IASTTranslationUnit tu = parse("int x = foo( b == 3 );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(b == 3)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b == 3)" ); //$NON-NLS-1$ } // Kind EQUALITY_NOTEQUALS : bool public void testEqualityNotEquals() throws Exception { IASTTranslationUnit tu = parse("int x = foo( b != 3 );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(b != 3)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b != 3)" ); //$NON-NLS-1$ } // Kind ANDEXPRESSION : usual arithmetic conversions public void testAndExpression() throws Exception { IASTTranslationUnit tu = parse("int x = foo( a & b );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(a & b)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a & b)" ); //$NON-NLS-1$ } // Kind EXCLUSIVEOREXPRESSION : usual arithmetic conversions public void testExclusiveOrExpression() throws Exception { IASTTranslationUnit tu = parse("int x = foo( a ^ b );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(a ^ b)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a ^ b)" ); //$NON-NLS-1$ } // Kind INCLUSIVEOREXPRESSION : : usual arithmetic conversions public void testInclusiveOrExpression() throws Exception { IASTTranslationUnit tu = parse("int x = foo( a | b );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(a | b)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a | b)" ); //$NON-NLS-1$ } // Kind LOGICALANDEXPRESSION : bool public void testLogicalAndExpression() throws Exception { IASTTranslationUnit tu = parse("int x = foo( a && b );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(a && b)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a && b)" ); //$NON-NLS-1$ } // Kind LOGICALOREXPRESSION : bool public void testLogicalOrExpression() throws Exception { IASTTranslationUnit tu = parse("int x = foo( a || b );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(a || b)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a || b)" ); //$NON-NLS-1$ } // Kind CONDITIONALEXPRESSION : conditional Expression Conversions public void testConditionalExpression() throws Exception { IASTTranslationUnit tu = parse("int x = foo( a > 5 ? b : c );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(a > 5 ? b : c)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a > 5 ? b : c)" ); //$NON-NLS-1$ } // Kind ASSIGNMENTEXPRESSION_NORMAL : LHS public void testAssignmentExpressionNormal() throws Exception { IASTTranslationUnit tu = parse("int x = foo( a = 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(a = 5)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a = 5)" ); //$NON-NLS-1$ } // Kind ASSIGNMENTEXPRESSION_PLUS : LHS public void testAssignmentExpressionPlus() throws Exception { IASTTranslationUnit tu = parse("int x = foo( a += 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(a += 5)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a += 5)" ); //$NON-NLS-1$ } // Kind ASSIGNMENTEXPRESSION_MINUS : LHS public void testAssignmentExpressionMinus() throws Exception { IASTTranslationUnit tu = parse("int x = foo( a -= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(a -= 5)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a -= 5)" ); //$NON-NLS-1$ } // Kind ASSIGNMENTEXPRESSION_MULT : LHS public void testAssignmentExpressionMulti() throws Exception { IASTTranslationUnit tu = parse("int x = foo( a *= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(a *= 5)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a *= 5)" ); //$NON-NLS-1$ } // Kind ASSIGNMENTEXPRESSION_DIV : LHS public void testAssignmentExpressionDiv() throws Exception { IASTTranslationUnit tu = parse("int x = foo( a /= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(a /= 5)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a /= 5)" ); //$NON-NLS-1$ } // Kind ASSIGNMENTEXPRESSION_MOD : LHS public void testAssignmentExpressionMod() throws Exception { IASTTranslationUnit tu = parse("int x = foo( a %= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(a %= 5)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a %= 5)" ); //$NON-NLS-1$ } // Kind ASSIGNMENTEXPRESSION_LSHIFT : LHS public void testAssignmentExpressionLShift() throws Exception { IASTTranslationUnit tu = parse("int x = foo( a >>= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(a >>= 5)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a >>= 5)" ); //$NON-NLS-1$ } // Kind ASSIGNMENTEXPRESSION_RSHIFT : LHS public void testAssignmentExpressionRShift() throws Exception { IASTTranslationUnit tu = parse("int x = foo( a <<= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(a <<= 5)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a <<= 5)" ); //$NON-NLS-1$ } // Kind ASSIGNMENTEXPRESSION_AND : LHS public void testAssignmentExpressionAnd() throws Exception { IASTTranslationUnit tu = parse("int x = foo( a &= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(a &= 5)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a &= 5)" ); //$NON-NLS-1$ } // Kind ASSIGNMENTEXPRESSION_OR : LHS public void testAssignmentExpressionOr() throws Exception { IASTTranslationUnit tu = parse("int x = foo( a |= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(a |= 5)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a |= 5)" ); //$NON-NLS-1$ } // Kind ASSIGNMENTEXPRESSION_XOR : LHS public void testAssignmentExpressionXOr() throws Exception { IASTTranslationUnit tu = parse("int x = foo( a ^= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$ IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual( ((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression(), "foo(a ^= 5)" ); //$NON-NLS-1$ + isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a ^= 5)" ); //$NON-NLS-1$ } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilTests.java index 083e76a1c11..2b2212cddc6 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,8 +14,8 @@ import org.eclipse.cdt.core.dom.ast.ASTSignatureUtil; import org.eclipse.cdt.core.dom.ast.IASTCastExpression; import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; +import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer; import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; -import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression; import org.eclipse.cdt.core.dom.ast.IASTReturnStatement; import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; @@ -51,16 +51,16 @@ public class AST2UtilTests extends AST2BaseTest { IASTTranslationUnit tu = parse(buff.toString(), ParserLanguage.C); IASTDeclaration[] d = tu.getDeclarations(); - isExpressionStringEqual(((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[2].getInitializer()).getExpression(), "0"); //$NON-NLS-1$ - isExpressionStringEqual(((IASTInitializerExpression)((IASTSimpleDeclaration)d[1]).getDeclarators()[0].getInitializer()).getExpression(), "l ? m : n"); //$NON-NLS-1$ - isExpressionStringEqual(((IASTInitializerExpression)((IASTSimpleDeclaration)d[2]).getDeclarators()[0].getInitializer()).getExpression(), "l ^ m"); //$NON-NLS-1$ - isExpressionStringEqual(((IASTInitializerExpression)((IASTSimpleDeclaration)d[3]).getDeclarators()[0].getInitializer()).getExpression(), "i <<= j"); //$NON-NLS-1$ - isExpressionStringEqual(((IASTInitializerExpression)((IASTSimpleDeclaration)d[4]).getDeclarators()[0].getInitializer()).getExpression(), "sizeof (int)"); //$NON-NLS-1$ - isExpressionStringEqual(((IASTInitializerExpression)((IASTSimpleDeclaration)d[5]).getDeclarators()[0].getInitializer()).getExpression(), "~f"); //$NON-NLS-1$ - isExpressionStringEqual(((IASTInitializerExpression)((IASTSimpleDeclaration)d[6]).getDeclarators()[0].getInitializer()).getExpression(), "++e"); //$NON-NLS-1$ - isExpressionStringEqual(((IASTInitializerExpression)((IASTSimpleDeclaration)d[7]).getDeclarators()[0].getInitializer()).getExpression(), "d++"); //$NON-NLS-1$ - isExpressionStringEqual(((IASTInitializerExpression)((IASTSimpleDeclaration)d[8]).getDeclarators()[0].getInitializer()).getExpression(), "sizeof b"); //$NON-NLS-1$ - isExpressionStringEqual(((IASTInitializerExpression)((IASTSimpleDeclaration)d[9]).getDeclarators()[0].getInitializer()).getExpression(), "b + c"); //$NON-NLS-1$ + isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[2].getInitializer()).getInitializerClause(), "0"); //$NON-NLS-1$ + isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[1]).getDeclarators()[0].getInitializer()).getInitializerClause(), "l ? m : n"); //$NON-NLS-1$ + isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[2]).getDeclarators()[0].getInitializer()).getInitializerClause(), "l ^ m"); //$NON-NLS-1$ + isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[3]).getDeclarators()[0].getInitializer()).getInitializerClause(), "i <<= j"); //$NON-NLS-1$ + isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[4]).getDeclarators()[0].getInitializer()).getInitializerClause(), "sizeof (int)"); //$NON-NLS-1$ + isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[5]).getDeclarators()[0].getInitializer()).getInitializerClause(), "~f"); //$NON-NLS-1$ + isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[6]).getDeclarators()[0].getInitializer()).getInitializerClause(), "++e"); //$NON-NLS-1$ + isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[7]).getDeclarators()[0].getInitializer()).getInitializerClause(), "d++"); //$NON-NLS-1$ + isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[8]).getDeclarators()[0].getInitializer()).getInitializerClause(), "sizeof b"); //$NON-NLS-1$ + isExpressionStringEqual(((IASTEqualsInitializer)((IASTSimpleDeclaration)d[9]).getDeclarators()[0].getInitializer()).getInitializerClause(), "b + c"); //$NON-NLS-1$ } public void testSimpleParameter() throws Exception { @@ -141,14 +141,14 @@ public class AST2UtilTests extends AST2BaseTest { IASTDeclaration[] d = tu.getDeclarations(); // verify signatures - isSignatureEqual( ((IASTTypeIdExpression)((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression()).getTypeId(), "int"); //$NON-NLS-1$ + isSignatureEqual( ((IASTTypeIdExpression)((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause()).getTypeId(), "int"); //$NON-NLS-1$ isSignatureEqual( ((IASTTypeIdExpression)((IASTReturnStatement)((IASTCompoundStatement)((IASTFunctionDefinition)d[2]).getBody()).getStatements()[0]).getReturnValue()).getTypeId(), "Squaw"); //$NON-NLS-1$ - isSignatureEqual( ((IASTCastExpression)((IASTInitializerExpression)((IASTSimpleDeclaration)d[6]).getDeclarators()[0].getInitializer()).getExpression()).getTypeId() , "jc"); //$NON-NLS-1$ + isSignatureEqual( ((IASTCastExpression)((IASTEqualsInitializer)((IASTSimpleDeclaration)d[6]).getDeclarators()[0].getInitializer()).getInitializerClause()).getTypeId() , "jc"); //$NON-NLS-1$ // verify types - isTypeEqual( ((IASTTypeIdExpression)((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression()).getTypeId(), "int"); //$NON-NLS-1$ + isTypeEqual( ((IASTTypeIdExpression)((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause()).getTypeId(), "int"); //$NON-NLS-1$ isTypeEqual( ((IASTTypeIdExpression)((IASTReturnStatement)((IASTCompoundStatement)((IASTFunctionDefinition)d[2]).getBody()).getStatements()[0]).getReturnValue()).getTypeId(), "Squaw"); //$NON-NLS-1$ - isTypeEqual( ((IASTCastExpression)((IASTInitializerExpression)((IASTSimpleDeclaration)d[6]).getDeclarators()[0].getInitializer()).getExpression()).getTypeId() , "short int"); //$NON-NLS-1$ + isTypeEqual( ((IASTCastExpression)((IASTEqualsInitializer)((IASTSimpleDeclaration)d[6]).getDeclarators()[0].getInitializer()).getInitializerClause()).getTypeId() , "short int"); //$NON-NLS-1$ } public void testKnRC() throws Exception { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationMacroTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationMacroTests.java index 04bd7cb8d2c..27c22c01543 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationMacroTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationMacroTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,10 +14,10 @@ package org.eclipse.cdt.core.parser.tests.ast2; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; -import org.eclipse.cdt.core.dom.ast.IASTExpression; +import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer; import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; -import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression; +import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; import org.eclipse.cdt.core.dom.ast.IASTMacroExpansionLocation; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNodeLocation; @@ -51,8 +51,8 @@ public class DOMLocationMacroTests extends AST2BaseTest { StringBuffer buffer = new StringBuffer( "#define ABC D\n" ); //$NON-NLS-1$ buffer.append( "int ABC;"); //$NON-NLS-1$ String code = buffer.toString(); - for(int i = 0; i < languages.length; i++) { - IASTTranslationUnit tu = parse(code, languages[i]); + for (ParserLanguage language : languages) { + IASTTranslationUnit tu = parse(code, language); IASTPreprocessorObjectStyleMacroDefinition ABC = (IASTPreprocessorObjectStyleMacroDefinition) tu.getMacroDefinitions()[0]; IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0]; IASTDeclarator d = var.getDeclarators()[0]; @@ -77,8 +77,8 @@ public class DOMLocationMacroTests extends AST2BaseTest { StringBuffer buffer = new StringBuffer( "#define ABC * D\n" ); //$NON-NLS-1$ buffer.append( "int ABC;"); //$NON-NLS-1$ String code = buffer.toString(); - for(int i = 0; i < languages.length; i++) { - IASTTranslationUnit tu = parse(code, languages[i]); + for (ParserLanguage language : languages) { + IASTTranslationUnit tu = parse(code, language); IASTPreprocessorObjectStyleMacroDefinition ABC = (IASTPreprocessorObjectStyleMacroDefinition) tu.getMacroDefinitions()[0]; IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0]; IASTDeclarator d = var.getDeclarators()[0]; @@ -124,8 +124,8 @@ public class DOMLocationMacroTests extends AST2BaseTest { StringBuffer buffer = new StringBuffer( "#define XYZ const\n"); //$NON-NLS-1$ buffer.append( "XYZ int var;"); //$NON-NLS-1$ String code = buffer.toString(); - for(int i = 0; i < languages.length; i++) { - IASTTranslationUnit tu = parse(code, languages[i]); + for (ParserLanguage language : languages) { + IASTTranslationUnit tu = parse(code, language); IASTPreprocessorObjectStyleMacroDefinition defXYZ = (IASTPreprocessorObjectStyleMacroDefinition) tu.getMacroDefinitions()[0]; IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0]; IASTSimpleDeclSpecifier declSpec = (IASTSimpleDeclSpecifier) var.getDeclSpecifier(); @@ -154,8 +154,8 @@ public class DOMLocationMacroTests extends AST2BaseTest { buffer.append( "int C_PO var;"); //$NON-NLS-1$ String code = buffer.toString(); - for(int i = 0; i < languages.length; i++) { - IASTTranslationUnit tu = parse(code, languages[i]); + for (ParserLanguage language : languages) { + IASTTranslationUnit tu = parse(code, language); final IASTPreprocessorMacroDefinition[] macroDefinitions = tu.getMacroDefinitions(); IASTPreprocessorMacroDefinition XYZ = macroDefinitions[0]; IASTPreprocessorMacroDefinition PO = macroDefinitions[1]; @@ -188,8 +188,8 @@ public class DOMLocationMacroTests extends AST2BaseTest { buffer.append( "XYZ IT C_PO C_PO V;"); //$NON-NLS-1$ String code = buffer.toString(); - for(int i = 0; i < languages.length; i++) { - IASTTranslationUnit tu = parse(code, languages[i]); + for (ParserLanguage language : languages) { + IASTTranslationUnit tu = parse(code, language); IASTPreprocessorObjectStyleMacroDefinition XYZ = (IASTPreprocessorObjectStyleMacroDefinition) tu.getMacroDefinitions()[0]; // IASTPreprocessorObjectStyleMacroDefinition PO = (IASTPreprocessorObjectStyleMacroDefinition) tu.getMacroDefinitions()[1]; IASTPreprocessorObjectStyleMacroDefinition C_PO = (IASTPreprocessorObjectStyleMacroDefinition) tu.getMacroDefinitions()[2]; @@ -238,8 +238,8 @@ public class DOMLocationMacroTests extends AST2BaseTest { buffer.append( "_PTR _EXFUN(memchr,(const _PTR, int, size_t));\n"); //$NON-NLS-1$ String code = buffer.toString(); - for(int i = 0; i < languages.length; i++) { - IASTTranslationUnit tu = parse(code, languages[i], true, true); + for (ParserLanguage language : languages) { + IASTTranslationUnit tu = parse(code, language, true, true); final IASTPreprocessorMacroDefinition[] macroDefinitions = tu.getMacroDefinitions(); IASTPreprocessorObjectStyleMacroDefinition _PTR = (IASTPreprocessorObjectStyleMacroDefinition) macroDefinitions[0]; IASTPreprocessorFunctionStyleMacroDefinition _EXFUN = (IASTPreprocessorFunctionStyleMacroDefinition) macroDefinitions[2]; @@ -280,8 +280,8 @@ public class DOMLocationMacroTests extends AST2BaseTest { buffer.append( "#define ABC ghi\n"); //$NON-NLS-1$ buffer.append( "int ABC;\n"); //$NON-NLS-1$ String code = buffer.toString(); - for(int i = 0; i < languages.length; i++) { - IASTTranslationUnit tu = parse(code, languages[i]); + for (ParserLanguage language : languages) { + IASTTranslationUnit tu = parse(code, language); IASTPreprocessorMacroDefinition [] macros = tu.getMacroDefinitions(); assertEquals( macros.length, 2 ); IASTPreprocessorObjectStyleMacroDefinition ABC1 = (IASTPreprocessorObjectStyleMacroDefinition) macros[0]; @@ -314,8 +314,8 @@ public class DOMLocationMacroTests extends AST2BaseTest { StringBuffer buffer = new StringBuffer( "#define MACRO mm\n"); //$NON-NLS-1$ buffer.append( "int MACRO;\n"); //$NON-NLS-1$ String code = buffer.toString(); - for(int i = 0; i < languages.length; i++) { - IASTTranslationUnit tu = parse(code, languages[i]); + for (ParserLanguage language : languages) { + IASTTranslationUnit tu = parse(code, language); IASTPreprocessorObjectStyleMacroDefinition MACRO = (IASTPreprocessorObjectStyleMacroDefinition) tu.getMacroDefinitions()[0]; IASTName macro_name = MACRO.getName(); IMacroBinding binding = (IMacroBinding) macro_name.resolveBinding(); @@ -336,8 +336,8 @@ public class DOMLocationMacroTests extends AST2BaseTest { buffer.append( "#define MYAPI API\n"); //$NON-NLS-1$ buffer.append( "MYAPI void func() {}" ); //$NON-NLS-1$ String code = buffer.toString(); - for(int i = 0; i < languages.length; i++) { - IASTTranslationUnit tu = parse(code, languages[i]); + for (ParserLanguage language : languages) { + IASTTranslationUnit tu = parse(code, language); IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0]; assertNotNull( f.getFileLocation() ); } @@ -350,11 +350,11 @@ public class DOMLocationMacroTests extends AST2BaseTest { buffer.append( "int var= FUNCTION(1);"); //$NON-NLS-1$ String code = buffer.toString(); - for(int i = 0; i < languages.length; i++) { - IASTTranslationUnit tu = parse(code, languages[i]); + for (ParserLanguage language : languages) { + IASTTranslationUnit tu = parse(code, language); IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0]; - IASTInitializerExpression initializer= (IASTInitializerExpression)var.getDeclarators()[0].getInitializer(); - IASTExpression expr= initializer.getExpression(); + IASTEqualsInitializer initializer= (IASTEqualsInitializer)var.getDeclarators()[0].getInitializer(); + IASTInitializerClause expr= initializer.getInitializerClause(); assertNotNull(expr.getFileLocation()); IASTNodeLocation [] locations = expr.getNodeLocations(); assertEquals(1, locations.length); @@ -369,8 +369,8 @@ public class DOMLocationMacroTests extends AST2BaseTest { private void assertMacroLocation(IASTDeclaration decl, int index, int length) { IASTSimpleDeclaration var = (IASTSimpleDeclaration) decl; - IASTInitializerExpression initializer= (IASTInitializerExpression)var.getDeclarators()[0].getInitializer(); - IASTExpression expr= initializer.getExpression(); + IASTEqualsInitializer initializer= (IASTEqualsInitializer)var.getDeclarators()[0].getInitializer(); + IASTInitializerClause expr= initializer.getInitializerClause(); assertNotNull(expr.getFileLocation()); IASTNodeLocation [] locations = expr.getNodeLocations(); assertEquals(1, locations.length); @@ -384,8 +384,8 @@ public class DOMLocationMacroTests extends AST2BaseTest { private void assertExpressionLocation(IASTDeclaration decl, int index, int length) { IASTSimpleDeclaration var = (IASTSimpleDeclaration) decl; - IASTInitializerExpression initializer= (IASTInitializerExpression)var.getDeclarators()[0].getInitializer(); - IASTExpression expr= initializer.getExpression(); + IASTEqualsInitializer initializer= (IASTEqualsInitializer)var.getDeclarators()[0].getInitializer(); + IASTInitializerClause expr= initializer.getInitializerClause(); IASTFileLocation fileLocation = expr.getFileLocation(); assertNotNull(fileLocation); assertEquals(index, fileLocation.getNodeOffset()); @@ -402,8 +402,8 @@ public class DOMLocationMacroTests extends AST2BaseTest { sb.append("int y = whatever; \n"); //$NON-NLS-1$ String code = sb.toString(); - for(int i = 0; i < languages.length; i++) { - IASTTranslationUnit tu = parse(code, languages[i]); + for (ParserLanguage language : languages) { + IASTTranslationUnit tu = parse(code, language); IASTDeclaration[] decls = tu.getDeclarations(); assertMacroLocation(decls[1], code.indexOf("Nullstr;"), "Nullstr".length()); //$NON-NLS-1$ //$NON-NLS-2$ assertExpressionLocation(decls[2], code.indexOf("whatever;"), "whatever".length()); //$NON-NLS-1$ //$NON-NLS-2$ @@ -421,8 +421,8 @@ public class DOMLocationMacroTests extends AST2BaseTest { sb.append("int y = whatever; \n"); //$NON-NLS-1$ String code = sb.toString(); - for(int i = 0; i < languages.length; i++) { - IASTTranslationUnit tu = parse(code, languages[i]); + for (ParserLanguage language : languages) { + IASTTranslationUnit tu = parse(code, language); IASTDeclaration[] decls = tu.getDeclarations(); assertMacroLocation(decls[0], code.indexOf("ADD(ONEYONENOE,TWO, THREE)"), "ADD(ONEYONENOE,TWO, THREE)".length()); //$NON-NLS-1$ //$NON-NLS-2$ assertExpressionLocation(decls[1], code.indexOf("whatever;"), "whatever".length()); //$NON-NLS-1$ //$NON-NLS-2$ @@ -438,8 +438,8 @@ public class DOMLocationMacroTests extends AST2BaseTest { sb.append("int y = whatever; \n"); //$NON-NLS-1$ String code = sb.toString(); - for(int i = 0; i < languages.length; i++) { - IASTTranslationUnit tu = parse(code, languages[i]); + for (ParserLanguage language : languages) { + IASTTranslationUnit tu = parse(code, language); IASTDeclaration[] decls = tu.getDeclarations(); assertMacroLocation(decls[0], code.indexOf("add2 z);"), "add2 z)".length()); //$NON-NLS-1$ //$NON-NLS-2$ assertExpressionLocation(decls[1], code.indexOf("whatever;"), "whatever".length()); //$NON-NLS-1$ //$NON-NLS-2$ @@ -455,8 +455,8 @@ public class DOMLocationMacroTests extends AST2BaseTest { sb.append("int y = whatever; \n"); //$NON-NLS-1$ String code = sb.toString(); - for(int i = 0; i < languages.length; i++) { - IASTTranslationUnit tu = parse(code, languages[i]); + for (ParserLanguage language : languages) { + IASTTranslationUnit tu = parse(code, language); IASTDeclaration[] decls = tu.getDeclarations(); assertMacroLocation(decls[0], code.indexOf("YO;"), "YO".length()); //$NON-NLS-1$ //$NON-NLS-2$ assertExpressionLocation(decls[1], code.indexOf("whatever;"), "whatever".length()); //$NON-NLS-1$ //$NON-NLS-2$ @@ -472,8 +472,8 @@ public class DOMLocationMacroTests extends AST2BaseTest { sb.append("int y = whatever; \n"); //$NON-NLS-1$ String code = sb.toString(); - for(int i = 0; i < languages.length; i++) { - IASTTranslationUnit tu = parse(code, languages[i]); + for (ParserLanguage language : languages) { + IASTTranslationUnit tu = parse(code, language); IASTDeclaration[] decls = tu.getDeclarations(); assertMacroLocation(decls[0], code.indexOf("MAKEFUN(1)(z);"), "MAKEFUN(1)(z)".length()); //$NON-NLS-1$ //$NON-NLS-2$ assertExpressionLocation(decls[1], code.indexOf("whatever;"), "whatever".length()); //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationTests.java index ff41bab7c1f..34dd6256ac4 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -22,7 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier; -import org.eclipse.cdt.core.dom.ast.IASTExpression; +import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer; import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement; import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.core.dom.ast.IASTForStatement; @@ -32,7 +32,7 @@ import org.eclipse.cdt.core.dom.ast.IASTFunctionStyleMacroParameter; import org.eclipse.cdt.core.dom.ast.IASTIdExpression; import org.eclipse.cdt.core.dom.ast.IASTIfStatement; import org.eclipse.cdt.core.dom.ast.IASTInitializer; -import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression; +import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNodeLocation; @@ -297,9 +297,9 @@ public class DOMLocationTests extends AST2BaseTest { } assertSoleLocation(decl, start, length); } - IASTInitializerExpression initializer = (IASTInitializerExpression) ((IASTSimpleDeclaration) declarations[2]) + IASTEqualsInitializer initializer = (IASTEqualsInitializer) ((IASTSimpleDeclaration) declarations[2]) .getDeclarators()[0].getInitializer(); - IASTCastExpression castExpression = (IASTCastExpression) initializer.getExpression(); + IASTCastExpression castExpression = (IASTCastExpression) initializer.getInitializerClause(); IASTTypeId typeId = castExpression.getTypeId(); assertSoleLocation(typeId, code.indexOf("(jc)") + 1, "jc".length()); //$NON-NLS-1$ //$NON-NLS-2$ } @@ -326,9 +326,9 @@ public class DOMLocationTests extends AST2BaseTest { IASTCompoundStatement statement = (IASTCompoundStatement) main.getBody(); IASTDeclarationStatement decl = (IASTDeclarationStatement) statement.getStatements()[0]; IASTSimpleDeclaration b = (IASTSimpleDeclaration) decl.getDeclaration(); - IASTInitializerExpression initializerExpression = (IASTInitializerExpression) b.getDeclarators()[0].getInitializer(); - assertSoleLocation(initializerExpression,code.indexOf("new B()"), "new B()".length()); //$NON-NLS-1$ //$NON-NLS-2$ - ICPPASTNewExpression newExpression = (ICPPASTNewExpression) initializerExpression.getExpression(); + IASTEqualsInitializer initializerExpression = (IASTEqualsInitializer) b.getDeclarators()[0].getInitializer(); + assertSoleLocation(initializerExpression.getInitializerClause(),code.indexOf("new B()"), "new B()".length()); //$NON-NLS-1$ //$NON-NLS-2$ + ICPPASTNewExpression newExpression = (ICPPASTNewExpression) initializerExpression.getInitializerClause(); assertSoleLocation(newExpression, code.indexOf("new B()"), "new B()".length()); //$NON-NLS-1$ //$NON-NLS-2$ } @@ -620,8 +620,8 @@ public class DOMLocationTests extends AST2BaseTest { IASTDeclarator[] declarators= simpleDecl.getDeclarators(); assertEquals(1, declarators.length); IASTInitializer initializer= declarators[0].getInitializer(); - assertTrue(initializer instanceof IASTInitializerExpression); - IASTExpression expr= ((IASTInitializerExpression)initializer).getExpression(); + assertTrue(initializer instanceof IASTEqualsInitializer); + IASTInitializerClause expr= ((IASTEqualsInitializer)initializer).getInitializerClause(); assertTrue(expr instanceof IASTTypeIdExpression); assertSoleLocation(expr, buffer.indexOf("sizeof"), "sizeof(int)".length()); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMPreprocessorInformationTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMPreprocessorInformationTest.java index 501b1676007..6b9be5bf38a 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMPreprocessorInformationTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMPreprocessorInformationTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -12,7 +12,8 @@ ******************************************************************************/ package org.eclipse.cdt.core.parser.tests.ast2; -import org.eclipse.cdt.core.dom.ast.IASTInitializer; +import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer; +import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; import org.eclipse.cdt.core.dom.ast.IASTNodeLocation; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorElifStatement; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorEndifStatement; @@ -177,7 +178,9 @@ public class DOMPreprocessorInformationTest extends AST2BaseTest { assertTrue(st[0] instanceof IASTPreprocessorFunctionStyleMacroDefinition); IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0]; - IASTInitializer init = decl.getDeclarators()[0].getInitializer(); + IASTEqualsInitializer einit = (IASTEqualsInitializer) decl.getDeclarators()[0].getInitializer(); + IASTInitializerClause init= einit.getInitializerClause(); + IASTNodeLocation[] nodeLocations = init.getNodeLocations(); assertEquals(1, nodeLocations.length); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCCompleteParseExtensionsTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCCompleteParseExtensionsTest.java index 91db6fc24d9..3aef461ea42 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCCompleteParseExtensionsTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCCompleteParseExtensionsTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,8 +17,9 @@ import java.io.Writer; import org.eclipse.cdt.core.dom.ast.ASTSignatureUtil; import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; +import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer; +import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; -import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression; import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IFunctionType; @@ -89,12 +90,12 @@ public class GCCCompleteParseExtensionsTest extends AST2BaseTest { public void testBug39698A() throws Exception { IASTDeclaration[] decls = parseGPP("int a=0; \n int b=1; \n int c = a ? b;").getDeclarations(); //$NON-NLS-1$ - assertEquals( ASTSignatureUtil.getExpressionString( ((IASTInitializerExpression)((IASTSimpleDeclaration)decls[2]).getDeclarators()[0].getInitializer()).getExpression() ), "a >? b" ); //$NON-NLS-1$ + assertEquals( ASTSignatureUtil.getExpressionString( (IASTExpression) ((IASTEqualsInitializer)((IASTSimpleDeclaration)decls[2]).getDeclarators()[0].getInitializer()).getInitializerClause() ), "a >? b" ); //$NON-NLS-1$ } public void testPredefinedSymbol_bug69791() throws Exception { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/append/CtorChainInitializerTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/append/CtorChainInitializerTest.java index e652e235a49..59445b8e0dc 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/append/CtorChainInitializerTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/append/CtorChainInitializerTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -54,7 +54,8 @@ public class CtorChainInitializerTest extends ChangeGeneratorTest { CPPASTFunctionDefinition fdef = (CPPASTFunctionDefinition)decl; CPPASTIdExpression initExpr = new CPPASTIdExpression(new CPPASTName("a".toCharArray())); //$NON-NLS-1$ CPPASTName initName = new CPPASTName("alpha".toCharArray()); //$NON-NLS-1$ - ICPPASTConstructorChainInitializer newInitializer = new CPPASTConstructorChainInitializer(initName, initExpr); + ICPPASTConstructorChainInitializer newInitializer = new CPPASTConstructorChainInitializer(initName, null); + newInitializer.setInitializerValue(initExpr); ASTModification modification = new ASTModification(ModificationKind.APPEND_CHILD, fdef, newInitializer, null); modStore.storeModification(null, modification); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/CtorChainInitializerTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/CtorChainInitializerTest.java index cbb71d1e050..1215aed1202 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/CtorChainInitializerTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/CtorChainInitializerTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -53,7 +53,8 @@ public class CtorChainInitializerTest extends ChangeGeneratorTest { ICPPASTConstructorChainInitializer ctorInitializer = functionDeclarator.getConstructorChain()[0]; CPPASTIdExpression initExpr = new CPPASTIdExpression(new CPPASTName("a".toCharArray())); //$NON-NLS-1$ CPPASTName initName = new CPPASTName("alpha".toCharArray()); //$NON-NLS-1$ - ICPPASTConstructorChainInitializer newInitializer = new CPPASTConstructorChainInitializer(initName, initExpr); + ICPPASTConstructorChainInitializer newInitializer = new CPPASTConstructorChainInitializer(initName, null); + newInitializer.setInitializerValue(initExpr); ASTModification modification = new ASTModification(ModificationKind.INSERT_BEFORE, ctorInitializer, newInitializer, null); modStore.storeModification(null, modification); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/remove/NewInitializerExpressionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/remove/NewInitializerExpressionTest.java index 5b374997a06..090219f4017 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/remove/NewInitializerExpressionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/remove/NewInitializerExpressionTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -14,7 +14,9 @@ package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.remove; import junit.framework.Test; import org.eclipse.cdt.core.dom.ast.IASTExpression; +import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression; import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest; import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification; @@ -49,7 +51,8 @@ public class NewInitializerExpressionTest extends ChangeGeneratorTest { public int visit(IASTExpression expression) { if (expression instanceof ICPPASTNewExpression) { ICPPASTNewExpression newExpression = (ICPPASTNewExpression) expression; - ASTModification modification = new ASTModification(ASTModification.ModificationKind.REPLACE, newExpression.getNewInitializer(), null, null); + final IASTNode lit = ((ICPPASTConstructorInitializer) newExpression.getInitializer()).getArguments()[0]; + ASTModification modification = new ASTModification(ASTModification.ModificationKind.REPLACE, lit, null, null); modStore.storeModification(null, modification); } return PROCESS_CONTINUE; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/replace/CtorChainInitializerTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/replace/CtorChainInitializerTest.java index 8db4323f9dc..0a7ffe2a6b6 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/replace/CtorChainInitializerTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/replace/CtorChainInitializerTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -58,7 +58,8 @@ public class CtorChainInitializerTest extends ChangeGeneratorTest { for(ICPPASTConstructorChainInitializer curInitializer : ctorInitializers){ CPPASTIdExpression initExpr = new CPPASTIdExpression(new CPPASTName("a".toCharArray())); //$NON-NLS-1$ CPPASTName initName = new CPPASTName("alpha".toCharArray()); //$NON-NLS-1$ - ICPPASTConstructorChainInitializer newInitializer = new CPPASTConstructorChainInitializer(initName, initExpr); + ICPPASTConstructorChainInitializer newInitializer = new CPPASTConstructorChainInitializer(initName, null); + newInitializer.setInitializerValue(initExpr); ASTModification modification = new ASTModification(ModificationKind.REPLACE, curInitializer, newInitializer, null); modStore.storeModification(null, modification); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/replace/InitializerTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/replace/InitializerTest.java index b7257f95e6b..41a58b2f2aa 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/replace/InitializerTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/replace/InitializerTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -18,7 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IASTInitializer; import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor; import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDeclarator; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTInitializerExpression; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTEqualsInitializer; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression; import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification; import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore; @@ -57,7 +57,7 @@ public class InitializerTest extends ChangeGeneratorTest { IASTInitializer initializer = fieldDeclarator.getInitializer(); CPPASTLiteralExpression litEx = new CPPASTLiteralExpression(0, "999"); //$NON-NLS-1$ - CPPASTInitializerExpression initExpr = new CPPASTInitializerExpression(litEx); + CPPASTEqualsInitializer initExpr = new CPPASTEqualsInitializer(litEx); ASTModification modification = new ASTModification(ModificationKind.REPLACE, initializer, initExpr, null); modStore.storeModification(null, modification); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/replace/NewInitializerExpressionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/replace/NewInitializerExpressionTest.java index 323a588d7e8..277d7816a4f 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/replace/NewInitializerExpressionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/replace/NewInitializerExpressionTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -14,7 +14,9 @@ package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.replace; import junit.framework.Test; import org.eclipse.cdt.core.dom.ast.IASTExpression; +import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression; import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression; @@ -54,7 +56,8 @@ public class NewInitializerExpressionTest extends ChangeGeneratorTest { public int visit(IASTExpression expression) { if (expression instanceof ICPPASTNewExpression) { ICPPASTNewExpression newExpression = (ICPPASTNewExpression) expression; - ASTModification modification = new ASTModification(ASTModification.ModificationKind.REPLACE, newExpression.getNewInitializer(), new CPPASTLiteralExpression(0, "6"), null); //$NON-NLS-1$ + final IASTNode lit = ((ICPPASTConstructorInitializer) newExpression.getInitializer()).getArguments()[0]; + ASTModification modification = new ASTModification(ASTModification.ModificationKind.REPLACE, lit, new CPPASTLiteralExpression(0, "6".toCharArray()), null); //$NON-NLS-1$ modStore.storeModification(null, modification); } return PROCESS_CONTINUE; diff --git a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclaratorTestSource.awts b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclaratorTestSource.awts index a1e74cdc39e..b5e0ab31b18 100644 --- a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclaratorTestSource.awts +++ b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclaratorTestSource.awts @@ -50,13 +50,18 @@ int fun3(int i, const char *a, ...); //!CPPFunctionDeclaratorTest //%CPP char & operator [](unsigned int); +class TestClass +{ + int alpha; + TestClass(int a); + virtual void pure() =0; +}; TestClass::TestClass(int a) :alpha(a) { } void undefPar(const char *c) throw (int); -virtual void pure() = 0; int getV() const; int vol() volatile; diff --git a/core/org.eclipse.cdt.core/.settings/.api_filters b/core/org.eclipse.cdt.core/.settings/.api_filters new file mode 100644 index 00000000000..2aae30a0706 --- /dev/null +++ b/core/org.eclipse.cdt.core/.settings/.api_filters @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java index 48d6f7a138e..89b0f7b28dd 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java @@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier; +import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpressionList; import org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator; @@ -26,7 +27,7 @@ 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.IASTInitializer; -import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression; +import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; import org.eclipse.cdt.core.dom.ast.IASTInitializerList; import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression; import org.eclipse.cdt.core.dom.ast.IASTName; @@ -51,12 +52,12 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeId; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression; import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer; import org.eclipse.cdt.core.parser.Keywords; @@ -324,20 +325,20 @@ public class ASTStringUtil { } private static StringBuilder appendInitializerString(StringBuilder buffer, IASTInitializer initializer) { - if (initializer instanceof IASTInitializerExpression) { - final IASTInitializerExpression initializerExpression= (IASTInitializerExpression)initializer; + if (initializer instanceof IASTEqualsInitializer) { + final IASTEqualsInitializer initializerExpression= (IASTEqualsInitializer)initializer; buffer.append(Keywords.cpASSIGN); - appendExpressionString(buffer, initializerExpression.getExpression()); + appendInitClauseString(buffer, initializerExpression.getInitializerClause()); } else if (initializer instanceof IASTInitializerList) { final IASTInitializerList initializerList= (IASTInitializerList)initializer; - final IASTInitializer[] initializers= initializerList.getInitializers(); + final IASTInitializerClause[] initializers= initializerList.getClauses(); buffer.append(Keywords.cpASSIGN); buffer.append(Keywords.cpLBRACE); for (int i= 0; i < initializers.length; i++) { if (i > 0) { buffer.append(COMMA_SPACE); } - appendInitializerString(buffer, initializers[i]); + appendInitClauseString(buffer, initializers[i]); } trimRight(buffer); buffer.append(Keywords.cpRBRACE); @@ -347,9 +348,14 @@ public class ASTStringUtil { // final ICASTDesignator[] designator= designatedInitializer.getDesignators(); } else if (initializer instanceof ICPPASTConstructorInitializer) { final ICPPASTConstructorInitializer constructorInitializer= (ICPPASTConstructorInitializer)initializer; - final IASTExpression expression= constructorInitializer.getExpression(); + final IASTInitializerClause[] clauses= constructorInitializer.getArguments(); buffer.append(Keywords.cpLPAREN); - appendExpressionString(buffer, expression); + for (int i= 0; i < clauses.length; i++) { + if (i > 0) { + buffer.append(COMMA_SPACE); + } + appendInitClauseString(buffer, clauses[i]); + } trimRight(buffer); buffer.append(Keywords.cpRPAREN); } else if (initializer != null) { @@ -358,6 +364,14 @@ public class ASTStringUtil { return buffer; } + private static void appendInitClauseString(StringBuilder buffer, IASTInitializerClause initializerClause) { + if (initializerClause instanceof IASTExpression) { + appendExpressionString(buffer, (IASTExpression) initializerClause); + } else if (initializerClause instanceof IASTInitializer) { + appendInitializerString(buffer, (IASTInitializer) initializerClause); + } + } + private static StringBuilder appendTypeIdString(StringBuilder buffer, IASTTypeId typeId) { appendDeclSpecifierString(buffer, typeId.getDeclSpecifier()); appendDeclaratorString(buffer, typeId.getAbstractDeclarator(), false, null); @@ -681,14 +695,12 @@ public class ASTStringUtil { } appendExpressionString(buffer, expressions[i]); } - } else if (expression instanceof ICPPASTTypenameExpression) { - final ICPPASTTypenameExpression typenameExpression= (ICPPASTTypenameExpression)expression; - buffer.append(Keywords.TYPENAME).append(' '); - appendQualifiedNameString(buffer, typenameExpression.getName()); - final IASTExpression initialValue= typenameExpression.getInitialValue(); - if (initialValue != null) { - buffer.append(Keywords.cpASSIGN); - appendExpressionString(buffer, initialValue); + } else if (expression instanceof ICPPASTSimpleTypeConstructorExpression) { + final ICPPASTSimpleTypeConstructorExpression typeCast= (ICPPASTSimpleTypeConstructorExpression)expression; + appendDeclSpecifierString(buffer, typeCast.getDeclSpecifier()); + final IASTInitializer init= typeCast.getInitializer(); + if (init != null) { + appendInitializerString(buffer, init); } } else if (expression instanceof IASTLiteralExpression) { buffer.append(ASTSignatureUtil.getExpressionString(expression)); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java index 1ac28708624..fca79f0bb96 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java @@ -28,7 +28,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPackExpansionExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeIdExpression; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression; import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression; import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTTypeIdExpression; @@ -324,16 +323,12 @@ public class ASTSignatureUtil { public static String getInitializerString(IASTInitializer init) { StringBuffer result = new StringBuffer(); - if (init instanceof IASTInitializerExpression) { - result.append(getExpressionString(((IASTInitializerExpression) init).getExpression())); + if (init instanceof IASTEqualsInitializer) { + result.append(Keywords.cpASSIGN); + result.append(getInitializerClauseString(((IASTEqualsInitializer) init).getInitializerClause())); } else if (init instanceof IASTInitializerList) { result.append(Keywords.cpLBRACE); - IASTInitializer[] inits = ((IASTInitializerList) init).getInitializers(); - for (int i = 0; i < inits.length; i++) { - result.append(getInitializerString(inits[i])); - if (i < inits.length - 1) - result.append(COMMA_SPACE); - } + appendExpressionList(result, ((IASTInitializerList) init).getClauses()); result.append(Keywords.cpRBRACE); } else if (init instanceof ICASTDesignatedInitializer) { ICASTDesignator[] designators = ((ICASTDesignatedInitializer) init).getDesignators(); @@ -343,16 +338,34 @@ public class ASTSignatureUtil { result.append(COMMA_SPACE); } result.append(Keywords.cpASSIGN); - result.append(getInitializerString(((ICASTDesignatedInitializer) init).getOperandInitializer())); + result.append(getInitializerClauseString(((ICASTDesignatedInitializer) init).getOperand())); } else if (init instanceof ICPPASTConstructorInitializer) { result.append("("); //$NON-NLS-1$ - result.append(getExpressionString(((ICPPASTConstructorInitializer) init).getExpression())); + appendExpressionList(result, ((ICPPASTConstructorInitializer) init).getArguments()); result.append(")"); //$NON-NLS-1$ } return result.toString(); } + private static void appendExpressionList(StringBuffer result, IASTInitializerClause[] inits) { + for (int i = 0; i < inits.length; i++) { + result.append(getInitializerClauseString(inits[i])); + if (i < inits.length - 1) + result.append(COMMA_SPACE); + } + } + + private static String getInitializerClauseString(IASTInitializerClause initializerClause) { + if (initializerClause instanceof IASTExpression) { + return getExpressionString((IASTExpression) initializerClause); + } + if (initializerClause instanceof IASTInitializer) { + return getInitializerString((IASTInitializer) initializerClause); + } + return ""; //$NON-NLS-1$ + } + private static String getDesignatorSignature(ICASTDesignator designator) { StringBuffer result = new StringBuffer(); @@ -796,8 +809,6 @@ public class ASTSignatureUtil { return getNewExpression((ICPPASTNewExpression)expression); else if (expression instanceof ICPPASTSimpleTypeConstructorExpression) return getSimpleTypeConstructorExpression((ICPPASTSimpleTypeConstructorExpression)expression); - else if (expression instanceof ICPPASTTypenameExpression) - return getTypenameExpression((ICPPASTTypenameExpression)expression); else if (expression instanceof IGNUASTCompoundStatementExpression) return getCompoundStatementExpression((IGNUASTCompoundStatementExpression)expression); else if (expression instanceof ICPPASTPackExpansionExpression) @@ -856,7 +867,13 @@ public class ASTSignatureUtil { StringBuffer result = new StringBuffer(); result.append(getExpressionString(expression.getFunctionNameExpression())); result.append(Keywords.cpLPAREN); - result.append(getExpressionString(expression.getParameterExpression())); + IASTInitializerClause[] clauses = expression.getArguments(); + for (int i= 0; i < clauses.length; i++) { + if (i > 0) { + result.append(COMMA_SPACE); + } + result.append(getInitializerClauseString(clauses[i])); + } result.append(Keywords.cpRPAREN); return result.toString(); } @@ -881,58 +898,8 @@ public class ASTSignatureUtil { private static String getSimpleTypeConstructorExpression(ICPPASTSimpleTypeConstructorExpression expression) { StringBuffer result = new StringBuffer(); - switch (expression.getSimpleType()) { - case ICPPASTSimpleTypeConstructorExpression.t_bool: - result.append(Keywords.BOOL); - break; - case ICPPASTSimpleTypeConstructorExpression.t_char: - result.append(Keywords.CHAR); - break; - case ICPPASTSimpleTypeConstructorExpression.t_double: - result.append(Keywords.DOUBLE); - break; - case ICPPASTSimpleTypeConstructorExpression.t_float: - result.append(Keywords.FLOAT); - break; - case ICPPASTSimpleTypeConstructorExpression.t_int: - result.append(Keywords.INT); - break; - case ICPPASTSimpleTypeConstructorExpression.t_long: - result.append(Keywords.LONG); - break; - case ICPPASTSimpleTypeConstructorExpression.t_short: - result.append(Keywords.SHORT); - break; - case ICPPASTSimpleTypeConstructorExpression.t_signed: - result.append(Keywords.SIGNED); - break; - case ICPPASTSimpleTypeConstructorExpression.t_unsigned: - result.append(Keywords.UNSIGNED); - break; - case ICPPASTSimpleTypeConstructorExpression.t_void: - result.append(Keywords.VOID); - break; - case ICPPASTSimpleTypeConstructorExpression.t_wchar_t: - result.append(Keywords.WCHAR_T); - break; - } - result.append(Keywords.cpLPAREN); - result.append(expression.getInitialValue()); - result.append(Keywords.cpRPAREN); - return result.toString(); - } - - private static String getTypenameExpression(ICPPASTTypenameExpression expression) { - StringBuffer result = new StringBuffer(); - result.append(Keywords.TYPENAME); - result.append(SPACE); - result.append(expression.getName().toString()); - IASTExpression initValue = expression.getInitialValue(); - result.append(Keywords.cpLPAREN); - if (initValue != null) { - result.append(getExpressionString(initValue)); - } - result.append(Keywords.cpRPAREN); + result.append(getSignature(expression.getDeclSpecifier())); + result.append(getInitializerString(expression.getInitializer())); return result.toString(); } @@ -1004,13 +971,16 @@ public class ASTSignatureUtil { StringBuffer result = new StringBuffer(); result.append(Keywords.NEW); result.append(SPACE); - if (expression.getNewPlacement() != null) { - result.append(getExpressionString(expression.getNewPlacement())); + final IASTInitializerClause[] args = expression.getPlacementArguments(); + if (args != null) { + result.append("("); //$NON-NLS-1$ + appendExpressionList(result, args); + result.append(")"); //$NON-NLS-1$ } result.append(getSignature(expression.getTypeId())); - result.append(Keywords.cpLPAREN); - result.append(getExpressionString(expression.getNewInitializer())); - result.append(Keywords.cpRPAREN); + final IASTInitializer initializer = expression.getInitializer(); + if (initializer != null) + result.append(getInitializerString(initializer)); return result.toString(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTArraySubscriptExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTArraySubscriptExpression.java index f3efe3a618f..3e9580a921e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTArraySubscriptExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTArraySubscriptExpression.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -19,15 +19,18 @@ package org.eclipse.cdt.core.dom.ast; */ public interface IASTArraySubscriptExpression extends IASTExpression { - /** - * Node property that describes the relationship between an - * IASTArraySubscriptExpression and an - * IASTExpression representing the subscript. - */ - public static final ASTNodeProperty ARRAY = new ASTNodeProperty("IASTArraySubscriptExpression.ARRAY - IASTExpression representing the Array"); //$NON-NLS-1$ + public static final ASTNodeProperty ARRAY = new ASTNodeProperty( + "IASTArraySubscriptExpression.ARRAY [IASTExpression]"); //$NON-NLS-1$ + public static final ASTNodeProperty SUBSCRIPT = new ASTNodeProperty( + "IASTArraySubscriptExpression.SUBSCRIPT - [IASTFunctionArgument]"); //$NON-NLS-1$ /** - * Get the expression that represents the array. + * @since 5.1 + */ + IASTArraySubscriptExpression copy(); + + /** + * Get the expression that represents the array * * @return IASTExpression that represents the array. */ @@ -42,30 +45,24 @@ public interface IASTArraySubscriptExpression extends IASTExpression { public void setArrayExpression(IASTExpression expression); /** - * Node property that describes the relationship between an - * IASTArraySubscriptExpression and an - * IASTExpression representing the array. + * Returns the operand of this expression. In c++ the operand can be a braced initializer list. + * @since 5.2 */ - public static final ASTNodeProperty SUBSCRIPT = new ASTNodeProperty( - "IASTArraySubscriptExpression.SUBSCRIPT - IASTExpression representing the Subscript"); //$NON-NLS-1$ + public IASTInitializerClause getArgument(); /** - * Get the subscript expression. - * - * @return IASTExpression that represents the subscript. + * Not allowed on frozen ast. + * @since 5.2 + */ + public void setArgument(IASTInitializerClause expression); + + /** + * Returns the subscript expression, or null. Consider using {@link #getArgument()}. */ public IASTExpression getSubscriptExpression(); /** - * Set the subscript expression. - * - * @param expression - * IASTExpression to be set. + * Not allowed on frozen ast. */ public void setSubscriptExpression(IASTExpression expression); - - /** - * @since 5.1 - */ - public IASTArraySubscriptExpression copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java index 671c35c2e4c..8e30888c24a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * Doug Schaefer (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -254,6 +255,13 @@ public interface IASTBinaryExpression extends IASTExpression { */ public IASTExpression getOperand2(); + /** + * Returns the second operand of the expression. For c++ assignment expressions this can be + * a braced list initializer. + * @since 5.2 + */ + public IASTInitializerClause getInitOperand2(); + /** * @param expression * IASTExpression value diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializerExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTEqualsInitializer.java similarity index 51% rename from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializerExpression.java rename to core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTEqualsInitializer.java index 835cecee6eb..67cca433a4b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializerExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTEqualsInitializer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2010 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,17 +8,28 @@ * Contributors: * Markus Schorn - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.core.dom.ast.cpp; +package org.eclipse.cdt.core.dom.ast; -import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression; /** - * Initializer expression for c++. - * + * Initializer with equals sign (copy initialization) as in int x= 0;. + * @since 5.2 + * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. - * @since 5.2 */ -public interface ICPPASTInitializerExpression extends IASTInitializerExpression, ICPPASTInitializer { +public interface IASTEqualsInitializer extends IASTInitializer { + ASTNodeProperty INITIALIZER = new ASTNodeProperty( + "IASTEqualsInitializer - INITIALIZER [IASTInitializerClause]"); //$NON-NLS-1$ + + /** + * Returns the expression or braced initializer list of this initializer. + */ + IASTInitializerClause getInitializerClause(); + + /** + * Not allowed on frozen ast. + */ + void setInitializerClause(IASTInitializerClause clause); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTExpression.java index 973e23d65ef..ce7f1d0a09f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTExpression.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,7 +17,7 @@ package org.eclipse.cdt.core.dom.ast; * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ -public interface IASTExpression extends IASTNode { +public interface IASTExpression extends IASTInitializerClause { /** * Empty expression array. */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionCallExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionCallExpression.java index 62443d31847..46a07d33f85 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionCallExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionCallExpression.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * John Camelon (IBM Rational Software) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -19,55 +20,54 @@ package org.eclipse.cdt.core.dom.ast; */ public interface IASTFunctionCallExpression extends IASTExpression { - /** - * FUNCTION_NAME represents the relationship between a - * IASTFunctionCallExpression and its - * IASTExpression (function name). - */ public static final ASTNodeProperty FUNCTION_NAME = new ASTNodeProperty( - "IASTFunctionCallExpression.FUNCTION_Name - IASTExpression (name) for IASTFunctionCallExpression"); //$NON-NLS-1$ + "IASTFunctionCallExpression.FUNCTION_NAME [IASTExpression]"); //$NON-NLS-1$ /** - * Set the function name expression. - * - * @param expression - * IASTExpression representing the function name + * @since 5.2 */ - public void setFunctionNameExpression(IASTExpression expression); + public static final ASTNodeProperty ARGUMENT = new ASTNodeProperty( + "IASTFunctionCallExpression.ARGUMENT [IASTInitializerClause]"); //$NON-NLS-1$ /** * Get the function name expression. - * - * @return IASTExpression representing the function name */ public IASTExpression getFunctionNameExpression(); /** - * PARAMETERS represents the relationship between a - * IASTFunctionCallExpression and its - * IASTExpression (parameters). + * Returns the arguments for this function call, never null. + * @since 5.2 */ - public static final ASTNodeProperty PARAMETERS = new ASTNodeProperty( - "IASTFunctionCallExpression.PARAMETERS - IASTExpression (parameters) for IASTFunctionCallExpression"); //$NON-NLS-1$ + public IASTInitializerClause[] getArguments(); - /** - * Set the parameters expression. - * - * @param expression - * IASTExpression representing the parameters - */ - public void setParameterExpression(IASTExpression expression); - - /** - * Get the parameter expression. - * - * @return IASTExpression representing the parameters - */ - public IASTExpression getParameterExpression(); - /** * @since 5.1 */ public IASTFunctionCallExpression copy(); + /** + * Not allowed on frozen ast. + */ + public void setFunctionNameExpression(IASTExpression expression); + + /** + * Not allowed on frozen ast. + * @since 5.2 + */ + public void setArguments(IASTInitializerClause[] args); + + @Deprecated + public static final ASTNodeProperty PARAMETERS = ARGUMENT; + + /** + * @deprecated Replaced by {@link #setArguments(IASTInitializerClause[])}. + */ + @Deprecated + public void setParameterExpression(IASTExpression expression); + + /** + * @deprecated Replaced by {@link #getArguments()}. + */ + @Deprecated + public IASTExpression getParameterExpression(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTImplicitName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTImplicitName.java index 6751396d423..00e45778a40 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTImplicitName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTImplicitName.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 IBM Corporation and others. + * Copyright (c) 2009, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -18,6 +18,8 @@ package org.eclipse.cdt.core.dom.ast; * * @see ASTVisitor#shouldVisitImplicitNames * @since 5.1 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTImplicitName extends IASTName { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTImplicitNameOwner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTImplicitNameOwner.java index 21b3c3b9179..a7afbffea22 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTImplicitNameOwner.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTImplicitNameOwner.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 IBM Corporation and others. + * Copyright (c) 2009, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,6 +14,8 @@ package org.eclipse.cdt.core.dom.ast; /** * An implicit name generated on demand. * @since 5.1 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTImplicitNameOwner extends IASTNode { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerClause.java similarity index 70% rename from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializer.java rename to core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerClause.java index 46a11628cb8..37448482778 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerClause.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2010 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,15 +8,15 @@ * Contributors: * Markus Schorn - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.core.dom.ast.cpp; - -import org.eclipse.cdt.core.dom.ast.IASTInitializer; +package org.eclipse.cdt.core.dom.ast; /** - * Initializer for c++ - * + * Interface for ast nodes that can nest in initializer lists. + * @since 5.2 * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. - * @since 5.2 */ -public interface ICPPASTInitializer extends IASTInitializer, ICPPASTPackExpandable {} +public interface IASTInitializerClause extends IASTNode { + + IASTInitializerClause copy(); +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerExpression.java index 4d972dc1895..8e49f3a0071 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerExpression.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,15 +15,16 @@ package org.eclipse.cdt.core.dom.ast; * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. + * @deprecated Replaced by {@link IASTEqualsInitializer}. */ -public interface IASTInitializerExpression extends IASTInitializer { +@Deprecated +public interface IASTInitializerExpression extends IASTEqualsInitializer { /** * INITIALIZER_EXPRESSION represents the relationship between * an IASTInitializerExpression. and its IASTExpression. */ - public static final ASTNodeProperty INITIALIZER_EXPRESSION = new ASTNodeProperty( - "IASTInitializerExpression.INITIALIZER_EXPRESSION - IASTExpression for IASTInitializerExpression"); //$NON-NLS-1$ + public static final ASTNodeProperty INITIALIZER_EXPRESSION = INITIALIZER; /** * Get the expression for the initializer. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerList.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerList.java index 937ab4c8aab..b3a094e441b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerList.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerList.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,25 +7,21 @@ * * Contributors: * Doug Schaefer (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; /** - * This is an an initializer that is a list of initializers. - * For example as in: + * Braced initializer list, for example as in: *
 int a[]= {1,2,3}; 
* * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ -public interface IASTInitializerList extends IASTInitializer { +public interface IASTInitializerList extends IASTInitializer, IASTInitializerClause { - /** - * NESTED_INITIALIZER describes the relationship between an - * IASTInitializerList and its sub-IASTInitializers. - */ public static final ASTNodeProperty NESTED_INITIALIZER = new ASTNodeProperty( - "IASTInitializerList.NESTED_INITIALIZER - sub-IASTInitializer for IASTInitializerList"); //$NON-NLS-1$ + "IASTInitializerList.NESTED_INITIALIZER [IASTInitializerClause]"); //$NON-NLS-1$ /** * Returns the size of the initializer list, including trivial initializers. This size may @@ -37,18 +33,34 @@ public interface IASTInitializerList extends IASTInitializer { /** * Returns the list of initializers. Depending on how the ast was created, this may omit * trivial initializers in order to save memory. + * @since 5.2 */ - public IASTInitializer[] getInitializers(); - + public IASTInitializerClause[] getClauses(); + + /** - * Add an initializer to the initializer list. Depending on how the AST is created the + * Add an initializer clause to the initializer list. Depending on how the AST is created the * initializer may be null. A null initializer will not be returned * by {@link #getInitializers()}, however it contributes to the actual element count (#getSize()). + * @since 5.2 */ - public void addInitializer(IASTInitializer initializer); + public void addClause(IASTInitializerClause clause); /** * @since 5.1 */ public IASTInitializerList copy(); + + /** + * @deprecated Replaced by {@link #getClauses()}. + */ + @Deprecated + public IASTInitializer[] getInitializers(); + + /** + * @deprecated Replaced by {@link #addClause(IASTInitializerClause)}. + */ + @Deprecated + public void addInitializer(IASTInitializer initializer); + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTReturnStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTReturnStatement.java index 7c341d9f50e..c84bc91ede2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTReturnStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTReturnStatement.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * Doug Schaefer (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -16,13 +17,8 @@ package org.eclipse.cdt.core.dom.ast; */ public interface IASTReturnStatement extends IASTStatement { - /** - * RETURNVALUE represents the relationship between an - * IASTReturnStatement and it's nested - * IASTExpression. - */ public static final ASTNodeProperty RETURNVALUE = new ASTNodeProperty( - "IASTReturnValue.RETURNVALUE - IASTExpression (returnValue) for IASTReturnStatement"); //$NON-NLS-1$ + "IASTReturnValue.RETURNVALUE - [IASTInitializerClause]"); //$NON-NLS-1$ /** * This is the optional return value for this function. @@ -32,10 +28,20 @@ public interface IASTReturnStatement extends IASTStatement { public IASTExpression getReturnValue(); /** - * Set the return value. - * - * @param returnValue - * IASTExpression + * Returns the return value as {@link IASTInitializerClause}, or null. + * In c++ this can be an braced initializer list. + * @since 5.2 + */ + public IASTInitializerClause getReturnArgument(); + + /** + * Not allowed on frozen ast. + * @since 5.2 + */ + public void setReturnArgument(IASTInitializerClause returnValue); + + /** + * Not allowed on frozen ast. */ public void setReturnValue(IASTExpression returnValue); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/INodeFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/INodeFactory.java index 1d4de605026..50a4371c653 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/INodeFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/INodeFactory.java @@ -1,12 +1,13 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 IBM Corporation and others. + * Copyright (c) 2006, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Corporation - initial API and implementation + * Mike Kucera (IBM Corporation) - initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -15,7 +16,6 @@ import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression; import org.eclipse.cdt.core.parser.IScanner; import org.eclipse.cdt.core.parser.IToken; - /** * Factory for creating AST nodes. This interface contains factory methods * for nodes that are available for both C and C++. @@ -33,13 +33,102 @@ import org.eclipse.cdt.core.parser.IToken; * * None of the factory methods should return null. * - * @author Mike Kucera * @since 5.1 * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ public interface INodeFactory { + public IASTArrayDeclarator newArrayDeclarator(IASTName name); + + public IASTArrayModifier newArrayModifier(IASTExpression expr); + + public IASTArraySubscriptExpression newArraySubscriptExpression(IASTExpression arrayExpr, IASTExpression subscript); + + public IASTASMDeclaration newASMDeclaration(String assembly); + + public IASTBinaryExpression newBinaryExpression(int op, IASTExpression expr1, IASTExpression expr2); + + public IASTBreakStatement newBreakStatement(); + + public IASTCaseStatement newCaseStatement(IASTExpression expr); + + public IASTCastExpression newCastExpression(int operator, IASTTypeId typeId, IASTExpression operand); + + public IASTCompositeTypeSpecifier newCompositeTypeSpecifier(int key, IASTName name); + + public IASTCompoundStatement newCompoundStatement(); + + public IASTConditionalExpression newConditionalExpession(IASTExpression expr1, IASTExpression expr2, IASTExpression expr3); + + public IASTContinueStatement newContinueStatement(); + + public IASTDeclarationStatement newDeclarationStatement(IASTDeclaration declaration); + + public IASTDeclarator newDeclarator(IASTName name); + + public IASTDefaultStatement newDefaultStatement(); + + public IASTDoStatement newDoStatement(IASTStatement body, IASTExpression condition); + + public IASTElaboratedTypeSpecifier newElaboratedTypeSpecifier(int kind, IASTName name); + + public IASTEnumerationSpecifier newEnumerationSpecifier(IASTName name); + + public IASTEnumerator newEnumerator(IASTName name, IASTExpression value); + + /** + * @since 5.2 + */ + public IASTEqualsInitializer newEqualsInitializer(IASTInitializerClause initClause); + + public IASTExpressionList newExpressionList(); + + public IASTExpressionStatement newExpressionStatement(IASTExpression expression); + + public IASTFieldDeclarator newFieldDeclarator(IASTName name, IASTExpression bitFieldSize); + + public IASTFieldReference newFieldReference(IASTName name, IASTExpression owner); + + public IASTForStatement newForStatement(IASTStatement init, IASTExpression condition, + IASTExpression iterationExpression, IASTStatement body); + + /** + * @deprecated Replaced by {@link #newFunctionCallExpression(IASTExpression, IASTInitializerClause[])} + */ + @Deprecated + public IASTFunctionCallExpression newFunctionCallExpression(IASTExpression idExpr, IASTExpression argList); + + /** + * @since 5.2 + */ + public IASTFunctionCallExpression newFunctionCallExpression(IASTExpression idExpr, IASTInitializerClause[] arguments); + + public IASTStandardFunctionDeclarator newFunctionDeclarator(IASTName name); + + public IASTFunctionDefinition newFunctionDefinition(IASTDeclSpecifier declSpecifier, + IASTFunctionDeclarator declarator, IASTStatement bodyStatement); + + public IGNUASTCompoundStatementExpression newGNUCompoundStatementExpression(IASTCompoundStatement compoundStatement); + + public IASTGotoStatement newGotoStatement(IASTName name); + + public IASTIdExpression newIdExpression(IASTName name); + + public IASTIfStatement newIfStatement(IASTExpression condition, IASTStatement then, IASTStatement elseClause); + + /** + * @deprecated Replaced by {@link #newEqualsInitializer(IASTInitializerClause)}. + */ + @Deprecated + public IASTInitializerExpression newInitializerExpression(IASTExpression expression); + + public IASTInitializerList newInitializerList(); + + public IASTLabelStatement newLabelStatement(IASTName name, IASTStatement nestedStatement); + + public IASTLiteralExpression newLiteralExpression(int kind, String rep); + /** * Creates a "dummy" name using an empty char array. */ @@ -47,12 +136,34 @@ public interface INodeFactory { public IASTName newName(char[] name); + public IASTNullStatement newNullStatement(); + + public IASTParameterDeclaration newParameterDeclaration(IASTDeclSpecifier declSpec, IASTDeclarator declarator); + + public IASTPointer newPointer(); + + public IASTProblem newProblem(int id, char[] arg, boolean error); + + public IASTProblemDeclaration newProblemDeclaration(IASTProblem problem); + + public IASTProblemExpression newProblemExpression(IASTProblem problem); + + public IASTProblemStatement newProblemStatement(IASTProblem problem); + + public IASTReturnStatement newReturnStatement(IASTExpression retValue); + + public IASTSimpleDeclaration newSimpleDeclaration(IASTDeclSpecifier declSpecifier); + + public IASTSimpleDeclSpecifier newSimpleDeclSpecifier(); + + public IASTSwitchStatement newSwitchStatement(IASTExpression controller, IASTStatement body); + /** - * @deprecated use {@link #newTranslationUnit(IScanner)}, instead. + * @deprecated Replaced by {@link #newTranslationUnit(IScanner)}. */ @Deprecated public IASTTranslationUnit newTranslationUnit(); - + /** * Creates a new translation unit that cooperates with the given scanner in order * to track macro-expansions and location information. @@ -60,112 +171,40 @@ public interface INodeFactory { * @since 5.2 */ public IASTTranslationUnit newTranslationUnit(IScanner scanner); - - public IASTLiteralExpression newLiteralExpression(int kind, String rep); - - public IASTUnaryExpression newUnaryExpression(int operator, IASTExpression operand); - - public IASTIdExpression newIdExpression(IASTName name); - - public IASTArraySubscriptExpression newArraySubscriptExpression(IASTExpression arrayExpr, IASTExpression subscript); - - public IASTFunctionCallExpression newFunctionCallExpression(IASTExpression idExpr, IASTExpression argList); - - public IASTExpressionList newExpressionList(); - - public IASTCastExpression newCastExpression(int operator, IASTTypeId typeId, IASTExpression operand); - - public IASTBinaryExpression newBinaryExpression(int op, IASTExpression expr1, IASTExpression expr2); - - public IASTConditionalExpression newConditionalExpession(IASTExpression expr1, IASTExpression expr2, IASTExpression expr3); - - public IASTTypeIdInitializerExpression newTypeIdInitializerExpression(IASTTypeId typeId, IASTInitializer initializer); - - public IASTLabelStatement newLabelStatement(IASTName name, IASTStatement nestedStatement); - - public IASTCaseStatement newCaseStatement(IASTExpression expr); - - public IASTDefaultStatement newDefaultStatement(); - - public IASTExpressionStatement newExpressionStatement(IASTExpression expression); - - public IASTNullStatement newNullStatement(); - - public IASTCompoundStatement newCompoundStatement(); - - public IASTSwitchStatement newSwitchStatement(IASTExpression controller, IASTStatement body); - - public IASTIfStatement newIfStatement(IASTExpression condition, IASTStatement then, IASTStatement elseClause); - - public IASTWhileStatement newWhileStatement(IASTExpression condition, IASTStatement body); - - public IASTDoStatement newDoStatement(IASTStatement body, IASTExpression condition); - - public IASTForStatement newForStatement(IASTStatement init, IASTExpression condition, - IASTExpression iterationExpression, IASTStatement body); - - public IASTGotoStatement newGotoStatement(IASTName name); - - public IASTContinueStatement newContinueStatement(); - - public IASTBreakStatement newBreakStatement(); - - public IASTReturnStatement newReturnStatement(IASTExpression retValue); - - public IASTDeclarationStatement newDeclarationStatement(IASTDeclaration declaration); - - public IASTTypeIdExpression newTypeIdExpression(int operator, IASTTypeId typeId); - - public IASTTypeId newTypeId(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator); - - public IASTDeclarator newDeclarator(IASTName name); - - public IASTSimpleDeclaration newSimpleDeclaration(IASTDeclSpecifier declSpecifier); - - public IASTInitializerExpression newInitializerExpression(IASTExpression expression); - - public IASTInitializerList newInitializerList(); - - public IASTFunctionDefinition newFunctionDefinition(IASTDeclSpecifier declSpecifier, - IASTFunctionDeclarator declarator, IASTStatement bodyStatement); - - public IASTStandardFunctionDeclarator newFunctionDeclarator(IASTName name); - - public IASTASMDeclaration newASMDeclaration(String assembly); - - public IASTProblemDeclaration newProblemDeclaration(IASTProblem problem); - - public IASTProblemStatement newProblemStatement(IASTProblem problem); - - public IASTProblemExpression newProblemExpression(IASTProblem problem); - - public IASTProblem newProblem(int id, char[] arg, boolean error); - - public IASTEnumerationSpecifier newEnumerationSpecifier(IASTName name); - - public IASTEnumerator newEnumerator(IASTName name, IASTExpression value); - - public IASTElaboratedTypeSpecifier newElaboratedTypeSpecifier(int kind, IASTName name); - - public IASTArrayModifier newArrayModifier(IASTExpression expr); - - public IASTArrayDeclarator newArrayDeclarator(IASTName name); - - public IASTParameterDeclaration newParameterDeclaration(IASTDeclSpecifier declSpec, IASTDeclarator declarator); - - public IASTFieldDeclarator newFieldDeclarator(IASTName name, IASTExpression bitFieldSize); - - public IASTSimpleDeclSpecifier newSimpleDeclSpecifier(); - - public IGNUASTCompoundStatementExpression newGNUCompoundStatementExpression(IASTCompoundStatement compoundStatement); - - public IASTPointer newPointer(); - - public IASTFieldReference newFieldReference(IASTName name, IASTExpression owner); public IASTNamedTypeSpecifier newTypedefNameSpecifier(IASTName name); - public IASTCompositeTypeSpecifier newCompositeTypeSpecifier(int key, IASTName name); + public IASTTypeId newTypeId(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator); + + public IASTTypeIdExpression newTypeIdExpression(int operator, IASTTypeId typeId); + + public IASTTypeIdInitializerExpression newTypeIdInitializerExpression(IASTTypeId typeId, IASTInitializer initializer); + + public IASTUnaryExpression newUnaryExpression(int operator, IASTExpression operand); + + public IASTWhileStatement newWhileStatement(IASTExpression condition, IASTStatement body); + + /** + * Adjusts the end-offset of a node to be the same as the end-offset of a given node. + * May throw an exception when either one of the nodes provided was not created by this factory. + * @param node a node created by this factory + * @param endNode a node created by this factory defining the end for the other node. + * @since 5.2 + */ + void setEndOffset(IASTNode node, IASTNode endNode); + + /** + * Provides the end offset for a node. The offset is an artificial numbers that identifies the + * position of a node in the translation unit. It is not a file-offset. You can obtain a + * valid offset via {@link IToken#getEndOffset()} from a token provided by the scanner for + * this translation unit. + * May throw an exception when the node provided was not created by this factory. + * @param node a node created by this factory + * @param endOffset the end offset (exclusive) for the node + * @see #newTranslationUnit(IScanner) + * @since 5.2 + */ + void setEndOffset(IASTNode node, int endOffset); /** * Provides the offsets for a node. The offsets are artificial numbers that identify the @@ -180,26 +219,4 @@ public interface INodeFactory { * @since 5.2 */ public void setOffsets(IASTNode node, int offset, int endOffset); - - /** - * Provides the end offset for a node. The offset is an artificial numbers that identifies the - * position of a node in the translation unit. It is not a file-offset. You can obtain a - * valid offset via {@link IToken#getEndOffset()} from a token provided by the scanner for - * this translation unit. - * May throw an exception when the node provided was not created by this factory. - * @param node a node created by this factory - * @param endOffset the end offset (exclusive) for the node - * @see #newTranslationUnit(IScanner) - * @since 5.2 - */ - void setEndOffset(IASTNode node, int endOffset); - - /** - * Adjusts the end-offset of a node to be the same as the end-offset of a given node. - * May throw an exception when either one of the nodes provided was not created by this factory. - * @param node a node created by this factory - * @param endNode a node created by this factory defining the end for the other node. - * @since 5.2 - */ - void setEndOffset(IASTNode node, IASTNode endNode); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDesignatedInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDesignatedInitializer.java index cae27e5e523..cbdb4256f24 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDesignatedInitializer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDesignatedInitializer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,11 +7,13 @@ * * Contributors: * John Camelon (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.c; import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; import org.eclipse.cdt.core.dom.ast.IASTInitializer; +import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; /** * This interface represents a designated initializer. e.g. struct x y = { .z=4, @@ -20,61 +22,53 @@ import org.eclipse.cdt.core.dom.ast.IASTInitializer; * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ -public interface ICASTDesignatedInitializer extends IASTInitializer { +public interface ICASTDesignatedInitializer extends IASTInitializer, IASTInitializerClause { - /** - * Constant. - */ public static final ICASTDesignator[] EMPTY_DESIGNATOR_ARRAY = new ICASTDesignator[0]; - /** - * DESIGNATOR represents the relationship between an - * ICASTDesignatedInitializer and - * ICASTDesignator. - */ public static final ASTNodeProperty DESIGNATOR = new ASTNodeProperty( - "ICASTDesignatedInitializer.DESIGNATOR - relationship between ICASTDesignatedInitializer and ICASTDesignator"); //$NON-NLS-1$ + "ICASTDesignatedInitializer.DESIGNATOR [ICASTDesignator]"); //$NON-NLS-1$ + + public static final ASTNodeProperty OPERAND = new ASTNodeProperty( + "ICASTDesignatedInitializer.OPERAND - [IASTInitializerClause]"); //$NON-NLS-1$ /** * Add a designator to this initializer. - * - * @param designator - * ICASTDesignator */ public void addDesignator(ICASTDesignator designator); /** * Get all of the designators. - * - * @return ICASTDesignator [] */ public ICASTDesignator[] getDesignators(); /** - * OPERAND represents the relationship between - * ICASTDesignatedInitializer and its - * IASTInitializer. + * Returns the operand initializer. + * @since 5.2 */ - public static final ASTNodeProperty OPERAND = new ASTNodeProperty( - "ICASTDesignatedInitializer.OPERAND - RHS IASTInitializer for ICASTDesignatedInitializer"); //$NON-NLS-1$ + public IASTInitializerClause getOperand(); /** - * Get the nested initializer. - * - * @return IASTInitializer + * Not allowed on frozen ast + * @since 5.2 */ - public IASTInitializer getOperandInitializer(); + void setOperand(IASTInitializerClause operand); - /** - * Set the nested initializer. - * - * @param rhs - * IASTInitializer - */ - public void setOperandInitializer(IASTInitializer rhs); - /** * @since 5.1 */ public ICASTDesignatedInitializer copy(); + + /** + * @deprecated Replaced by {@link #getOperand()}; + */ + @Deprecated + public IASTInitializer getOperandInitializer(); + + /** + * @deprecated Replaced by setOperand(); + */ + @Deprecated + public void setOperandInitializer(IASTInitializer rhs); + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICNodeFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICNodeFactory.java index 7886253a5a1..da6e5c4ce89 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICNodeFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICNodeFactory.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast.c; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTInitializer; +import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTTypeId; import org.eclipse.cdt.core.dom.ast.INodeFactory; @@ -30,35 +31,44 @@ import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator; */ public interface ICNodeFactory extends INodeFactory { - public ICASTEnumerationSpecifier newEnumerationSpecifier(IASTName name); - - public ICASTElaboratedTypeSpecifier newElaboratedTypeSpecifier(int kind, IASTName name); - - public ICASTSimpleDeclSpecifier newSimpleDeclSpecifier(); - - public ICASTPointer newPointer(); - - public ICASTTypedefNameSpecifier newTypedefNameSpecifier(IASTName name); - - public ICASTCompositeTypeSpecifier newCompositeTypeSpecifier(int key, IASTName name); + public ICASTArrayDesignator newArrayDesignator(IASTExpression exp); public ICASTArrayModifier newArrayModifier(IASTExpression expr); - public ICASTTypeIdInitializerExpression newTypeIdInitializerExpression(IASTTypeId typeId, IASTInitializer initializer); - - public ICASTKnRFunctionDeclarator newKnRFunctionDeclarator(IASTName[] parameterNames, IASTDeclaration[] parameterDeclarations); - + public IGCCASTArrayRangeDesignator newArrayRangeDesignatorGCC(IASTExpression floor, IASTExpression ceiling); + + public ICASTCompositeTypeSpecifier newCompositeTypeSpecifier(int key, IASTName name); + + /** + * @deprecated Replaced by {@link #newDesignatedInitializer(IASTInitializerClause)}. + */ + @Deprecated public ICASTDesignatedInitializer newDesignatedInitializer(IASTInitializer rhs); - public ICASTArrayDesignator newArrayDesignator(IASTExpression exp); + /** + * @since 5.2 + */ + public ICASTDesignatedInitializer newDesignatedInitializer(IASTInitializerClause initializer); + + public ICASTElaboratedTypeSpecifier newElaboratedTypeSpecifier(int kind, IASTName name); + + public ICASTEnumerationSpecifier newEnumerationSpecifier(IASTName name); public ICASTFieldDesignator newFieldDesignator(IASTName name); - public IGCCASTArrayRangeDesignator newArrayRangeDesignatorGCC(IASTExpression floor, IASTExpression ceiling); + public ICASTKnRFunctionDeclarator newKnRFunctionDeclarator(IASTName[] parameterNames, IASTDeclaration[] parameterDeclarations); + + public ICASTPointer newPointer(); + + public ICASTSimpleDeclSpecifier newSimpleDeclSpecifier(); /** * @deprecated Replaced by {@link #newSimpleDeclSpecifier()} */ @Deprecated - public org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier newSimpleDeclSpecifierGCC(IASTExpression typeofExpression); + public org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier newSimpleDeclSpecifierGCC(IASTExpression typeofExpression); + + public ICASTTypedefNameSpecifier newTypedefNameSpecifier(IASTName name); + + public ICASTTypeIdInitializerExpression newTypeIdInitializerExpression(IASTTypeId typeId, IASTInitializer initializer); } \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTArraySubscriptExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTArraySubscriptExpression.java index cfeb6342564..8111a899a9a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTArraySubscriptExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTArraySubscriptExpression.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 IBM Corporation and others. + * Copyright (c) 2009, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,6 +15,9 @@ import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner; /** * @since 5.1 + * + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTArraySubscriptExpression extends IASTArraySubscriptExpression, IASTImplicitNameOwner { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorChainInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorChainInitializer.java index 1ee336218c3..9928c292003 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorChainInitializer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorChainInitializer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -13,70 +13,67 @@ package org.eclipse.cdt.core.dom.ast.cpp; import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; import org.eclipse.cdt.core.dom.ast.IASTExpression; +import org.eclipse.cdt.core.dom.ast.IASTInitializer; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNameOwner; /** + * Represents a member initializer: *
 class X {
  *     int a;
  *     X();
  * };
- * X::X : a(0) {}  // a(0) is a constructor chain initializer.
+ * X::X : a(0) {}  // a(0) is a member initializer.
  * 
  * @noextend This interface is not intended to be extended by clients.
  * @noimplement This interface is not intended to be implemented by clients.
  */
-public interface ICPPASTConstructorChainInitializer extends ICPPASTInitializer, IASTNameOwner {
-	/**
-	 * Constant.
-	 */
+public interface ICPPASTConstructorChainInitializer extends IASTInitializer, ICPPASTPackExpandable,
+		IASTNameOwner {
 	public static final ICPPASTConstructorChainInitializer[] EMPTY_CONSTRUCTORCHAININITIALIZER_ARRAY = new ICPPASTConstructorChainInitializer[0];
 
-	/**
-	 * MEMBER_ID represents the class field name being
-	 * initialized.
-	 */
 	public static final ASTNodeProperty MEMBER_ID = new ASTNodeProperty(
-			"ICPPASTConstructorChainInitializer.MEMBER_ID - Class field name initialized"); //$NON-NLS-1$
+			"ICPPASTConstructorChainInitializer.MEMBER_ID [IASTName]"); //$NON-NLS-1$
+
+	public static final ASTNodeProperty INITIALIZER = new ASTNodeProperty(
+			"ICPPASTConstructorChainInitializer.INITIALIZER [IASTInitializer]"); //$NON-NLS-1$
 
 	/**
-	 * Get the field name.
-	 * 
-	 * @return IASTName
+	 * Returns the name of the member.
 	 */
 	public IASTName getMemberInitializerId();
 
 	/**
-	 * Set the field name.
-	 * 
-	 * @param name
-	 *            IASTName
+	 * Returns the initializer for the member
+	 * @since 5.2
 	 */
-	public void setMemberInitializerId(IASTName name);
-
-	/**
-	 * Expression field is being initialized to.
-	 */
-	public static final ASTNodeProperty INITIALIZER = new ASTNodeProperty(
-			"ICPPASTConstructorChainInitializer.INITIALIZER - Expression Field Initializer"); //$NON-NLS-1$
-
-	/**
-	 * Get the initializer value.
-	 * 
-	 * @return IASTExpression
-	 */
-	public IASTExpression getInitializerValue();
-
-	/**
-	 * Set the initializer value.
-	 * 
-	 * @param expression
-	 *            IASTExpression
-	 */
-	public void setInitializerValue(IASTExpression expression);
+	public IASTInitializer getInitializer();
 
 	/**
 	 * @since 5.1
 	 */
 	public ICPPASTConstructorChainInitializer copy();
+
+	/**
+	 * Not allowed on frozen ast.
+	 */
+	public void setMemberInitializerId(IASTName name);
+
+	/**
+	 * Not allowed on frozen ast.
+	 * @since 5.2
+	 */
+	public void setInitializer(IASTInitializer initializer);
+	
+	/**
+	 * @deprecated Replaced by {@link #getInitializer()}.
+	 */
+	@Deprecated
+	public IASTExpression getInitializerValue();
+
+	/**
+	 * @deprecated Replaced by {@link #setInitializer(IASTInitializer)}.
+	 */
+	@Deprecated
+	public void setInitializerValue(IASTExpression expression);
 }
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorInitializer.java
index eab636f08e2..7b63a37fc2b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorInitializer.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorInitializer.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -13,38 +13,56 @@ package org.eclipse.cdt.core.dom.ast.cpp;
 
 import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
 import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
+import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
 
 /**
- * This is an initializer that is a call to the constructor for the declarator.
+ * Represents a potentially empty list of initializers in parenthesis: ( initializer-list? )
  * 
  * @noextend This interface is not intended to be extended by clients.
  * @noimplement This interface is not intended to be implemented by clients.
  */
-public interface ICPPASTConstructorInitializer extends ICPPASTInitializer {
+public interface ICPPASTConstructorInitializer extends IASTInitializer {
 
 	/**
-	 * EXPRESSION represents the expression being conusmed in a
-	 * constructor.
+	 * @since 5.2
 	 */
-	public static final ASTNodeProperty EXPRESSION = new ASTNodeProperty(
-			"ICPPASTConstructorInitializer.EXPRESSION - Expression consumed in constructor"); //$NON-NLS-1$
+	public static final ASTNodeProperty ARGUMENT = new ASTNodeProperty(
+			"ICPPASTConstructorInitializer.ARGUMENT - [IASTInitializerClause]"); //$NON-NLS-1$
 
 	/**
-	 * Get the arguments to the constructor.
+	 * Returns the arguments of this initializer, never null.
+	 * An argument can be of type {@link IASTInitializerList}.
 	 * 
-	 * @return IASTExpression
+	 * @since 5.2
 	 */
-	public IASTExpression getExpression();
-
-	/**
-	 * Set the arguments to the constructor.
-	 * 
-	 * @param expression
-	 */
-	public void setExpression(IASTExpression expression);
-
+	public IASTInitializerClause[] getArguments();
+	
 	/**
 	 * @since 5.1
 	 */
 	public ICPPASTConstructorInitializer copy();
+
+
+	/**
+	 * Not allowed on frozen ast.
+	 * @since 5.2
+	 */
+	public void setArguments(IASTInitializerClause[] args);
+
+	/**
+	 * @deprecated Replaced by {@link #getArguments()}.
+	 */
+	@Deprecated
+	public IASTExpression getExpression();
+
+	/**
+	 * @deprecated Replaced by {@link #setArguments(IASTInitializerClause[])}.
+	 */
+	@Deprecated
+	public void setExpression(IASTExpression expression);
+	
+	@Deprecated
+	public static final ASTNodeProperty EXPRESSION = ARGUMENT;
 }
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTExpressionList.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTExpressionList.java
index 15e900eaf23..7e40a64f1f1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTExpressionList.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTExpressionList.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
+ * Copyright (c) 2009, 2010 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -15,6 +15,9 @@ import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner;
 
 /**
  * @since 5.1
+ * 
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
  */
 public interface ICPPASTExpressionList extends IASTExpressionList, IASTImplicitNameOwner {
 
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionCallExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionCallExpression.java
index 8c8e91facea..065b5661927 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionCallExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionCallExpression.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
+ * Copyright (c) 2009, 2010 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -15,6 +15,9 @@ import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner;
 
 /**
  * @since 5.1
+ * 
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
  */
 public interface ICPPASTFunctionCallExpression extends IASTFunctionCallExpression, IASTImplicitNameOwner {
 
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializerList.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializerList.java
index 594659eeb94..487cffbc224 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializerList.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializerList.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009 Wind River Systems, Inc. and others.
+ * Copyright (c) 2009, 2010 Wind River Systems, Inc. and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -13,12 +13,13 @@ package org.eclipse.cdt.core.dom.ast.cpp;
 import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
 
 /**
- * Initializer expression for c++.
+ * Braced initializer list. 
  *
+ * @since 5.2
  * @noextend This interface is not intended to be extended by clients.
  * @noimplement This interface is not intended to be implemented by clients.
- * @since 5.2
  */
-public interface ICPPASTInitializerList extends IASTInitializerList, ICPPASTInitializer {
+public interface ICPPASTInitializerList extends IASTInitializerList, ICPPASTPackExpandable {
 
+	ICPPASTInitializerList copy();
 }
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNewExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNewExpression.java
index 85780652f53..ff165ab158b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNewExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNewExpression.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -14,8 +14,10 @@ package org.eclipse.cdt.core.dom.ast.cpp;
 
 import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
 import org.eclipse.cdt.core.dom.ast.IASTExpression;
-import org.eclipse.cdt.core.dom.ast.IASTTypeId;
 import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner;
+import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
+import org.eclipse.cdt.core.dom.ast.IASTTypeId;
 
 /**
  * This interface represents a new expression.
@@ -25,79 +27,38 @@ import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner;
  */
 public interface ICPPASTNewExpression extends IASTExpression, IASTImplicitNameOwner {
 
+	public static final ASTNodeProperty NEW_PLACEMENT = new ASTNodeProperty(
+			"ICPPASTNewExpression.NEW_PLACEMENT [IASTExpression]"); //$NON-NLS-1$
+
+	public static final ASTNodeProperty TYPE_ID = new ASTNodeProperty(
+			"ICPPASTNewExpression.TYPE_ID - [IASTTypeId]"); //$NON-NLS-1$
+
+	public static final ASTNodeProperty NEW_INITIALIZER = new ASTNodeProperty(
+		"ICPPASTNewExpression.NEW_INITIALIZER - [IASTInitializer]"); //$NON-NLS-1$
+
 	/**
 	 * Is this a ::new expression?
-	 * 
-	 * @return boolean
 	 */
 	public boolean isGlobal();
 
 	/**
-	 * Set this expression to bea global ::new expression (or not).
-	 * 
-	 * @param value
-	 *            boolean
+	 * Returns true if this expression is allocating an array.
+	 * @since 5.1
 	 */
-	public void setIsGlobal(boolean value);
+	public boolean isArrayAllocation();
 
 	/**
-	 * NEW_PLACEMENT is a role for an expression to represent the location of
-	 * where the memory should be allocated.
+	 * Returns the additional arguments for the new placement, or null.
+	 * A placement argument can be of type {@link ICPPASTInitializerList}.
+	 * @since 5.2
 	 */
-	public static final ASTNodeProperty NEW_PLACEMENT = new ASTNodeProperty(
-			"ICPPASTNewExpression.NEW_PLACEMENT - Location where memory should be allocated"); //$NON-NLS-1$
-
-	/**
-	 * Get the new placement (optional).
-	 * 
-	 * @return IASTExpression
-	 */
-	public IASTExpression getNewPlacement();
-
-	/**
-	 * Set the new placement expression.
-	 * 
-	 * @param expression
-	 *            IASTExpression
-	 */
-	public void setNewPlacement(IASTExpression expression);
-
-	/**
-	 * NEW_INITIALIZER
-	 */
-	public static final ASTNodeProperty NEW_INITIALIZER = new ASTNodeProperty(
-			"ICPPASTNewExpression.NEW_INITIALIZER - New Initializer"); //$NON-NLS-1$
-
-	/**
-	 * @return IASTExpression
-	 */
-	public IASTExpression getNewInitializer();
-
-	/**
-	 * @param expression
-	 *            IASTExpression
-	 */
-	public void setNewInitializer(IASTExpression expression);
-
-	/**
-	 * TYPE_ID is the type being 'newed'.
-	 */
-	public static final ASTNodeProperty TYPE_ID = new ASTNodeProperty("ICPPASTNewExpression.TYPE_ID - The type being 'newed'"); //$NON-NLS-1$
-
+	public IASTInitializerClause[] getPlacementArguments();
+	
 	/**
 	 * Get the type Id. The type-id includes the optional array modifications.
-	 * @return IASTTypeId
 	 */
 	public IASTTypeId getTypeId();
 
-	/**
-	 * Set the type Id.
-	 * 
-	 * @param typeId
-	 *            IASTTypeId
-	 */
-	public void setTypeId(IASTTypeId typeId);
-
 	/**
 	 * Returns whether the the typeID a new type ID, which is the case when
 	 * the type-id is provided without parenthesis.
@@ -105,24 +66,49 @@ public interface ICPPASTNewExpression extends IASTExpression, IASTImplicitNameOw
 	public boolean isNewTypeId();
 
 	/**
-	 * Set the type ID to be a new type ID.
-	 * 
-	 * @param value
-	 *            boolean
+	 * Returns the initializer or null.
+	 * @since 5.2
 	 */
-	public void setIsNewTypeId(boolean value);
+	public IASTInitializer getInitializer();
+
+	/**
+	 * @since 5.1
+	 */
+	public ICPPASTNewExpression copy();
 
 	
 	/**
-	 * Returns true if this expression is allocating an array.
-	 * @since 5.1
+	 * Not allowed on frozen ast.
 	 */
-	public boolean isArrayAllocation();
-	
-	
+	public void setIsGlobal(boolean value);
+
 	/**
-	 * Expressions that go inside array brackets.
+	 * Not allowed on frozen ast.
+	 * @since 5.2
 	 */
+	public void setPlacementArguments(IASTInitializerClause[] expression);
+
+	/**
+	 * Not allowed on frozen ast.
+	 */
+	public void setTypeId(IASTTypeId typeId);
+
+	/**
+	 * Not allowed on frozen ast.
+	 */
+	public void setIsNewTypeId(boolean value);
+
+	/**
+	 * Not allowed on frozen ast.
+	 * @since 5.2
+	 */
+	public void setInitializer(IASTInitializer init);
+
+
+	/**
+	 * @deprecated the id-expressions are part of the type-id.
+	 */
+	@Deprecated
 	public static final ASTNodeProperty NEW_TYPEID_ARRAY_EXPRESSION = new ASTNodeProperty(
 			"ICPPASTNewExpression.NEW_TYPEID_ARRAY_EXPRESSION - Expressions inside array brackets"); //$NON-NLS-1$
 
@@ -138,10 +124,27 @@ public interface ICPPASTNewExpression extends IASTExpression, IASTImplicitNameOw
 	@Deprecated
 	public void addNewTypeIdArrayExpression(IASTExpression expression);
 	
+	/**
+	 * @deprecated Replaced by {@link #getPlacementArguments()}
+	 */
+	@Deprecated
+	public IASTExpression getNewPlacement();
 	
 	/**
-	 * @since 5.1
+	 * @deprecated Replaced by {@link #setPlacementArguments(IASTInitializerClause[])}
 	 */
-	public ICPPASTNewExpression copy();
+	@Deprecated
+	public void setNewPlacement(IASTExpression expression);
 
+	/**
+	 * @deprecated Replaced by {@link #getInitializer()}
+	 */
+	@Deprecated
+	public IASTExpression getNewInitializer();
+
+	/**
+	 * @deprecated Replaced by {@link #setInitializer(IASTInitializer)}
+	 */
+	@Deprecated
+	public void setNewInitializer(IASTExpression expression);
 }
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleTypeConstructorExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleTypeConstructorExpression.java
index 889fb3b5a3b..9d1c2cdc59a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleTypeConstructorExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleTypeConstructorExpression.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -7,123 +7,108 @@
  *
  * Contributors:
  *    John Camelon (IBM) - Initial API and implementation
+ *    Markus Schorn (Wind River Systems)
  *******************************************************************************/
 package org.eclipse.cdt.core.dom.ast.cpp;
 
 import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
 import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializer;
 
 /**
- * Simple type constructor postfix expression.
- * 
+ * Functional cast expressions:
+ *   simple-type-specifier (expression-list?)
+ *   simple-type-specifier braced-init-list
+ *   typename-specifier (expression-list?)
+ *   typename-specifier braced-init-list
+ *   
  * @noextend This interface is not intended to be extended by clients.
  * @noimplement This interface is not intended to be implemented by clients.
  */
 public interface ICPPASTSimpleTypeConstructorExpression extends IASTExpression {
+	/**
+	 * @since 5.2
+	 */
+	public static final ASTNodeProperty TYPE_SPECIFIER = new ASTNodeProperty(
+			"ICPPASTSimpleTypeConstructorExpression.TYPE_SPECIFIER [ICPPASTSimpleDeclSpecifier]"); //$NON-NLS-1$
+	/**
+	 * @since 5.2
+	 */
+	public static final ASTNodeProperty INITIALIZER = new ASTNodeProperty(
+			"ICPPASTSimpleTypeConstructorExpression.INITIALIZER [IASTInitializer]"); //$NON-NLS-1$
 
 	/**
-	 * t_unspecified (error)
+	 * Returns the declaration specifier that specifies the type.
+	 * @since 5.2
 	 */
-	public static final int t_unspecified = 0;
+	public ICPPASTDeclSpecifier getDeclSpecifier();
 
 	/**
-	 * t_void == void
+	 * Returns the argument for initialization. Can be {@link ICPPASTConstructorInitializer} or
+	 * {@link ICPPASTInitializerList}
+	 * @since 5.2
 	 */
-	public static final int t_void = 1;
-
-	/**
-	 * t_char == char
-	 */
-	public static final int t_char = 2;
-
-	/**
-	 * t_int == int
-	 */
-	public static final int t_int = 3;
-
-	/**
-	 * t_float == float
-	 */
-	public static final int t_float = 4;
-
-	/**
-	 * t_double == double
-	 */
-	public static final int t_double = 5;
-
-	/**
-	 * t_bool = bool
-	 */
-	public static final int t_bool = 6;
-
-	/**
-	 * t_wchar_t = wchar_t
-	 */
-	public static final int t_wchar_t = 7;
-
-	/**
-	 * t_short = short
-	 */
-	public static final int t_short = 8;
-
-	/**
-	 * t_long = long
-	 */
-	public static final int t_long = 9;
-
-	/**
-	 * t_signed = signed
-	 */
-	public static final int t_signed = 10;
-
-	/**
-	 * t_unsigned = unsigned
-	 */
-	public static final int t_unsigned = 11;
-
-	/**
-	 * t_last is provided for subinterfaces.
-	 */
-	public static final int t_last = t_unsigned;
-
-	/**
-	 * Get the simple type.
-	 * 
-	 * @return int
-	 */
-	public int getSimpleType();
-
-	/**
-	 * Set the simple type.
-	 * 
-	 * @param value
-	 *            int
-	 */
-	public void setSimpleType(int value);
-
-	/**
-	 * INITIALIZER_VALUE is the value passed into the constructor.
-	 */
-	public static final ASTNodeProperty INITIALIZER_VALUE = new ASTNodeProperty(
-			"ICPPASTSimpleTypeConstructorExpression.INITIALIZER_VALUE - Value passed into constructor"); //$NON-NLS-1$
-
-	/**
-	 * Get the initial value.
-	 * 
-	 * @return IASTExpression
-	 */
-	public IASTExpression getInitialValue();
-
-	/**
-	 * Set the initial value.
-	 * 
-	 * @param expression
-	 *            IASTExpression
-	 */
-	public void setInitialValue(IASTExpression expression);
-
+	public IASTInitializer getInitializer();
+	
 	/**
 	 * @since 5.1
 	 */
 	public ICPPASTSimpleTypeConstructorExpression copy();
+
+	/**
+	 * Not allowed on frozen ast.
+	 * @since 5.2
+	 */
+	public void setDeclSpecifier(ICPPASTDeclSpecifier declSpec);
+
+	/**
+	 * Not allowed on frozen ast.
+	 * @since 5.2
+	 */
+	public void setInitializer(IASTInitializer initializer);
+	
+	
+	@Deprecated	public static final int t_unspecified = 0;
+	@Deprecated public static final int t_void = 1;
+	@Deprecated public static final int t_char = 2;
+	@Deprecated public static final int t_int = 3;
+	@Deprecated public static final int t_float = 4;
+	@Deprecated public static final int t_double = 5;
+	@Deprecated public static final int t_bool = 6;
+	@Deprecated public static final int t_wchar_t = 7;
+	@Deprecated public static final int t_short = 8;
+	@Deprecated public static final int t_long = 9;
+	@Deprecated public static final int t_signed = 10;
+	@Deprecated public static final int t_unsigned = 11;
+	@Deprecated public static final int t_last = t_unsigned;
+
+	/**
+	 * @deprecated Replaced by {@link #getDeclSpecifier()}.
+	 */
+	@Deprecated
+	public int getSimpleType();
+
+	/**
+	 * @deprecated Replaced by {@link #setDeclSpecifier(ICPPASTDeclSpecifier)}
+	 */
+	@Deprecated
+	public void setSimpleType(int value);
+
+	/**
+	 * @deprecated Replaced by {@link #INITIALIZER}.
+	 */
+	@Deprecated
+	public static final ASTNodeProperty INITIALIZER_VALUE = INITIALIZER;
+
+	/**
+	 * @deprecated Replaced by {@link #getInitializer()}
+	 */
+	@Deprecated
+	public IASTExpression getInitialValue();
+
+	/**
+	 * @deprecated Replaced by {@link #setInitializer(IASTInitializer)}
+	 */
+	@Deprecated
+	public void setInitialValue(IASTExpression expression);
 }
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTypenameExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTypenameExpression.java
index 2beb51c289e..2123f9ab9be 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTypenameExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTypenameExpression.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
  *
  * Contributors:
  *    John Camelon (IBM) - Initial API and implementation
+ *    Markus Schorn (Wind River Systems)
  *******************************************************************************/
 package org.eclipse.cdt.core.dom.ast.cpp;
 
@@ -18,8 +19,10 @@ import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
 /**
  * @noextend This interface is not intended to be extended by clients.
  * @noimplement This interface is not intended to be implemented by clients.
+ * @deprecated Unified with {@link ICPPASTSimpleTypeConstructorExpression}.
  */
-public interface ICPPASTTypenameExpression extends IASTExpression, IASTNameOwner {
+@Deprecated
+public interface ICPPASTTypenameExpression extends ICPPASTSimpleTypeConstructorExpression, IASTNameOwner {
 
 	/**
 	 * Was template token consumed?
@@ -60,8 +63,7 @@ public interface ICPPASTTypenameExpression extends IASTExpression, IASTNameOwner
 	/**
 	 * INITIAL_VALUE is an expression.
 	 */
-	public static final ASTNodeProperty INITIAL_VALUE = new ASTNodeProperty(
-			"ICPPASTTypenameExpression.INITIAL_VALUE - Initial Value is an expression"); //$NON-NLS-1$
+	public static final ASTNodeProperty INITIAL_VALUE = INITIALIZER;
 
 	/**
 	 * Set initial value.
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java
index e8408356aba..a69eb686ad7 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java
@@ -16,9 +16,12 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
 import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
 import org.eclipse.cdt.core.dom.ast.IASTExpression;
 import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
 import org.eclipse.cdt.core.dom.ast.IASTName;
 import org.eclipse.cdt.core.dom.ast.IASTProblem;
 import org.eclipse.cdt.core.dom.ast.IASTProblemTypeId;
+import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
 import org.eclipse.cdt.core.dom.ast.IASTStatement;
 import org.eclipse.cdt.core.dom.ast.IASTTypeId;
 import org.eclipse.cdt.core.dom.ast.INodeFactory;
@@ -37,188 +40,177 @@ import org.eclipse.cdt.core.parser.IScanner;
 public interface ICPPNodeFactory extends INodeFactory {
 	
 	/**
-	 * Creates a new translation unit that cooperates with the given scanner in order
-	 * to track macro-expansions and location information.
-	 * @scanner the preprocessor the translation unit interacts with.
 	 * @since 5.2
 	 */
-	public ICPPASTTranslationUnit newTranslationUnit(IScanner scanner);
+	public ICPPASTArrayDeclarator newArrayDeclarator(IASTName name);
 	
-	public ICPPASTLiteralExpression newLiteralExpression(int kind, String rep);
+	public ICPPASTArraySubscriptExpression newArraySubscriptExpression(IASTExpression arrayExpr, IASTExpression subscript);
 	
-	public ICPPASTUnaryExpression newUnaryExpression(int operator, IASTExpression operand);
+	/**
+	 * @since 5.2
+	 */
+	public ICPPASTArraySubscriptExpression newArraySubscriptExpression(IASTExpression arrayExpr, IASTInitializerClause subscript);
 	
-	public ICPPASTCastExpression newCastExpression(int operator, IASTTypeId typeId, IASTExpression operand);
+	public ICPPASTBaseSpecifier newBaseSpecifier(IASTName name, int visibility, boolean isVirtual);
 	
 	public ICPPASTBinaryExpression newBinaryExpression(int op, IASTExpression expr1, IASTExpression expr2);
 	
-	public ICPPASTTypeIdExpression newTypeIdExpression(int operator, IASTTypeId typeId);
+	/**
+	 * @since 5.2
+	 */
+	public ICPPASTBinaryExpression newBinaryExpression(int op, IASTExpression expr1, IASTInitializerClause expr2);
+
+	public ICPPASTCastExpression newCastExpression(int operator, IASTTypeId typeId, IASTExpression operand);
 	
-	public ICPPASTFunctionDefinition newFunctionDefinition(IASTDeclSpecifier declSpecifier,
-			IASTFunctionDeclarator declarator, IASTStatement bodyStatement);
+	public ICPPASTCatchHandler newCatchHandler(IASTDeclaration decl, IASTStatement body);
 	
+	public ICPPASTCompositeTypeSpecifier newCompositeTypeSpecifier(int key, IASTName name);
+
+	/**
+	 * @deprecated Replaced by {@link #newConstructorChainInitializer(IASTName, IASTInitializer)}
+	 */
+	@Deprecated
+	public ICPPASTConstructorChainInitializer newConstructorChainInitializer(IASTName memberInitializerId, IASTExpression initializerValue);
+	
+	/**
+	 * @since 5.2
+	 */
+	public ICPPASTConstructorChainInitializer newConstructorChainInitializer(IASTName id, IASTInitializer initializer);
+
+	/**
+	 * @deprecated Replaced by {@link #newConstructorInitializer(IASTInitializerClause[])}.
+	 */
+	@Deprecated
+	public ICPPASTConstructorInitializer newConstructorInitializer(IASTExpression exp);
+
+	/**
+	 * @since 5.2
+	 */
+	public ICPPASTConstructorInitializer newConstructorInitializer(IASTInitializerClause[] args);
+	
+	public ICPPASTConversionName newConversionName(IASTTypeId typeId);
+
 	/**
 	 * @since 5.2
 	 */
 	public ICPPASTDeclarator newDeclarator(IASTName name);
 
-	public ICPPASTFunctionDeclarator newFunctionDeclarator(IASTName name);
+	public ICPPASTDeleteExpression newDeleteExpression(IASTExpression operand);
+	
+	public ICPPASTElaboratedTypeSpecifier newElaboratedTypeSpecifier(int kind, IASTName name);
+
+	public ICPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiation(IASTDeclaration declaration);
 	
 	/**
-	 * @since 5.2
+	 * @deprecated Replaced by {@link #newExplicitTemplateInstantiation(IASTDeclaration)}.
 	 */
-	public ICPPASTArrayDeclarator newArrayDeclarator(IASTName name);
+	@Deprecated
+	public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiationGPP(IASTDeclaration declaration);
+
+	public ICPPASTExpressionList newExpressionList();
 
 	/**
 	 * @since 5.2
 	 */
 	public ICPPASTFieldDeclarator newFieldDeclarator(IASTName name, IASTExpression bitFieldSize);
-
-	public ICPPASTElaboratedTypeSpecifier newElaboratedTypeSpecifier(int kind, IASTName name);
-	
-	public ICPPASTParameterDeclaration newParameterDeclaration(IASTDeclSpecifier declSpec, IASTDeclarator declarator);
-
-	public ICPPASTSimpleDeclSpecifier newSimpleDeclSpecifier();
-	
-	public ICPPASTOperatorName newOperatorName(char[] name);
-
-	public ICPPASTNewExpression newNewExpression(IASTExpression placement, IASTExpression initializer, IASTTypeId typeId);
 	
 	public ICPPASTFieldReference newFieldReference(IASTName name, IASTExpression owner);
 	
-	public ICPPASTTemplateId newTemplateId(IASTName templateName);
-
-	public ICPPASTConversionName newConversionName(IASTTypeId typeId);
-
-	public ICPPASTQualifiedName newQualifiedName();
-	
-	public ICPPASTSwitchStatement newSwitchStatement(IASTExpression controlloer, IASTStatement body);
-	
-	public ICPPASTSwitchStatement newSwitchStatement(IASTDeclaration controller, IASTStatement body);
-	
-	public ICPPASTSwitchStatement newSwitchStatement();
-
-	public ICPPASTIfStatement newIfStatement(IASTExpression condition, IASTStatement then, IASTStatement elseClause);
-	
-	public ICPPASTIfStatement newIfStatement(IASTDeclaration condition, IASTStatement then, IASTStatement elseClause);
-	
-	public ICPPASTIfStatement newIfStatement();
-	
-	public ICPPASTForStatement newForStatement(IASTStatement init, IASTExpression condition,
-			IASTExpression iterationExpression, IASTStatement body);
+	public ICPPASTForStatement newForStatement();
 	
 	public ICPPASTForStatement newForStatement(IASTStatement init, IASTDeclaration condition,
 			IASTExpression iterationExpression, IASTStatement body);
-	
-	public ICPPASTForStatement newForStatement();
-	
-	public ICPPASTWhileStatement newWhileStatement(IASTExpression condition, IASTStatement body);
-	
-	public ICPPASTWhileStatement newWhileStatement(IASTDeclaration condition, IASTStatement body);
-	
-	public ICPPASTWhileStatement newWhileStatement();
 
+	public ICPPASTForStatement newForStatement(IASTStatement init, IASTExpression condition,
+			IASTExpression iterationExpression, IASTStatement body);
+	
+	/**
+	 * @deprecated Replaced by {@link #newFunctionCallExpression(IASTExpression, IASTInitializerClause[])}.
+	 */
+	@Deprecated
+	public ICPPASTFunctionCallExpression newFunctionCallExpression(IASTExpression idExpr, IASTExpression argList);
+	
 	/**
 	 * @since 5.2
 	 */
-	public ICPPASTTypeId newTypeId(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator);
+	public ICPPASTFunctionCallExpression newFunctionCallExpression(IASTExpression idExpr, IASTInitializerClause[] arguments);
+	
+	public ICPPASTFunctionDeclarator newFunctionDeclarator(IASTName name);
+	
+	public ICPPASTFunctionDefinition newFunctionDefinition(IASTDeclSpecifier declSpecifier,
+			IASTFunctionDeclarator declarator, IASTStatement bodyStatement);
+	
+	public ICPPASTFunctionWithTryBlock newFunctionTryBlock(IASTDeclSpecifier declSpecifier, IASTFunctionDeclarator declarator,
+			IASTStatement bodyStatement);
+	
+	public ICPPASTIfStatement newIfStatement();
+	
+	public ICPPASTIfStatement newIfStatement(IASTDeclaration condition, IASTStatement then, IASTStatement elseClause);
+	
+	public ICPPASTIfStatement newIfStatement(IASTExpression condition, IASTStatement then, IASTStatement elseClause);
 
-	public ICPPASTDeleteExpression newDeleteExpression(IASTExpression operand);
-	
-	public ICPPASTSimpleTypeConstructorExpression newSimpleTypeConstructorExpression(int type, IASTExpression expression);
-
-	public ICPPASTTypenameExpression newTypenameExpression(IASTName qualifiedName, IASTExpression expr, boolean isTemplate);
-
-	public ICPPASTNamespaceAlias newNamespaceAlias(IASTName alias, IASTName qualifiedName);
-	
-	public ICPPASTUsingDeclaration newUsingDeclaration(IASTName name);
-	
-	public ICPPASTUsingDirective newUsingDirective(IASTName name);
-
-	public ICPPASTLinkageSpecification newLinkageSpecification(String literal);
-	
-	public ICPPASTNamespaceDefinition newNamespaceDefinition(IASTName name);
-
-	public ICPPASTTemplateDeclaration newTemplateDeclaration(IASTDeclaration declaration);
-
-	public ICPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiation(IASTDeclaration declaration);
-	
-	public ICPPASTTemplateSpecialization newTemplateSpecialization(IASTDeclaration declaration);
-
-	public ICPPASTTryBlockStatement newTryBlockStatement(IASTStatement body);
-
-	public ICPPASTCatchHandler newCatchHandler(IASTDeclaration decl, IASTStatement body);
-	
-	public ICPPASTVisibilityLabel newVisibilityLabel(int visibility);
-	
-	public ICPPASTBaseSpecifier newBaseSpecifier(IASTName name, int visibility, boolean isVirtual);
-	
-	public ICPPASTCompositeTypeSpecifier newCompositeTypeSpecifier(int key, IASTName name);
-	
-	public ICPPASTNamedTypeSpecifier newTypedefNameSpecifier(IASTName name);
-	
-	public IGPPASTPointer newPointerGPP();
-	
-	/**
-	 * Creates an lvalue or rvalue reference operator.
-	 * @since 5.2
-	 */
-	public ICPPASTReferenceOperator newReferenceOperator(boolean isRValueReference);
-
-	public ICPPASTPointerToMember newPointerToMember(IASTName name);
-	
-	public IGPPASTPointerToMember newPointerToMemberGPP(IASTName name);
-
-	/**
-	 * @since 5.2
-	 */
-	public ICPPASTInitializerExpression newInitializerExpression(IASTExpression expression);
-	
 	/**
 	 * @since 5.2
 	 */
 	public ICPPASTInitializerList newInitializerList();
 
-	public ICPPASTConstructorInitializer newConstructorInitializer(IASTExpression exp);
+	public ICPPASTLinkageSpecification newLinkageSpecification(String literal);
 	
-	public ICPPASTConstructorChainInitializer newConstructorChainInitializer(IASTName memberInitializerId, IASTExpression initializerValue);
+	public ICPPASTLiteralExpression newLiteralExpression(int kind, String rep);
 
-	public ICPPASTFunctionWithTryBlock newFunctionTryBlock(IASTDeclSpecifier declSpecifier, IASTFunctionDeclarator declarator,
-			IASTStatement bodyStatement);
+	public ICPPASTNamespaceAlias newNamespaceAlias(IASTName alias, IASTName qualifiedName);
 
-	public ICPPASTSimpleTypeTemplateParameter newSimpleTypeTemplateParameter(int type, IASTName name, IASTTypeId typeId);
-
-	public ICPPASTTemplatedTypeTemplateParameter newTemplatedTypeTemplateParameter(IASTName name, IASTExpression defaultValue);
+	public ICPPASTNamespaceDefinition newNamespaceDefinition(IASTName name);
+	
+	/**
+	 * @deprecated Replaced by {@link #newNewExpression(IASTInitializerClause[], IASTInitializer, IASTTypeId)}
+	 */
+	@Deprecated
+	public ICPPASTNewExpression newNewExpression(IASTExpression placement, IASTExpression initializer, IASTTypeId typeId);
 	
-	public IASTProblemTypeId newProblemTypeId(IASTProblem problem);
-	
-	public ICPPASTExpressionList newExpressionList();
-	
-	public ICPPASTArraySubscriptExpression newArraySubscriptExpression(IASTExpression arrayExpr, IASTExpression subscript);
-	
-	public ICPPASTFunctionCallExpression newFunctionCallExpression(IASTExpression idExpr, IASTExpression argList);
-
 	/**
-	 * Creates a new static assertion declaration with the given condition and message.
 	 * @since 5.2
 	 */
-	public ICPPASTStaticAssertDeclaration newStaticAssertion(IASTExpression condition, ICPPASTLiteralExpression message);
+	public ICPPASTNewExpression newNewExpression(IASTInitializerClause[] placement, IASTInitializer initializer, IASTTypeId typeId);
+
+	public ICPPASTOperatorName newOperatorName(char[] name);
 	
 	/**
 	 * Creates a new pack expansion expression for the given pattern.
 	 * @since 5.2
 	 */
 	public ICPPASTPackExpansionExpression newPackExpansionExpression(IASTExpression pattern);
+
+	public ICPPASTParameterDeclaration newParameterDeclaration(IASTDeclSpecifier declSpec, IASTDeclarator declarator);
+
+	public IGPPASTPointer newPointerGPP();
+	
+	public ICPPASTPointerToMember newPointerToMember(IASTName name);
+
+	public IGPPASTPointerToMember newPointerToMemberGPP(IASTName name);
+
+	public IASTProblemTypeId newProblemTypeId(IASTProblem problem);
+	
+	public ICPPASTQualifiedName newQualifiedName();
 	
 	/**
 	 * @deprecated Replaced by {@link #newReferenceOperator(boolean)}.
 	 */
 	@Deprecated	public ICPPASTReferenceOperator newReferenceOperator();
+	
 	/**
-	 * @deprecated Replaced by {@link #newTranslationUnit(IScanner)}.
+	 * Creates an lvalue or rvalue reference operator.
+	 * @since 5.2
 	 */
-	@Deprecated
-	public ICPPASTTranslationUnit newTranslationUnit();
+	public ICPPASTReferenceOperator newReferenceOperator(boolean isRValueReference);
+	
+	/**
+	 * @since 5.2
+	 */
+	public IASTReturnStatement newReturnStatement(IASTInitializerClause retValue);
+	
+	public ICPPASTSimpleDeclSpecifier newSimpleDeclSpecifier();
+	
 	/**
 	 * @deprecated Replaced by {@link #newSimpleDeclSpecifier()}
 	 */
@@ -226,10 +218,81 @@ public interface ICPPNodeFactory extends INodeFactory {
 	public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier newSimpleDeclSpecifierGPP();
 
 	/**
-	 * @deprecated Replaced by {@link #newExplicitTemplateInstantiation(IASTDeclaration)}.
+	 * @deprecated Replaced by {@link #newSimpleTypeConstructorExpression(ICPPASTDeclSpecifier, IASTInitializer)}
+     */
+	@Deprecated
+	public ICPPASTSimpleTypeConstructorExpression newSimpleTypeConstructorExpression(int type, IASTExpression expression);
+
+	/**
+	 * @since 5.2
+	 */
+	public ICPPASTSimpleTypeConstructorExpression newSimpleTypeConstructorExpression(ICPPASTDeclSpecifier declSpec, IASTInitializer initializer);
+	
+	public ICPPASTSimpleTypeTemplateParameter newSimpleTypeTemplateParameter(int type, IASTName name, IASTTypeId typeId);
+	
+	/**
+	 * Creates a new static assertion declaration with the given condition and message.
+	 * @since 5.2
+	 */
+	public ICPPASTStaticAssertDeclaration newStaticAssertion(IASTExpression condition, ICPPASTLiteralExpression message);
+
+	public ICPPASTSwitchStatement newSwitchStatement();
+	
+	public ICPPASTSwitchStatement newSwitchStatement(IASTDeclaration controller, IASTStatement body);
+
+	public ICPPASTSwitchStatement newSwitchStatement(IASTExpression controlloer, IASTStatement body);
+
+	public ICPPASTTemplateDeclaration newTemplateDeclaration(IASTDeclaration declaration);
+
+	public ICPPASTTemplatedTypeTemplateParameter newTemplatedTypeTemplateParameter(IASTName name, IASTExpression defaultValue);
+	
+	public ICPPASTTemplateId newTemplateId(IASTName templateName);
+	
+	public ICPPASTTemplateSpecialization newTemplateSpecialization(IASTDeclaration declaration);
+	
+	/**
+	 * @deprecated Replaced by {@link #newTranslationUnit(IScanner)}.
 	 */
 	@Deprecated
-	public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiationGPP(IASTDeclaration declaration);
+	public ICPPASTTranslationUnit newTranslationUnit();
 
+	/**
+	 * Creates a new translation unit that cooperates with the given scanner in order
+	 * to track macro-expansions and location information.
+	 * @scanner the preprocessor the translation unit interacts with.
+	 * @since 5.2
+	 */
+	public ICPPASTTranslationUnit newTranslationUnit(IScanner scanner);
+
+	public ICPPASTTryBlockStatement newTryBlockStatement(IASTStatement body);
+
+	public ICPPASTNamedTypeSpecifier newTypedefNameSpecifier(IASTName name);
+	
+	/**
+	 * @since 5.2
+	 */
+	public ICPPASTTypeId newTypeId(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator);
+	
+	public ICPPASTTypeIdExpression newTypeIdExpression(int operator, IASTTypeId typeId);
+
+	/**
+	 * @deprecated Replaced by {@link #newSimpleTypeConstructorExpression(ICPPASTDeclSpecifier, IASTInitializer)}
+	 */
+	@Deprecated
+	public ICPPASTTypenameExpression newTypenameExpression(IASTName qualifiedName, IASTExpression expr, boolean isTemplate);
+	
+	public ICPPASTUnaryExpression newUnaryExpression(int operator, IASTExpression operand);
+
+	public ICPPASTUsingDeclaration newUsingDeclaration(IASTName name);
+
+	public ICPPASTUsingDirective newUsingDirective(IASTName name);
+
+	public ICPPASTVisibilityLabel newVisibilityLabel(int visibility);
+
+	public ICPPASTWhileStatement newWhileStatement();
+
+	public ICPPASTWhileStatement newWhileStatement(IASTDeclaration condition, IASTStatement body);
+	
+	public ICPPASTWhileStatement newWhileStatement(IASTExpression condition, IASTStatement body);
 
 }
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTUnaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTUnaryExpression.java
index 9e372d78c99..86be3b62afe 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTUnaryExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTUnaryExpression.java
@@ -14,6 +14,9 @@ import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
 
 /**
  * @deprecated Replaced by {@link IASTUnaryExpression}.
+ * 
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
  */
 @Deprecated
 public interface IGNUASTUnaryExpression extends IASTUnaryExpression {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IInactiveCodeToken.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IInactiveCodeToken.java
index b756aca39eb..34ae2bf74c5 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IInactiveCodeToken.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IInactiveCodeToken.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009 Wind River Systems, Inc. and others.
+ * Copyright (c) 2009, 2010 Wind River Systems, Inc. and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -14,6 +14,8 @@ package org.eclipse.cdt.core.parser;
  * Interface for tokens of kind {@link IToken#tINACTIVE_CODE_START}, {@link IToken#tINACTIVE_CODE_SEPARATOR} and
  * {@link IToken#tINACTIVE_CODE_END}.
  * @since 5.1
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
  */
 public interface IInactiveCodeToken extends IToken {
 
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousCastVsFunctionCallExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousCastVsFunctionCallExpression.java
index 0a5044376a4..41b01aa6ef4 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousCastVsFunctionCallExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousCastVsFunctionCallExpression.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008, 2009 Wind River Systems, Inc. and others.
+ * Copyright (c) 2008, 2010 Wind River Systems, Inc. and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -14,8 +14,10 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
 import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
 import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
 import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
 import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
 import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
 import org.eclipse.cdt.core.dom.ast.IASTName;
 import org.eclipse.cdt.core.dom.ast.IASTNode;
 import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
@@ -104,7 +106,15 @@ public abstract class ASTAmbiguousCastVsFunctionCallExpression extends ASTAmbigu
 		if (!hasIssue) 
 			return nodeToReplace;
 
-		fFunctionCallExpression.setParameterExpression(primaryWithParenthesis.getOperand());
+		final IASTExpression operand = primaryWithParenthesis.getOperand();
+		if (operand instanceof IASTExpressionList) {
+			final IASTExpressionList list= (IASTExpressionList) operand;
+			fFunctionCallExpression.setArguments(list.getExpressions());
+		} else if (operand != null) {
+			fFunctionCallExpression.setArguments(new IASTInitializerClause[] {operand});
+		} else {
+			fFunctionCallExpression.setArguments(IASTExpression.EMPTY_EXPRESSION_ARRAY);
+		}
 		setRange(fFunctionCallExpression, fCastExpression, primaryWithParenthesis);
 		
 		IASTExpression result= fFunctionCallExpression;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEqualsInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEqualsInitializer.java
new file mode 100644
index 00000000000..1311303fadc
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEqualsInitializer.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    John Camelon (IBM) - Initial API and implementation
+ *    Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.parser;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+
+/**
+ * Initializer with equals sign (copy initialization)
+ */
+public abstract class ASTEqualsInitializer extends ASTNode implements IASTEqualsInitializer,
+		IASTAmbiguityParent {
+
+    private IASTInitializerClause fArgument;
+    
+    public ASTEqualsInitializer() {
+	}
+
+	public ASTEqualsInitializer(IASTInitializerClause arg) {
+		setInitializerClause(arg);
+	}
+
+	public IASTInitializerClause getInitializerClause() {
+        return fArgument;
+    }
+
+    public void setInitializerClause(IASTInitializerClause clause) {
+        assertNotFrozen();
+        fArgument = clause;
+        if (clause != null) {
+        	clause.setParent(this);
+        	clause.setPropertyInParent(INITIALIZER);
+		}
+    }
+
+    @Override
+	public boolean accept( ASTVisitor action ){
+        if( action.shouldVisitInitializers ){
+		    switch( action.visit( this ) ){
+	            case ASTVisitor.PROCESS_ABORT : return false;
+	            case ASTVisitor.PROCESS_SKIP  : return true;
+	            default : break;
+	        }
+		}
+        
+		if (fArgument != null && !fArgument.accept(action))
+			return false;
+        
+		if (action.shouldVisitInitializers && action.leave(this) == ASTVisitor.PROCESS_ABORT)
+			return false;
+
+        return true;
+    }
+
+	public void replace(IASTNode child, IASTNode other) {
+		if (child == fArgument) {
+			other.setPropertyInParent(child.getPropertyInParent());
+			other.setParent(child.getParent());
+			fArgument = (IASTInitializerClause) other;
+		}
+	}
+
+	@Deprecated
+	public IASTExpression getExpression() {
+		if (fArgument instanceof IASTExpression)
+			return (IASTExpression) fArgument;
+		
+		return null;
+	}
+
+	@Deprecated
+	public void setExpression(IASTExpression expression) {
+		setInitializerClause(expression);
+	}
+}
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 70b0d5b8fe0..8c523178d8d 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
@@ -43,8 +43,8 @@ import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
 import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
 import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
 import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
-import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
 import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
 import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
 import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
 import org.eclipse.cdt.core.dom.ast.IASTName;
@@ -55,7 +55,6 @@ import org.eclipse.cdt.core.dom.ast.IASTProblem;
 import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration;
 import org.eclipse.cdt.core.dom.ast.IASTProblemExpression;
 import org.eclipse.cdt.core.dom.ast.IASTProblemStatement;
-import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
 import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
 import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
 import org.eclipse.cdt.core.dom.ast.IASTStatement;
@@ -67,7 +66,6 @@ import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
 import org.eclipse.cdt.core.dom.ast.INodeFactory;
 import org.eclipse.cdt.core.dom.ast.IType;
 import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPackExpansionExpression;
 import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
 import org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider;
 import org.eclipse.cdt.core.dom.parser.ISourceCodeParser;
@@ -633,6 +631,11 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
         throw backtrack;
     }
 
+    protected final void throwBacktrack(IASTNode node) throws BacktrackException {
+    	final ASTNode n= (ASTNode) node;
+		throwBacktrack(n.getOffset(), n.getLength());
+    }
+
     public IASTTranslationUnit parse() {
         long startTime = System.currentTimeMillis();
         translationUnit();
@@ -900,16 +903,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
     }
 
 
-    protected IASTExpression possiblyEmptyExpressionList(int endToken) throws BacktrackException, EndOfFileException {
-    	IToken la1= LA(1);
-    	if (la1.getType() == endToken) {
-            IASTExpressionList expressionList = nodeFactory.newExpressionList();
-            ((ASTNode) expressionList).setOffsetAndLength(la1.getOffset(), 0);
-            return expressionList;
-    	}
-    	return expression();
-    }
-    
     /**
      * Models a cast expression followed by an operator. Can be linked into a chain.
      * This is done right to left, such that a tree of variants can be built.
@@ -919,10 +912,10 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
 		final int fLeftPrecedence;
 		final int fRightPrecedence;
 		BinaryOperator fNext;
-		IASTExpression fExpression;
+		IASTInitializerClause fExpression;
 		final CastAmbiguityMarker fAmbiguityMarker;
 
-		public BinaryOperator(BinaryOperator nextOp, IASTExpression expression, int operatorToken, int leftPrecedence, int rightPrecedence) {
+		public BinaryOperator(BinaryOperator nextOp, IASTInitializerClause expression, int operatorToken, int leftPrecedence, int rightPrecedence) {
 			fNext= nextOp;
 			fOperatorToken= operatorToken;
 			fLeftPrecedence= leftPrecedence;
@@ -937,24 +930,24 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
 			}
 		}
 
-		public IASTExpression exchange(IASTExpression expr) {
-			IASTExpression e= fExpression;
+		public IASTInitializerClause exchange(IASTInitializerClause expr) {
+			IASTInitializerClause e= fExpression;
 			fExpression= expr;
 			return e;
 		}
 	}
 	
-	protected final IASTExpression buildExpression(BinaryOperator leftChain, IASTExpression expr) throws BacktrackException {
+	protected final IASTExpression buildExpression(BinaryOperator leftChain, IASTInitializerClause expr) throws BacktrackException {
 		BinaryOperator rightChain= null;
 		for (;;) {
 			if (leftChain == null) {
 				if (rightChain == null)
-					return expr;
+					return (IASTExpression) expr;
 				
-				expr= buildExpression(expr, rightChain);
+				expr= buildExpression((IASTExpression) expr, rightChain);
 				rightChain= rightChain.fNext;
 			} else if (rightChain != null && leftChain.fRightPrecedence < rightChain.fLeftPrecedence) {
-				expr= buildExpression(expr, rightChain);
+				expr= buildExpression((IASTExpression) expr, rightChain);
 				rightChain= rightChain.fNext;
 			} else { 
 				BinaryOperator op= leftChain;
@@ -968,7 +961,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
 
 	private IASTExpression buildExpression(IASTExpression left, BinaryOperator operator) throws BacktrackException {
 		int op, unaryOp= 0;
-		final IASTExpression right= operator.fExpression;
+		final IASTInitializerClause right= operator.fExpression;
 		switch(operator.fOperatorToken) {
         case IToken.tQUESTION:
         	if (operator.fNext == null || operator.fNext.fOperatorToken != IToken.tCOLON) {
@@ -977,26 +970,15 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
 	        	throwBacktrack(node.getOffset(), node.getLength());
 	        	return null; // Will never be reached.
         	} 
-        	IASTExpression negative= operator.fNext.fExpression;
+        	IASTInitializerClause negative= operator.fNext.fExpression;
         	operator.fNext= operator.fNext.fNext;
-            IASTConditionalExpression conditionalEx = nodeFactory.newConditionalExpession(left, right, negative);
+            IASTConditionalExpression conditionalEx = nodeFactory.newConditionalExpession(left, (IASTExpression) right, (IASTExpression) negative);
             setRange(conditionalEx, left);
             if (negative != null) {
             	adjustLength(conditionalEx, negative);
             }
             return conditionalEx;
 			
-        case IToken.tELLIPSIS:
-        	if (right instanceof ICPPASTPackExpansionExpression) {
-        		((ICPPASTPackExpansionExpression) right).setPattern(left);
-        		int endOffset= ((ASTNode) right).getLength();
-        		setRange(right, left);
-        		adjustEndOffset(right, endOffset);
-        		return right;
-        	}
-        	assert false;
-        	return left;
-
 		case IToken.tCOMMA:
 			IASTExpressionList list;
 			if (left instanceof IASTExpressionList) {
@@ -1006,7 +988,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
 				list.addExpression(left);
 				setRange(list, left);
 			}
-			list.addExpression(right);
+			list.addExpression((IASTExpression) right);
 			adjustLength(list, right);
 			return list;
 			
@@ -1220,7 +1202,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
 						backup(mark);
 						try {
 							IASTExpression expr= primaryExpression(ctx);
-							IASTFunctionCallExpression fcall = nodeFactory.newFunctionCallExpression(expr, null);
+							IASTFunctionCallExpression fcall = nodeFactory.newFunctionCallExpression(expr, (IASTExpression[]) null);
 							IASTAmbiguousExpression ambiguity = createAmbiguousCastVsFunctionCallExpression(result, fcall);
 							((ASTNode) ambiguity).setOffsetAndLength((ASTNode) result);
 							return ca == null ? ambiguity : ca.updateExpression(ambiguity);
@@ -1346,12 +1328,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
 		parent.addDeclaration(declaration);
 	}
 
-    protected IASTExpression buildBinaryExpression(int operator, IASTExpression expr1, IASTExpression expr2, int lastOffset) {
-        IASTBinaryExpression result = nodeFactory.newBinaryExpression(operator, expr1, expr2);
-        int o = ((ASTNode) expr1).getOffset();
-        ((ASTNode) result).setOffsetAndLength(o, lastOffset - o);
-        return result;
-    }
+    abstract protected IASTExpression buildBinaryExpression(int operator, IASTExpression expr1, IASTInitializerClause expr2, int lastOffset);
 
 	private IASTExpression createCastVsBinaryExpressionAmbiguity(IASTBinaryExpression expr, final IASTTypeId typeid, int unaryOperator, int unaryOpOffset) {
 		IASTUnaryExpression unary= nodeFactory.newUnaryExpression(unaryOperator, null);
@@ -1829,6 +1806,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
             ((ASTNode) ds).setOffsetAndLength(((ASTNode) d).getOffset(), ((ASTNode) d).getLength());
         } catch (BacktrackException b) {
             if (expressionStatement == null) {
+            	backup(mark);
             	throw b;
             }
         }
@@ -1974,40 +1952,17 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
     }
 
     protected IASTStatement parseReturnStatement() throws EndOfFileException, BacktrackException {
-        int startOffset;
-        startOffset = consume().getOffset(); // t_return
-        IASTExpression result = null;
+        final int offset= consume(IToken.t_return).getOffset();
 
-        // See if there is a return expression
-        switch (LT(1)) {
-        case IToken.tEOC:
-            // We're trying to start one
-            IASTName name = identifier();
-            IASTIdExpression idExpr = nodeFactory.newIdExpression(name);
-            result = idExpr;
-            break;
-        case IToken.tSEMI:
-            // None
-            break;
-        default:
-            // Yes
-            result = expression();
-            break;
+        // Optional expression
+        IASTExpression expr = null;
+        if (LT(1) != IToken.tSEMI) {
+        	expr = expression();
         }
+        // Semicolon
+        final int endOffset= consumeOrEOC(IToken.tSEMI).getEndOffset();
 
-        int lastOffset = 0;
-        switch (LT(1)) {
-        case IToken.tSEMI:
-        case IToken.tEOC:
-            lastOffset = consume().getEndOffset();
-            break;
-        default:
-            throwBacktrack(LA(1));
-        }
-
-        IASTReturnStatement return_statement = nodeFactory.newReturnStatement(result);
-        ((ASTNode) return_statement).setOffsetAndLength(startOffset, lastOffset - startOffset);
-        return return_statement;
+        return setRange(nodeFactory.newReturnStatement(expr), offset, endOffset);
     }
 
     protected IASTStatement parseDoStatement() throws EndOfFileException, BacktrackException {
@@ -2316,7 +2271,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
     			
     			// Allow empty attribute
     			if (lt1 != IToken.tCOMMA) {
-    				singelAttribute();
+    				singleAttribute();
     			}
 
 				// Require comma
@@ -2330,7 +2285,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
     	}
     }
 
-	private void singelAttribute() throws EndOfFileException, BacktrackException {
+	private void singleAttribute() throws EndOfFileException, BacktrackException {
 		// Check if we have an identifier including keywords
 		if (!isIdentifier(LA(1)))
 			throw backtrack;					
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java
index 13122ad584a..ac5294f63e8 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java
@@ -12,33 +12,33 @@ package org.eclipse.cdt.internal.core.dom.parser;
 
 /** 
  * Configures the parsing of a declaration in various contexts.
- * @since 5.0
  */
 public class DeclarationOptions {
-	final public static int ALLOW_EMPTY_SPECIFIER= 	0x01;
-	final public static int ALLOW_ABSTRACT= 		0x02;
-	final public static int REQUIRE_ABSTRACT= 		0x04;
-	final public static int ALLOW_BITFIELD= 		0x08;
-	final public static int NO_INITIALIZER=      	0x10;
-	final public static int ALLOW_CONSTRUCTOR_INITIALIZER= 0x20;
-	final public static int NO_FUNCTIONS= 			0x40;
-	final public static int NO_ARRAYS= 				0x80;
-	final public static int NO_NESTED= 				0x100;
-	final public static int ALLOW_PARAMETER_PACKS=  0x200;
-	final public static int REQUIRE_SIMPLE_NAME=    0x400;
+	final public static int ALLOW_EMPTY_SPECIFIER= 			0x01;
+	final public static int ALLOW_ABSTRACT= 				0x02;
+	final public static int REQUIRE_ABSTRACT= 				0x04;
+	final public static int ALLOW_BITFIELD= 				0x08;
+	final public static int NO_INITIALIZER=      			0x10;
+	final public static int NO_CTOR_STYLE_INITIALIZER= 		0x20;
+	final public static int NO_BRACED_INITIALIZER= 			0x40;
+	final public static int NO_FUNCTIONS= 					0x80;
+	final public static int NO_ARRAYS= 						0x100;
+	final public static int NO_NESTED= 						0x200;
+	final public static int ALLOW_PARAMETER_PACKS=  		0x400;
+	final public static int REQUIRE_SIMPLE_NAME=    		0x800;
 
     public static final DeclarationOptions 
-    	GLOBAL=     new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | ALLOW_CONSTRUCTOR_INITIALIZER),
+    	GLOBAL=     new DeclarationOptions(ALLOW_EMPTY_SPECIFIER),
     	FUNCTION_STYLE_ASM= new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | NO_INITIALIZER | ALLOW_ABSTRACT),
     	C_MEMBER=   new DeclarationOptions(ALLOW_BITFIELD | ALLOW_ABSTRACT),
-    	CPP_MEMBER= new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | ALLOW_BITFIELD),
-    	LOCAL=	    new DeclarationOptions(ALLOW_CONSTRUCTOR_INITIALIZER),
-    	PARAMETER=  new DeclarationOptions(ALLOW_ABSTRACT | ALLOW_PARAMETER_PACKS | REQUIRE_SIMPLE_NAME),
+    	CPP_MEMBER= new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | ALLOW_BITFIELD | NO_CTOR_STYLE_INITIALIZER),
+    	LOCAL=	    new DeclarationOptions(0),
+    	PARAMETER=  new DeclarationOptions(ALLOW_ABSTRACT | ALLOW_PARAMETER_PACKS | REQUIRE_SIMPLE_NAME | NO_BRACED_INITIALIZER | NO_CTOR_STYLE_INITIALIZER),
     	TYPEID=     new DeclarationOptions(REQUIRE_ABSTRACT | NO_INITIALIZER),
     	TYPEID_NEW= new DeclarationOptions(REQUIRE_ABSTRACT | NO_INITIALIZER | NO_FUNCTIONS | NO_NESTED),
     	TYPEID_CONVERSION= new DeclarationOptions(REQUIRE_ABSTRACT | NO_INITIALIZER | NO_FUNCTIONS | NO_NESTED),
         EXCEPTION= new DeclarationOptions(ALLOW_ABSTRACT | NO_INITIALIZER),
-        CONDITION= new DeclarationOptions(ALLOW_CONSTRUCTOR_INITIALIZER),
+        CONDITION= new DeclarationOptions(NO_CTOR_STYLE_INITIALIZER),
         C_PARAMETER_NON_ABSTRACT= new DeclarationOptions(ALLOW_ABSTRACT | ALLOW_EMPTY_SPECIFIER);
 
 	final public boolean fAllowEmptySpecifier;
@@ -46,7 +46,8 @@ public class DeclarationOptions {
 	final public boolean fRequireAbstract;
 	final public boolean fAllowBitField;
 	final public boolean fAllowInitializer;
-	final public boolean fAllowConstructorInitializer;
+	final public boolean fAllowBracedInitializer;
+	final public boolean fAllowCtorStyleInitializer;
 	final public boolean fAllowFunctions;
 	final public boolean fAllowNested;
 	final public boolean fAllowParameterPacks;
@@ -58,7 +59,8 @@ public class DeclarationOptions {
 		fAllowAbstract= fRequireAbstract || (options & ALLOW_ABSTRACT) != 0;
 		fAllowBitField= (options & ALLOW_BITFIELD) != 0;
 		fAllowInitializer= (options & NO_INITIALIZER) == 0;
-		fAllowConstructorInitializer= fAllowInitializer && (options & ALLOW_CONSTRUCTOR_INITIALIZER) != 0;
+		fAllowBracedInitializer= fAllowInitializer && (options & NO_BRACED_INITIALIZER) == 0;
+		fAllowCtorStyleInitializer= fAllowInitializer && (options & NO_CTOR_STYLE_INITIALIZER) == 0;
 		fAllowFunctions= (options & NO_FUNCTIONS) == 0;
 		fAllowNested= (options & NO_NESTED) == 0;
 		fAllowParameterPacks= (options & ALLOW_PARAMETER_PACKS) != 0;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTAmbiguousSimpleDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTAmbiguousSimpleDeclaration.java
index 14c61f38e4b..4b59b50b0f3 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTAmbiguousSimpleDeclaration.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTAmbiguousSimpleDeclaration.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009 Wind River Systems, Inc. and others.
+ * Copyright (c) 2009, 2010 Wind River Systems, Inc. and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -14,7 +14,6 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
 
 /**
  * Needed to handle the ambiguity for simple declarations in plain C
- * @since 5.1
  */
 public interface IASTAmbiguousSimpleDeclaration extends IASTSimpleDeclaration {
 
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalEnumerationSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalEnumerationSpecifier.java
index 7bc08231750..5024bdd2094 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalEnumerationSpecifier.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalEnumerationSpecifier.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008 Wind River Systems, Inc. and others.
+ * Copyright (c) 2008, 2010 Wind River Systems, Inc. and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -14,7 +14,6 @@ import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
 
 /**
  * Internal interface for c- or c++ enumeration specifiers.
- * @noimplement This interface is not intended to be implemented by clients.
  */
 public interface IASTInternalEnumerationSpecifier extends IASTEnumerationSpecifier {
 	/**
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java
index 88ac199cb3e..84a4b24f34e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java
@@ -20,6 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
 import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression;
 import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
 import org.eclipse.cdt.core.dom.ast.IASTDoStatement;
+import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
 import org.eclipse.cdt.core.dom.ast.IASTExpression;
 import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
 import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
@@ -28,7 +29,6 @@ import org.eclipse.cdt.core.dom.ast.IASTForStatement;
 import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
 import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
 import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
-import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
 import org.eclipse.cdt.core.dom.ast.IASTNode;
 import org.eclipse.cdt.core.dom.ast.IASTProblemExpression;
 import org.eclipse.cdt.core.dom.ast.IASTProblemStatement;
@@ -65,7 +65,7 @@ public abstract class VariableReadWriteFlags {
 		else if (parent instanceof IASTStatement) {
 			return rwInStatement(node, (IASTStatement) parent, indirection);
 		}
-		else if (parent instanceof IASTInitializerExpression) {
+		else if (parent instanceof IASTEqualsInitializer) {
 			return rwInInitializerExpression(indirection, parent);
 		}
 		else if (parent instanceof IASTArrayModifier) {
@@ -113,7 +113,7 @@ public abstract class VariableReadWriteFlags {
 		if (expr instanceof IASTExpressionList) {
 			final IASTExpressionList exprList = (IASTExpressionList)expr;
 			final IASTNode grand= expr.getParent();
-			if (grand instanceof IASTFunctionCallExpression && expr.getPropertyInParent() == IASTFunctionCallExpression.PARAMETERS) {
+			if (grand instanceof IASTFunctionCallExpression && expr.getPropertyInParent() == IASTFunctionCallExpression.ARGUMENT) {
 				final IASTFunctionCallExpression funcCall = (IASTFunctionCallExpression) grand;
 				return rwArgumentForFunctionCall(node, exprList, funcCall, indirection);
 			}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArraySubscriptExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArraySubscriptExpression.java
index 420e0188cb8..65090f6183d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArraySubscriptExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArraySubscriptExpression.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -15,6 +15,7 @@ package org.eclipse.cdt.internal.core.dom.parser.c;
 import org.eclipse.cdt.core.dom.ast.ASTVisitor;
 import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
 import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
 import org.eclipse.cdt.core.dom.ast.IASTNode;
 import org.eclipse.cdt.core.dom.ast.IArrayType;
 import org.eclipse.cdt.core.dom.ast.IPointerType;
@@ -73,7 +74,20 @@ public class CASTArraySubscriptExpression extends ASTNode implements
         }
     }
 
-    @Override
+    
+    public IASTInitializerClause getArgument() {
+		return getSubscriptExpression();
+	}
+
+	public void setArgument(IASTInitializerClause expression) {
+		if (expression instanceof IASTExpression) {
+			setSubscriptExpression((IASTExpression) expression);
+		} else {
+			setSubscriptExpression(null);
+		}
+	}
+
+	@Override
 	public boolean accept( ASTVisitor action ){
         if( action.shouldVisitExpressions ){
 		    switch( action.visit( this ) ){
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBinaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBinaryExpression.java
index 9216dada5fd..6de2baaa096 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBinaryExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBinaryExpression.java
@@ -15,6 +15,7 @@ package org.eclipse.cdt.internal.core.dom.parser.c;
 import org.eclipse.cdt.core.dom.ast.ASTVisitor;
 import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
 import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
 import org.eclipse.cdt.core.dom.ast.IASTNode;
 import org.eclipse.cdt.core.dom.ast.IPointerType;
 import org.eclipse.cdt.core.dom.ast.IType;
@@ -62,7 +63,11 @@ public class CASTBinaryExpression extends ASTNode implements
         return operand2;
     }
 
-    /**
+    public IASTInitializerClause getInitOperand2() {
+        return operand2;
+	}
+
+	/**
      * @param op An op_X field from {@link IASTBinaryExpression}
      */
     public void setOperator(int op) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDesignatedInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDesignatedInitializer.java
index 0b746a82d3e..14a62cfdb37 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDesignatedInitializer.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDesignatedInitializer.java
@@ -1,36 +1,43 @@
 /*******************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
  *
  * Contributors:
- * IBM - Initial API and implementation
- * Yuan Zhang / Beth Tibbitts (IBM Research)
+ *    John Camelon (IBM) - Initial API and implementation
+ *    Yuan Zhang / Beth Tibbitts (IBM Research)
+ *    Markus Schorn (Wind River Systems)
  *******************************************************************************/
 package org.eclipse.cdt.internal.core.dom.parser.c;
 
 import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
 import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
 import org.eclipse.cdt.core.dom.ast.c.ICASTDesignatedInitializer;
 import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
 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.IASTAmbiguityParent;
 
 /**
- * @author jcamelon
+ * Implementation for designated initializers
  */
-public class CASTDesignatedInitializer extends ASTNode implements ICASTDesignatedInitializer {
+public class CASTDesignatedInitializer extends ASTNode implements ICASTDesignatedInitializer, IASTAmbiguityParent {
 
-    private IASTInitializer rhs;
-
-    
+    private IASTInitializerClause rhs;
+    private ICASTDesignator [] designators = null;
+    private int designatorsPos=-1;
+     
     public CASTDesignatedInitializer() {
 	}
 
-	public CASTDesignatedInitializer(IASTInitializer operandInitializer) {
-		setOperandInitializer(operandInitializer);
+	public CASTDesignatedInitializer(IASTInitializerClause init) {
+		setOperand(init);
 	}
 
 	public CASTDesignatedInitializer copy() {
@@ -57,22 +64,44 @@ public class CASTDesignatedInitializer extends ASTNode implements ICASTDesignate
         return designators;
     }
 
-    private ICASTDesignator [] designators = null;
-    int designatorsPos=-1;
     
     
-    public IASTInitializer getOperandInitializer() {
+    public IASTInitializerClause getOperand() {
         return rhs;
-    }
+	}
 
-    
-    public void setOperandInitializer(IASTInitializer rhs) {
+	public void setOperand(IASTInitializerClause operand) {
         assertNotFrozen();
-        this.rhs = rhs;
+        this.rhs = operand;
         if (rhs != null) {
 			rhs.setParent(this);
 			rhs.setPropertyInParent(OPERAND);
 		}
+	}
+
+	@Deprecated
+	public IASTInitializer getOperandInitializer() {
+		if (rhs instanceof IASTInitializer) {
+			return (IASTInitializer) rhs;
+		}
+		if (rhs instanceof IASTExpression) {
+			CASTEqualsInitializer init = new CASTEqualsInitializer(((IASTExpression)rhs).copy());
+			init.setParent(this);
+			init.setPropertyInParent(OPERAND);
+			return init;
+		}
+        return null;
+    }
+
+    @Deprecated
+    public void setOperandInitializer(IASTInitializer rhs) {
+    	if (rhs instanceof IASTEqualsInitializer) {
+    		setOperand(((IASTEqualsInitializer) rhs).getInitializerClause());
+    	} else if (rhs instanceof IASTInitializerClause) {
+    		setOperand((IASTInitializerClause) rhs);
+    	} else {
+    		setOperand(null);
+    	}
     }
 
     @Override
@@ -100,4 +129,11 @@ public class CASTDesignatedInitializer extends ASTNode implements ICASTDesignate
         return true;
     }
 
+    public void replace(IASTNode child, IASTNode other) {
+    	if (child == rhs) {
+    		other.setPropertyInParent(child.getPropertyInParent());
+    		other.setParent(child.getParent());
+    		rhs =  (IASTInitializerClause) other;
+    	}
+    }
 }
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEqualsInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEqualsInitializer.java
new file mode 100644
index 00000000000..41ec7663860
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEqualsInitializer.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    John Camelon (IBM) - Initial API and implementation
+ *    Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.parser.c;
+
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
+import org.eclipse.cdt.internal.core.dom.parser.ASTEqualsInitializer;
+
+/**
+ * Initializer with equals sign (copy initialization)
+ */
+public class CASTEqualsInitializer extends ASTEqualsInitializer {
+    public CASTEqualsInitializer() {
+	}
+
+	public CASTEqualsInitializer(IASTInitializerClause arg) {
+		super(arg);
+	}
+
+	public CASTEqualsInitializer copy() {
+		IASTInitializerClause arg = getInitializerClause();
+		CASTEqualsInitializer copy = new CASTEqualsInitializer(arg == null ? null : arg.copy());
+		copy.setOffsetAndLength(this);
+		return copy;
+	}
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFunctionCallExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFunctionCallExpression.java
index dc94acc2313..6f08ca8d85e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFunctionCallExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFunctionCallExpression.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -14,6 +14,8 @@ package org.eclipse.cdt.internal.core.dom.parser.c;
 
 import org.eclipse.cdt.core.dom.ast.ASTVisitor;
 import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
 import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
 import org.eclipse.cdt.core.dom.ast.IASTNode;
 import org.eclipse.cdt.core.dom.ast.IFunctionType;
@@ -29,21 +31,29 @@ public class CASTFunctionCallExpression extends ASTNode implements
         IASTFunctionCallExpression, IASTAmbiguityParent {
 
     private IASTExpression functionName;
-    private IASTExpression parameter;
+    private IASTInitializerClause[] fArguments;
 
     
     public CASTFunctionCallExpression() {
+    	setArguments(null);
 	}
 
-	public CASTFunctionCallExpression(IASTExpression functionName, IASTExpression parameter) {
+	public CASTFunctionCallExpression(IASTExpression functionName, IASTInitializerClause[] args) {
 		setFunctionNameExpression(functionName);
-		setParameterExpression(parameter);
+		setArguments(args);
 	}
 
 	public CASTFunctionCallExpression copy() {
-		CASTFunctionCallExpression copy = new CASTFunctionCallExpression();
+		IASTInitializerClause[] args = null;
+		if (fArguments.length > 0) {
+			args= new IASTInitializerClause[fArguments.length];
+			for (int i=0; i designator= designatorList();
         	if (designator == null) {
-        		IASTInitializer initializer= cInitializerClause(true);
+        		IASTInitializerClause clause= initClause(true);
         		// depending on value of skipTrivialItemsInCompoundInitializers initializer may be null
         		// in any way add the initializer such that the actual size can be tracked.
-        		result.addInitializer(initializer);
+        		result.addClause(clause);
         	} else {
+        		// Gnu extension: the assign operator is optional
         		if (LT(1) == IToken.tASSIGN)
-        			consume();
-        		IASTInitializer initializer= cInitializerClause(false);
-        		ICASTDesignatedInitializer desigInitializer = nodeFactory.newDesignatedInitializer(initializer);
+        			consume(IToken.tASSIGN);
+        		
+        		IASTInitializerClause clause= initClause(false);
+        		ICASTDesignatedInitializer desigInitializer = nodeFactory.newDesignatedInitializer(clause);
         		setRange(desigInitializer, designator.get(0));
-        		adjustLength(desigInitializer, initializer);
+        		adjustLength(desigInitializer, clause);
 
         		for (ICASTDesignator d : designator) {
         			desigInitializer.addDesignator(d);
         		}
-        		result.addInitializer(desigInitializer);
+        		result.addClause(desigInitializer);
         	}
 
         	// can end with ", }" or "}"
@@ -566,6 +569,14 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
     	return buildExpression(lastOperator, lastExpression);
 	}
     
+    @Override
+	protected IASTExpression buildBinaryExpression(int operator, IASTExpression expr1, IASTInitializerClause expr2, int lastOffset) {
+        IASTBinaryExpression result = nodeFactory.newBinaryExpression(operator, expr1, (IASTExpression) expr2);
+        int o = ((ASTNode) expr1).getOffset();
+        ((ASTNode) result).setOffsetAndLength(o, lastOffset - o);
+        return result;
+    }
+
     @Override
 	protected IASTExpression unaryExpression(CastExprCtx ctx) throws EndOfFileException, BacktrackException {
         switch (LT(1)) {
@@ -609,7 +620,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
         		if (t != null) {
         			consume(IToken.tRPAREN);
                 	if (LT(1) == IToken.tLBRACE) {
-						IASTInitializer i = cInitializerClause(false);
+						IASTInitializer i = (IASTInitializerList) initClause(false);
 						firstExpression= nodeFactory.newTypeIdInitializerExpression(t, i);
 						setRange(firstExpression, offset, calculateEndOffset(i));
         				break;        
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTArraySubscriptExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTArraySubscriptExpression.java
index 3ba0cd9bc45..377639ab364 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTArraySubscriptExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTArraySubscriptExpression.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
 import org.eclipse.cdt.core.dom.ast.DOMException;
 import org.eclipse.cdt.core.dom.ast.IASTExpression;
 import org.eclipse.cdt.core.dom.ast.IASTImplicitName;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
 import org.eclipse.cdt.core.dom.ast.IASTNode;
 import org.eclipse.cdt.core.dom.ast.IArrayType;
 import org.eclipse.cdt.core.dom.ast.IPointerType;
@@ -31,8 +32,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
 
 public class CPPASTArraySubscriptExpression extends ASTNode implements ICPPASTArraySubscriptExpression, IASTAmbiguityParent {
 
-    private IASTExpression subscriptExp;
     private IASTExpression arrayExpression;
+    private IASTInitializerClause subscriptExp;
     private ICPPFunction overload= UNINITIALIZED_FUNCTION;
 
     private IASTImplicitName[] implicitNames = null;
@@ -40,15 +41,15 @@ public class CPPASTArraySubscriptExpression extends ASTNode implements ICPPASTAr
     public CPPASTArraySubscriptExpression() {
 	}
 
-	public CPPASTArraySubscriptExpression(IASTExpression arrayExpression, IASTExpression subscriptExp) {
+	public CPPASTArraySubscriptExpression(IASTExpression arrayExpression, IASTInitializerClause operand) {
 		setArrayExpression(arrayExpression);
-		setSubscriptExpression(subscriptExp);
+		setArgument(operand);
 	}
 	
 	public CPPASTArraySubscriptExpression copy() {
 		CPPASTArraySubscriptExpression copy = new CPPASTArraySubscriptExpression();
 		copy.setArrayExpression(arrayExpression == null ? null : arrayExpression.copy());
-		copy.setSubscriptExpression(subscriptExp == null ? null : subscriptExp.copy());
+		copy.setArgument(subscriptExp == null ? null : subscriptExp.copy());
 		copy.setOffsetAndLength(this);
 		return copy;
 	}
@@ -67,18 +68,30 @@ public class CPPASTArraySubscriptExpression extends ASTNode implements ICPPASTAr
 		}
     }
 
-    public IASTExpression getSubscriptExpression() {
+    public IASTInitializerClause getArgument() {
         return subscriptExp;
     }
 
-    public void setSubscriptExpression(IASTExpression expression) {
+    public void setArgument(IASTInitializerClause arg) {
         assertNotFrozen();
-        subscriptExp = expression;
-        if (expression != null) {
-			expression.setParent(this);
-			expression.setPropertyInParent(SUBSCRIPT);
+        subscriptExp = arg;
+        if (arg != null) {
+        	arg.setParent(this);
+        	arg.setPropertyInParent(SUBSCRIPT);
 		}
     }
+
+    @Deprecated
+    public IASTExpression getSubscriptExpression() {
+    	if (subscriptExp instanceof IASTExpression)
+    		return (IASTExpression) subscriptExp;
+    	return null;
+    }
+
+    @Deprecated
+    public void setSubscriptExpression(IASTExpression expression) {
+    	setArgument(expression);
+    }
     
     public IASTImplicitName[] getImplicitNames() {
 		if(implicitNames == null) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java
index dee8ac63cc1..2131a4a4ce6 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java
@@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
 import org.eclipse.cdt.core.dom.ast.IASTExpression;
 import org.eclipse.cdt.core.dom.ast.IASTImplicitName;
 import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
 import org.eclipse.cdt.core.dom.ast.IASTNode;
 import org.eclipse.cdt.core.dom.ast.IPointerType;
 import org.eclipse.cdt.core.dom.ast.IProblemBinding;
@@ -37,7 +38,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
 public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpression, IASTAmbiguityParent {
 	private int op;
     private IASTExpression operand1;
-    private IASTExpression operand2;
+    private IASTInitializerClause operand2;
     private IType type;
     private ICPPFunction overload= UNINITIALIZED_FUNCTION;
     private IASTImplicitName[] implicitNames = null;
@@ -46,17 +47,17 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
     public CPPASTBinaryExpression() {
 	}
 
-	public CPPASTBinaryExpression(int op, IASTExpression operand1, IASTExpression operand2) {
+	public CPPASTBinaryExpression(int op, IASTExpression operand1, IASTInitializerClause operand2) {
 		this.op = op;
 		setOperand1(operand1);
-		setOperand2(operand2);
+		setInitOperand2(operand2);
 	}
 
 	public CPPASTBinaryExpression copy() {
 		CPPASTBinaryExpression copy = new CPPASTBinaryExpression();
 		copy.op = op;
 		copy.setOperand1(operand1 == null ? null : operand1.copy());
-		copy.setOperand2(operand2 == null ? null : operand2.copy());
+		copy.setInitOperand2(operand2 == null ? null : operand2.copy());
 		copy.setOffsetAndLength(this);
 		return copy;
 	}
@@ -69,8 +70,14 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
         return operand1;
     }
 
+    public IASTInitializerClause getInitOperand2() {
+    	return operand2;
+    }
+
     public IASTExpression getOperand2() {
-        return operand2;
+    	if (operand2 instanceof IASTExpression)
+    		return (IASTExpression) operand2;
+    	return null;
     }
 
     public void setOperator(int op) {
@@ -87,15 +94,19 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
 		}
     }
 
-    public void setOperand2(IASTExpression expression) {
+    public void setInitOperand2(IASTInitializerClause operand) {
         assertNotFrozen();
-        operand2 = expression;
-        if (expression != null) {
-			expression.setParent(this);
-			expression.setPropertyInParent(OPERAND_TWO);
+        operand2 = operand;
+        if (operand != null) {
+        	operand.setParent(this);
+        	operand.setPropertyInParent(OPERAND_TWO);
 		}
     }
 
+    public void setOperand2(IASTExpression expression) {
+    	setInitOperand2(expression);
+    }
+
 	public IASTImplicitName[] getImplicitNames() {
 		if(implicitNames == null) {
 			ICPPFunction overload = getOverload();
@@ -219,7 +230,7 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
 		if (child == operand2) {
 			other.setPropertyInParent(child.getPropertyInParent());
 			other.setParent(child.getParent());
-			operand2 = (IASTExpression) other;
+			operand2 = (IASTInitializerClause) other;
 		}
 	}
 
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorChainInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorChainInitializer.java
index f595db5c936..62c9d27605c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorChainInitializer.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorChainInitializer.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -16,18 +16,19 @@ import java.util.Arrays;
 import org.eclipse.cdt.core.dom.ast.ASTVisitor;
 import org.eclipse.cdt.core.dom.ast.IASTCompletionContext;
 import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializer;
 import org.eclipse.cdt.core.dom.ast.IASTName;
 import org.eclipse.cdt.core.dom.ast.IASTNode;
 import org.eclipse.cdt.core.dom.ast.IBinding;
 import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
 import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
 import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
 import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
 import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
 import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
 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.IASTAmbiguityParent;
 import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
 
 /**
@@ -39,25 +40,25 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
  * {@code Base()} and {@code field()} are the constructor chain initializers.
*/ public class CPPASTConstructorChainInitializer extends ASTNode implements - ICPPASTConstructorChainInitializer, IASTAmbiguityParent, IASTCompletionContext { + ICPPASTConstructorChainInitializer, IASTCompletionContext { private IASTName name; - private IASTExpression value; + private IASTInitializer initializer; private boolean fIsPackExpansion; public CPPASTConstructorChainInitializer() { } - public CPPASTConstructorChainInitializer(IASTName memberInitializerid, IASTExpression initializerValue) { - setMemberInitializerId(memberInitializerid); - setInitializerValue(initializerValue); + public CPPASTConstructorChainInitializer(IASTName id, IASTInitializer initializer) { + setMemberInitializerId(id); + setInitializer(initializer); } public CPPASTConstructorChainInitializer copy() { CPPASTConstructorChainInitializer copy = new CPPASTConstructorChainInitializer(); copy.setMemberInitializerId(name == null ? null : name.copy()); - copy.setInitializerValue(value == null ? null : value.copy()); + copy.setInitializer(initializer == null ? null : initializer.copy()); copy.setOffsetAndLength(this); copy.fIsPackExpansion= fIsPackExpansion; return copy; @@ -76,17 +77,16 @@ public class CPPASTConstructorChainInitializer extends ASTNode implements } } - public IASTExpression getInitializerValue() { - return value; + public IASTInitializer getInitializer() { + return initializer; } - - public void setInitializerValue(IASTExpression expression) { + public void setInitializer(IASTInitializer init) { assertNotFrozen(); - value = expression; - if(expression != null) { - expression.setParent(this); - expression.setPropertyInParent(INITIALIZER); + initializer = init; + if(init != null) { + init.setParent(this); + init.setPropertyInParent(INITIALIZER); } } @@ -100,17 +100,15 @@ public class CPPASTConstructorChainInitializer extends ASTNode implements return true; } } - if (name != null) - if (!name.accept(action)) - return false; - if (value != null) - if (!value.accept(action)) - return false; + if (name != null && !name.accept(action)) + return false; - if (action.shouldVisitInitializers) { - if (action.leave(this) == ASTVisitor.PROCESS_ABORT) - return false; - } + if (initializer != null && !initializer.accept(action)) + return false; + + if (action.shouldVisitInitializers && action.leave(this) == ASTVisitor.PROCESS_ABORT) + return false; + return true; } @@ -120,21 +118,12 @@ public class CPPASTConstructorChainInitializer extends ASTNode implements return r_unclear; } - public void replace(IASTNode child, IASTNode other) { - if (child == value) { - other.setPropertyInParent(child.getPropertyInParent()); - other.setParent(child.getParent()); - value = (IASTExpression) other; - } - } - public IBinding[] findBindings(IASTName n, boolean isPrefix) { IBinding[] bindings = CPPSemantics.findBindingsForContentAssist(n, isPrefix); ICPPASTBaseSpecifier[] baseClasses = null; for (int i = 0; i < bindings.length; i++) { - if ((bindings[i] instanceof ICPPField) || (bindings[i] instanceof ICPPNamespace)) { continue; } else if (bindings[i] instanceof ICPPConstructor) { @@ -184,4 +173,36 @@ public class CPPASTConstructorChainInitializer extends ASTNode implements assertNotFrozen(); fIsPackExpansion= val; } + + @Deprecated + public IASTExpression getInitializerValue() { + if (initializer == null || initializer instanceof IASTExpression) { + return (IASTExpression) initializer; + } + if (initializer instanceof ICPPASTConstructorInitializer) { + IASTExpression expr= ((ICPPASTConstructorInitializer) initializer).getExpression(); + if (expr != null) { + expr= expr.copy(); + expr.setParent(this); + expr.setPropertyInParent(INITIALIZER); + } + return expr; + } + return null; + } + + @Deprecated + public void setInitializerValue(IASTExpression expression) { + assertNotFrozen(); + if (expression == null) { + setInitializer(null); + } else if (expression instanceof IASTInitializer) { + setInitializer((IASTInitializer) expression); + } else { + CPPASTConstructorInitializer ctorInit= new CPPASTConstructorInitializer(); + ctorInit.setExpression(expression); + ctorInit.setOffsetAndLength((ASTNode) expression); + setInitializer(ctorInit); + } + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorInitializer.java index acc4f311e31..46730475857 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorInitializer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorInitializer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -13,45 +13,56 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTExpression; +import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpressionList; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; /** - * Initializer in parenthesis. + * Initializer list in parenthesis. */ -public class CPPASTConstructorInitializer extends ASTNode implements - ICPPASTConstructorInitializer, IASTAmbiguityParent { - - private IASTExpression exp; - private boolean fIsPackExpansion; +public class CPPASTConstructorInitializer extends ASTNode implements ICPPASTConstructorInitializer, + IASTAmbiguityParent { + private IASTInitializerClause[] fArguments; public CPPASTConstructorInitializer() { + setArguments(null); } - public CPPASTConstructorInitializer(IASTExpression exp) { - setExpression(exp); + public CPPASTConstructorInitializer(IASTInitializerClause[] args) { + setArguments(args); } public CPPASTConstructorInitializer copy() { - CPPASTConstructorInitializer copy = new CPPASTConstructorInitializer(exp == null ? null : exp.copy()); + IASTInitializerClause[] args = null; + if (fArguments != null) { + args= new IASTExpression[fArguments.length]; + for (int i=0; i 0) { + args= new IASTExpression[fArguments.length]; + for (int i=0; i 0) - if(!implicits[0].accept(action)) return false; + if (implicits != null && implicits.length > 0) + if (!implicits[0].accept(action)) + return false; - if( parameter != null ) if( !parameter.accept( action ) ) return false; - - if(implicits != null && implicits.length > 0) - if(!implicits[1].accept(action)) return false; - - if( action.shouldVisitExpressions ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; - } + for (IASTInitializerClause arg : fArguments) { + if (!arg.accept(action)) + return false; } + + if (implicits != null && implicits.length > 0) + if (!implicits[1].accept(action)) + return false; + + if (action.shouldVisitExpressions && action.leave(this) == ASTVisitor.PROCESS_ABORT) + return false; + return true; } - public void replace(IASTNode child, IASTNode other) { - if( child == functionName ) - { - other.setPropertyInParent( child.getPropertyInParent() ); - other.setParent( child.getParent() ); - functionName = (IASTExpression) other; - } - if( child == parameter ) - { - other.setPropertyInParent( child.getPropertyInParent() ); - other.setParent( child.getParent() ); - parameter = (IASTExpression) other; - } - } + public void replace(IASTNode child, IASTNode other) { + if (child == functionName) { + other.setPropertyInParent(child.getPropertyInParent()); + other.setParent(child.getParent()); + functionName = (IASTExpression) other; + } + for (int i = 0; i < fArguments.length; ++i) { + if (child == fArguments[i]) { + other.setPropertyInParent(child.getPropertyInParent()); + other.setParent(child.getParent()); + fArguments[i] = (IASTExpression) other; + } + } + } public ICPPFunction getOperator() { if (overload == UNINITIALIZED_FUNCTION) { @@ -254,4 +267,38 @@ public class CPPASTFunctionCallExpression extends ASTNode implements } return null; } + + @Deprecated + public IASTExpression getParameterExpression() { + if (fArguments.length == 0) + return null; + if (fArguments.length == 1) { + IASTInitializerClause arg = fArguments[0]; + if (arg instanceof IASTExpression) + return (IASTExpression) arg; + return null; + } + + CPPASTExpressionList result= new CPPASTExpressionList(); + for (IASTInitializerClause arg : fArguments) { + if (arg instanceof IASTExpression) { + result.addExpression(((IASTExpression) arg).copy()); + } + } + result.setParent(this); + result.setPropertyInParent(ARGUMENT); + return result; + } + + @Deprecated + public void setParameterExpression(IASTExpression expression) { + assertNotFrozen(); + if (expression == null) { + setArguments(null); + } else if (expression instanceof ICPPASTExpressionList) { + setArguments(((ICPPASTExpressionList) expression).getExpressions()); + } else { + setArguments(new IASTExpression[] {expression}); + } + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerExpression.java index cd9cf256770..716501b041a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerExpression.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,85 +11,26 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; -import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTExpression; -import org.eclipse.cdt.core.dom.ast.IASTNode; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerExpression; -import org.eclipse.cdt.internal.core.dom.parser.ASTNode; -import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; +import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; +import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression; -/** - * Initializer expression. - */ -public class CPPASTInitializerExpression extends ASTNode implements - ICPPASTInitializerExpression, IASTAmbiguityParent { +@Deprecated +public class CPPASTInitializerExpression extends CPPASTEqualsInitializer implements IASTInitializerExpression { - private IASTExpression exp; - private boolean fIsPackExpansion; - - public CPPASTInitializerExpression() { } - public CPPASTInitializerExpression(IASTExpression exp) { - setExpression(exp); + public CPPASTInitializerExpression(IASTExpression expression) { + setExpression(expression); } + @Override public CPPASTInitializerExpression copy() { - CPPASTInitializerExpression copy = new CPPASTInitializerExpression(exp == null ? null : exp.copy()); + CPPASTInitializerExpression copy= new CPPASTInitializerExpression(); + IASTInitializerClause init= getInitializerClause(); + copy.setInitializerClause(init == null ? null : init.copy()); copy.setOffsetAndLength(this); - copy.fIsPackExpansion= fIsPackExpansion; return copy; } - - public IASTExpression getExpression() { - return exp; - } - - public void setExpression(IASTExpression expression) { - assertNotFrozen(); - this.exp = expression; - if (expression != null) { - expression.setParent(this); - expression.setPropertyInParent(INITIALIZER_EXPRESSION); - } - } - - @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitInitializers ){ - switch( action.visit( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; - } - } - if( exp != null ) if( !exp.accept( action ) ) return false; - - if( action.shouldVisitInitializers ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; - } - } - return true; - } - - public void replace(IASTNode child, IASTNode other) { - if( child == exp ) { - other.setPropertyInParent( child.getPropertyInParent() ); - other.setParent( child.getParent() ); - exp = (IASTExpression) other; - } - } - public boolean isPackExpansion() { - return fIsPackExpansion; - } - - public void setIsPackExpansion(boolean val) { - assertNotFrozen(); - fIsPackExpansion= val; - } - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerList.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerList.java index aaafa5126ac..39d86f66c81 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerList.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerList.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,77 +12,111 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.ASTVisitor; +import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer; +import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTInitializer; +import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; +import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerList; 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.IASTAmbiguityParent; /** * e.g.: int a[]= {1,2,3}; */ -public class CPPASTInitializerList extends ASTNode implements ICPPASTInitializerList { - private IASTInitializer [] initializers = null; +public class CPPASTInitializerList extends ASTNode implements ICPPASTInitializerList, IASTAmbiguityParent { + + private IASTInitializerClause [] initializers = null; private int initializersPos=-1; - private int actualLength; + private int actualSize; private boolean fIsPackExpansion; public CPPASTInitializerList copy() { CPPASTInitializerList copy = new CPPASTInitializerList(); - for(IASTInitializer initializer : getInitializers()) - copy.addInitializer(initializer == null ? null : initializer.copy()); + for (IASTInitializerClause initializer : getClauses()) + copy.addClause(initializer == null ? null : initializer.copy()); copy.setOffsetAndLength(this); - copy.actualLength= getSize(); - copy.fIsPackExpansion= fIsPackExpansion; + copy.actualSize = getSize(); + copy.fIsPackExpansion = fIsPackExpansion; return copy; } public int getSize() { - return actualLength; + return actualSize; } - public IASTInitializer[] getInitializers() { + public IASTInitializerClause[] getClauses() { if (initializers == null) - return IASTInitializer.EMPTY_INITIALIZER_ARRAY; - - initializers = ArrayUtil.trimAt(IASTInitializer.class, initializers, initializersPos); + return IASTExpression.EMPTY_EXPRESSION_ARRAY; + initializers = ArrayUtil.trimAt(IASTInitializerClause.class, initializers, initializersPos); return initializers; } - - public void addInitializer(IASTInitializer d) { - assertNotFrozen(); - if (d != null) { - initializers = (IASTInitializer[]) ArrayUtil.append(IASTInitializer.class, initializers, - ++initializersPos, d); - d.setParent(this); - d.setPropertyInParent(NESTED_INITIALIZER); + + @Deprecated + public IASTInitializer[] getInitializers() { + IASTInitializerClause[] clauses= getClauses(); + if (clauses.length == 0) + return IASTInitializer.EMPTY_INITIALIZER_ARRAY; + + IASTInitializer[] inits= new IASTInitializer[clauses.length]; + for (int i = 0; i < inits.length; i++) { + IASTInitializerClause clause= clauses[i]; + if (clause instanceof IASTInitializer) { + inits[i]= (IASTInitializer) clause; + } else if (clause instanceof IASTExpression) { + final CPPASTEqualsInitializer initExpr = new CPPASTEqualsInitializer(((IASTExpression) clause).copy()); + initExpr.setParent(this); + initExpr.setPropertyInParent(NESTED_INITIALIZER); + inits[i]= initExpr; + } } - actualLength++; + return inits; } + + public void addClause(IASTInitializerClause d) { + assertNotFrozen(); + if (d != null) { + initializers = (IASTInitializerClause[]) ArrayUtil.append( IASTInitializerClause.class, initializers, ++initializersPos, d ); + d.setParent(this); + d.setPropertyInParent(NESTED_INITIALIZER); + } + actualSize++; + } + + @Deprecated + public void addInitializer(IASTInitializer d) { + assertNotFrozen(); + if (d instanceof IASTInitializerClause) { + addClause((IASTInitializerClause) d); + } else if (d instanceof IASTEqualsInitializer) { + addClause(((IASTEqualsInitializer) d).getInitializerClause()); + } else { + addClause(null); + } + } @Override public boolean accept( ASTVisitor action ){ - if( action.shouldVisitInitializers ){ - switch( action.visit( this ) ){ + if (action.shouldVisitInitializers) { + switch (action.visit(this)) { case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_SKIP : return true; default : break; } } - IASTInitializer [] list = getInitializers(); - for ( int i = 0; i < list.length; i++ ) { - if( !list[i].accept( action ) ) return false; - } + IASTInitializerClause[] list = getClauses(); + for (IASTInitializerClause clause : list) { + if (!clause.accept(action)) + return false; + } - if( action.shouldVisitInitializers ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; - } - } - return true; + if (action.shouldVisitInitializers && action.leave(this) == ASTVisitor.PROCESS_ABORT) + return false; + + return true; } - + public boolean isPackExpansion() { return fIsPackExpansion; } @@ -91,5 +125,16 @@ public class CPPASTInitializerList extends ASTNode implements ICPPASTInitializer assertNotFrozen(); fIsPackExpansion= val; } - + + public void replace(IASTNode child, IASTNode other) { + if (initializers != null) { + for (int i = 0; i < initializers.length; ++i) { + if (child == initializers[i]) { + other.setPropertyInParent(child.getPropertyInParent()); + other.setParent(child.getParent()); + initializers[i] = (IASTInitializerClause) other; + } + } + } + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNewExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNewExpression.java index 5d8d2493a7b..c829f575af5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNewExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNewExpression.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,92 +17,92 @@ import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator; import org.eclipse.cdt.core.dom.ast.IASTArrayModifier; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTExpression; +import org.eclipse.cdt.core.dom.ast.IASTExpressionList; import org.eclipse.cdt.core.dom.ast.IASTImplicitName; +import org.eclipse.cdt.core.dom.ast.IASTInitializer; +import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTPointerOperator; import org.eclipse.cdt.core.dom.ast.IASTTypeId; import org.eclipse.cdt.core.dom.ast.IArrayType; import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTQueries; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; +import org.eclipse.cdt.internal.core.dom.parser.c.CASTExpressionList; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.core.runtime.Assert; -public class CPPASTNewExpression extends ASTNode implements - ICPPASTNewExpression, IASTAmbiguityParent { - - private boolean global; - private IASTExpression placement; - private IASTExpression initializer; +public class CPPASTNewExpression extends ASTNode implements ICPPASTNewExpression, IASTAmbiguityParent { + private IASTInitializerClause[] placement; private IASTTypeId typeId; - private boolean isNewTypeId; - - private IASTExpression [] arrayExpressions = null; - + private IASTInitializer initializer; private IASTImplicitName[] implicitNames = null; - + private boolean isGlobal; + private boolean isNewTypeId; + + private IASTExpression[] cachedArraySizes; public CPPASTNewExpression() { } - public CPPASTNewExpression(IASTExpression placement, - IASTExpression initializer, IASTTypeId typeId) { - setNewPlacement(placement); - setNewInitializer(initializer); + public CPPASTNewExpression(IASTInitializerClause[] placement, IASTInitializer initializer, IASTTypeId typeId) { + setPlacementArguments(placement); setTypeId(typeId); + setInitializer(initializer); } public CPPASTNewExpression copy() { CPPASTNewExpression copy = new CPPASTNewExpression(); - copy.setIsGlobal(global); + copy.setIsGlobal(isGlobal); copy.setIsNewTypeId(isNewTypeId); - copy.setNewPlacement(placement == null ? null : placement.copy()); - copy.setNewInitializer(initializer == null ? null : initializer.copy()); - copy.setTypeId(typeId == null ? null : typeId.copy()); - - if(arrayExpressions != null) { - copy.arrayExpressions = new IASTExpression[arrayExpressions.length]; - for(int i = 0; i < arrayExpressions.length; i++) { - copy.arrayExpressions[i] = arrayExpressions[i] == null ? null : arrayExpressions[i].copy(); + if (placement != null) { + IASTInitializerClause[] plcmt = new IASTInitializerClause[placement.length]; + for (int i=0; i filtered = filterClassScopeBindings(classType, bindings, isDeclaration); - if (isDeclaration && nameMatches(classType.getNameCharArray(), - n.getLookupKey(), isPrefix)) { - try { - ICPPConstructor[] constructors = classType.getConstructors(); - for (int i = 0; i < constructors.length; i++) { - if (!constructors[i].isImplicit()) { - filtered.add(constructors[i]); - } + final boolean isDeclaration = getParent().getParent() instanceof IASTSimpleDeclaration; + List filtered = filterClassScopeBindings(classType, bindings, isDeclaration); + if (isDeclaration && nameMatches(classType.getNameCharArray(), + n.getLookupKey(), isPrefix)) { + try { + ICPPConstructor[] constructors = classType.getConstructors(); + for (int i = 0; i < constructors.length; i++) { + if (!constructors[i].isImplicit()) { + filtered.add(constructors[i]); } - } catch (DOMException e) { } + } catch (DOMException e) { } - return filtered.toArray(new IBinding[filtered.size()]); } + return filtered.toArray(new IBinding[filtered.size()]); } } @@ -301,22 +300,24 @@ public class CPPASTQualifiedName extends CPPASTNameBase private List filterClassScopeBindings(ICPPClassType classType, IBinding[] bindings, final boolean isDeclaration) { List filtered = new ArrayList(); - + final boolean canBeFieldAccess= canBeFieldAccess(classType); + try { for (final IBinding binding : bindings) { if (binding instanceof IField) { IField field = (IField) binding; - if (!field.isStatic()) + if (!canBeFieldAccess && !field.isStatic()) continue; } else if (binding instanceof ICPPMethod) { ICPPMethod method = (ICPPMethod) binding; if (method.isImplicit()) continue; if (!isDeclaration) { - if (method.isDestructor() || method instanceof ICPPConstructor || !method.isStatic()) + if (method.isDestructor() || method instanceof ICPPConstructor + || (!canBeFieldAccess && !method.isStatic())) continue; } - } else if (binding instanceof IEnumerator || binding instanceof IEnumerator) { + } else if (binding instanceof IEnumerator || binding instanceof IEnumeration) { if (isDeclaration) continue; } else if (binding instanceof IType) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReturnStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReturnStatement.java index 9a1721fe63b..36bea044360 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReturnStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReturnStatement.java @@ -1,34 +1,33 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation + * John Camelon (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTExpression; +import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTReturnStatement; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; -/** - * @author jcamelon - */ public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatement, IASTAmbiguityParent { - private IASTExpression retValue; + private IASTInitializerClause retValue; public CPPASTReturnStatement() { } - public CPPASTReturnStatement(IASTExpression retValue) { - setReturnValue(retValue); + public CPPASTReturnStatement(IASTInitializerClause retValue) { + setReturnArgument(retValue); } public CPPASTReturnStatement copy() { @@ -37,16 +36,28 @@ public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatemen return copy; } + public IASTInitializerClause getReturnArgument() { + return retValue; + } + public IASTExpression getReturnValue() { - return retValue; + if (retValue instanceof IASTExpression) { + return (IASTExpression) retValue; + } + return null; } + public void setReturnValue(IASTExpression returnValue) { + setReturnArgument(returnValue); + } + + public void setReturnArgument(IASTInitializerClause arg) { assertNotFrozen(); - retValue = returnValue; - if (returnValue != null) { - returnValue.setParent(this); - returnValue.setPropertyInParent(RETURNVALUE); + retValue = arg; + if (arg != null) { + arg.setParent(this); + arg.setPropertyInParent(RETURNVALUE); } } @@ -62,9 +73,8 @@ public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatemen break; } } - if (retValue != null) - if (!retValue.accept(action)) - return false; + if (retValue != null && !retValue.accept(action)) + return false; if( action.shouldVisitStatements ){ switch( action.leave( this ) ){ @@ -80,7 +90,7 @@ public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatemen if (child == retValue) { other.setPropertyInParent(child.getPropertyInParent()); other.setParent(child.getParent()); - retValue = (IASTExpression) other; + retValue = (IASTInitializerClause) other; } } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeConstructorExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeConstructorExpression.java index 611ed09ce1a..b477eb1c8f4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeConstructorExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeConstructorExpression.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -13,56 +13,76 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTExpression; -import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.core.dom.ast.IASTInitializer; import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.IBasicType.Kind; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; -import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; public class CPPASTSimpleTypeConstructorExpression extends ASTNode implements - ICPPASTSimpleTypeConstructorExpression, IASTAmbiguityParent { + ICPPASTSimpleTypeConstructorExpression { - private int st; - private IASTExpression init; + private ICPPASTDeclSpecifier fDeclSpec; + private IASTInitializer fInitializer; + private IType fType; public CPPASTSimpleTypeConstructorExpression() { } - public CPPASTSimpleTypeConstructorExpression(int st, IASTExpression init) { - this.st = st; - setInitialValue(init); + public CPPASTSimpleTypeConstructorExpression(ICPPASTDeclSpecifier declSpec, IASTInitializer init) { + setDeclSpecifier(declSpec); + setInitializer(init); } public CPPASTSimpleTypeConstructorExpression copy() { CPPASTSimpleTypeConstructorExpression copy = new CPPASTSimpleTypeConstructorExpression(); - copy.st = st; - copy.setInitialValue(init == null ? null : init.copy()); + copy.setDeclSpecifier(fDeclSpec == null ? null : fDeclSpec.copy()); + copy.setInitializer(fInitializer == null ? null : fInitializer.copy()); copy.setOffsetAndLength(this); return copy; } - public int getSimpleType() { - return st; + public ICPPASTDeclSpecifier getDeclSpecifier() { + return fDeclSpec; + } + + public IASTInitializer getInitializer() { + return fInitializer; + } + + public void setDeclSpecifier(ICPPASTDeclSpecifier declSpec) { + assertNotFrozen(); + fDeclSpec = declSpec; + if (declSpec != null) { + declSpec.setParent(this); + declSpec.setPropertyInParent(TYPE_SPECIFIER); + } } - public void setSimpleType(int value) { - assertNotFrozen(); - st = value; + public void setInitializer(IASTInitializer initializer) { + assertNotFrozen(); + fInitializer = initializer; + if (initializer != null) { + initializer.setParent(this); + initializer.setPropertyInParent(INITIALIZER); + } } - public IASTExpression getInitialValue() { - return init; - } - - public void setInitialValue(IASTExpression expression) { - assertNotFrozen(); - init = expression; - if (expression != null) { - expression.setParent(this); - expression.setPropertyInParent(INITIALIZER_VALUE); + public IType getExpressionType() { + if (fType == null) { + fType= CPPVisitor.createType(fDeclSpec); } - } + return fType; + } + public boolean isLValue() { + return false; + } + @Override public boolean accept( ASTVisitor action ){ if( action.shouldVisitExpressions ){ @@ -72,8 +92,12 @@ public class CPPASTSimpleTypeConstructorExpression extends ASTNode implements default : break; } } - - if( init != null ) if( !init.accept( action ) ) return false; + + if (fDeclSpec != null && !fDeclSpec.accept(action)) + return false; + + if (fInitializer != null && !fInitializer.accept(action)) + return false; if( action.shouldVisitExpressions ){ switch( action.leave( this ) ){ @@ -85,20 +109,102 @@ public class CPPASTSimpleTypeConstructorExpression extends ASTNode implements return true; } - public void replace(IASTNode child, IASTNode other) { - if( child == init ) - { - other.setPropertyInParent( child.getPropertyInParent() ); - other.setParent( child.getParent() ); - init = (IASTExpression) other; - } + @Deprecated + public int getSimpleType() { + IType type= getExpressionType(); + if (type instanceof ICPPBasicType) { + ICPPBasicType bt= (ICPPBasicType) type; + Kind kind = bt.getKind(); + switch(kind) { + case eBoolean: + return t_bool; + case eChar: + return t_char; + case eDouble: + return t_double; + case eFloat: + return t_float; + case eInt: + if (bt.isShort()) + return t_short; + if (bt.isLong()) + return t_long; + if (bt.isSigned()) + return t_signed; + if (bt.isUnsigned()) + return t_unsigned; + return t_int; + case eVoid: + return t_void; + case eWChar: + return t_wchar_t; + default: + break; + } + } + return t_unspecified; } - public IType getExpressionType() { - return new CPPBasicType(CPPBasicType.getKind(st), 0); + @Deprecated + public void setSimpleType(int value) { + CPPASTSimpleDeclSpecifier declspec = new CPPASTSimpleDeclSpecifier(); + switch(value) { + case t_bool: + declspec.setType(Kind.eBoolean); + break; + case t_char: + declspec.setType(Kind.eChar); + break; + case t_double: + declspec.setType(Kind.eDouble); + break; + case t_float: + declspec.setType(Kind.eFloat); + break; + case t_int: + declspec.setType(Kind.eInt); + break; + case t_long: + declspec.setType(Kind.eInt); + declspec.setLong(true); + break; + case t_short: + declspec.setType(Kind.eInt); + declspec.setShort(true); + break; + case t_signed: + declspec.setType(Kind.eInt); + declspec.setSigned(true); + break; + case t_unsigned: + declspec.setType(Kind.eInt); + declspec.setUnsigned(true); + break; + case t_void: + declspec.setType(Kind.eVoid); + break; + case t_wchar_t: + declspec.setType(Kind.eWChar); + break; + default: + declspec.setType(Kind.eUnspecified); + break; + } + setDeclSpecifier(declspec); + } + + @Deprecated + public IASTExpression getInitialValue() { + if (fInitializer instanceof ICPPASTConstructorInitializer) { + return ((ICPPASTConstructorInitializer) fInitializer).getExpression(); + } + return null; + } + + @Deprecated + public void setInitialValue(IASTExpression expression) { + ICPPASTConstructorInitializer init= new CPPASTConstructorInitializer(); + init.setExpression(expression); + setInitializer(init); } - - public boolean isLValue() { - return false; - } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypenameExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypenameExpression.java index 625464d0de3..39030d0c3b0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypenameExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypenameExpression.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,130 +11,63 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; -import org.eclipse.cdt.core.dom.ast.ASTVisitor; +import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTExpression; +import org.eclipse.cdt.core.dom.ast.IASTInitializer; import org.eclipse.cdt.core.dom.ast.IASTName; -import org.eclipse.cdt.core.dom.ast.IASTNode; -import org.eclipse.cdt.core.dom.ast.IBinding; -import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression; -import org.eclipse.cdt.internal.core.dom.parser.ASTNode; -import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; -public class CPPASTTypenameExpression extends ASTNode implements - ICPPASTTypenameExpression, IASTAmbiguityParent { +@Deprecated +public class CPPASTTypenameExpression extends CPPASTSimpleTypeConstructorExpression implements ICPPASTTypenameExpression { - private boolean isTemplate; - private IASTName name; - private IASTExpression init; - - public CPPASTTypenameExpression() { } - public CPPASTTypenameExpression(IASTName name, IASTExpression init) { - this(name, init, false); - } - - public CPPASTTypenameExpression(IASTName name, IASTExpression init, boolean isTemplate) { + public CPPASTTypenameExpression(IASTName name, IASTExpression expr) { setName(name); - setInitialValue(init); - this.isTemplate = isTemplate; + setInitialValue(expr); } + @Override public CPPASTTypenameExpression copy() { + super.copy(); CPPASTTypenameExpression copy = new CPPASTTypenameExpression(); - copy.setName(name == null ? null : name.copy()); - copy.setInitialValue(init == null ? null : init.copy()); - copy.isTemplate = isTemplate; + ICPPASTDeclSpecifier declSpec = getDeclSpecifier(); + IASTInitializer init = getInitializer(); + copy.setDeclSpecifier(declSpec == null ? null : declSpec.copy()); + copy.setInitializer(init == null ? null : init.copy()); copy.setOffsetAndLength(this); return copy; } - - public void setIsTemplate(boolean templateTokenConsumed) { - assertNotFrozen(); - isTemplate = templateTokenConsumed; - } - - public boolean isTemplate() { - return isTemplate; - } - public void setName(IASTName name) { - assertNotFrozen(); - this.name = name; - if (name != null) { - name.setParent(this); - name.setPropertyInParent(TYPENAME); - } + CPPASTNamedTypeSpecifier spec= new CPPASTNamedTypeSpecifier(name); + spec.setOffsetAndLength(this); + setDeclSpecifier(spec); } public IASTName getName() { - return name; + IASTDeclSpecifier spec= getDeclSpecifier(); + if (spec instanceof ICPPASTNamedTypeSpecifier) { + return ((ICPPASTNamedTypeSpecifier) spec).getName(); + } + return null; } - public void setInitialValue(IASTExpression expressionList) { - assertNotFrozen(); - init = expressionList; - if (expressionList != null) { - expressionList.setParent(this); - expressionList.setPropertyInParent(INITIAL_VALUE); - } - } - - public IASTExpression getInitialValue() { - return init; - } - - @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitExpressions ){ - switch( action.visit( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; - } - } - - if( name != null ) if( !name.accept( action ) ) return false; - if( init != null ) if( !init.accept( action ) ) return false; - - if( action.shouldVisitExpressions ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; - } - } - return true; - } - public int getRoleForName(IASTName n) { - if( n == name ) + if (n == getName()) return r_reference; return r_unclear; } - public void replace(IASTNode child, IASTNode other) { - if( child == init ) - { - other.setPropertyInParent( child.getPropertyInParent() ); - other.setParent( child.getParent() ); - init = (IASTExpression) other; - } - - } - - public IType getExpressionType() { - IBinding binding = getName().resolvePreBinding(); - if (binding instanceof IType) { - return (IType) binding; - } - return null; + @Deprecated + public void setIsTemplate(boolean val) { } - public boolean isLValue() { - return false; - } + @Deprecated + public boolean isTemplate() { + return false; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java index 5013a720675..85c5e4d0b7d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java @@ -25,12 +25,14 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTDefaultStatement; import org.eclipse.cdt.core.dom.ast.IASTDoStatement; import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier; +import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement; import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.IASTGotoStatement; import org.eclipse.cdt.core.dom.ast.IASTIdExpression; import org.eclipse.cdt.core.dom.ast.IASTInitializer; +import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; import org.eclipse.cdt.core.dom.ast.IASTLabelStatement; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNullStatement; @@ -55,6 +57,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclarator; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier; @@ -68,7 +71,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionWithTryBlock; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTIfStatement; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerList; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression; @@ -95,7 +97,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTryBlockStatement; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeId; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeIdExpression; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective; @@ -121,32 +122,302 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory { return DEFAULT_INSTANCE; } - public ICPPASTTranslationUnit newTranslationUnit() { - return newTranslationUnit(null); + public ICPPASTArrayDeclarator newArrayDeclarator(IASTName name) { + return new CPPASTArrayDeclarator(name); } - public ICPPASTTranslationUnit newTranslationUnit(IScanner scanner) { - CPPASTTranslationUnit tu = new CPPASTTranslationUnit(); - - if (scanner != null) { - tu.setLocationResolver(scanner.getLocationResolver()); - } - tu.setASTNodeFactory(this); - return tu; + public IASTArrayModifier newArrayModifier(IASTExpression expr) { + return new CPPASTArrayModifier(expr); } - public IASTName newName(char[] name) { - return new CPPASTName(name); + public ICPPASTArraySubscriptExpression newArraySubscriptExpression(IASTExpression arrayExpr, IASTExpression subscript) { + return new CPPASTArraySubscriptExpression(arrayExpr, subscript); } + public ICPPASTArraySubscriptExpression newArraySubscriptExpression(IASTExpression arrayExpr, + IASTInitializerClause subscript) { + return new CPPASTArraySubscriptExpression(arrayExpr, subscript); + } + + public IASTASMDeclaration newASMDeclaration(String assembly) { + return new CPPASTASMDeclaration(assembly); + } + + public ICPPASTBaseSpecifier newBaseSpecifier(IASTName name, int visibility, boolean isVirtual) { + return new CPPASTBaseSpecifier(name, visibility, isVirtual); + } + + public ICPPASTBinaryExpression newBinaryExpression(int op, IASTExpression expr1, IASTExpression expr2) { + return new CPPASTBinaryExpression(op, expr1, expr2); + } + + public ICPPASTBinaryExpression newBinaryExpression(int op, IASTExpression expr1, IASTInitializerClause expr2) { + return new CPPASTBinaryExpression(op, expr1, expr2); + } + + public IASTBreakStatement newBreakStatement() { + return new CPPASTBreakStatement(); + } + + public IASTCaseStatement newCaseStatement(IASTExpression expr) { + return new CPPASTCaseStatement(expr); + } + + public ICPPASTCastExpression newCastExpression(int operator, IASTTypeId typeId, IASTExpression operand) { + return new CPPASTCastExpression(operator, typeId, operand); + } + + public ICPPASTCatchHandler newCatchHandler(IASTDeclaration decl, IASTStatement body) { + return new CPPASTCatchHandler(decl, body); + } + + public ICPPASTCompositeTypeSpecifier newCompositeTypeSpecifier(int key, IASTName name) { + return new CPPASTCompositeTypeSpecifier(key, name); + } + + public IASTCompoundStatement newCompoundStatement() { + return new CPPASTCompoundStatement(); + } + + public IASTConditionalExpression newConditionalExpession(IASTExpression expr1, IASTExpression expr2, IASTExpression expr3) { + return new CPPASTConditionalExpression(expr1, expr2, expr3); + } + + @Deprecated + public ICPPASTConstructorChainInitializer newConstructorChainInitializer(IASTName id, IASTExpression expression) { + ICPPASTConstructorChainInitializer result= new CPPASTConstructorChainInitializer(id, null); + result.setInitializerValue(expression); + return result; + } + + public ICPPASTConstructorChainInitializer newConstructorChainInitializer(IASTName id, IASTInitializer init) { + return new CPPASTConstructorChainInitializer(id, init); + } + + @Deprecated + public ICPPASTConstructorInitializer newConstructorInitializer(IASTExpression exp) { + ICPPASTConstructorInitializer result= new CPPASTConstructorInitializer(null); + result.setExpression(exp); + return result; + } + + public ICPPASTConstructorInitializer newConstructorInitializer(IASTInitializerClause[] args) { + return new CPPASTConstructorInitializer(args); + } + + public IASTContinueStatement newContinueStatement() { + return new CPPASTContinueStatement(); + } + + public ICPPASTConversionName newConversionName(IASTTypeId typeId) { + return new CPPASTConversionName(typeId); + } + + public IASTDeclarationStatement newDeclarationStatement(IASTDeclaration declaration) { + return new CPPASTDeclarationStatement(declaration); + } + + public ICPPASTDeclarator newDeclarator(IASTName name) { + return new CPPASTDeclarator(name); + } + + public IASTDefaultStatement newDefaultStatement() { + return new CPPASTDefaultStatement(); + } + + public ICPPASTDeleteExpression newDeleteExpression(IASTExpression operand) { + return new CPPASTDeleteExpression(operand); + } + + public IASTDoStatement newDoStatement(IASTStatement body, IASTExpression condition) { + return new CPPASTDoStatement(body, condition); + } + + public ICPPASTElaboratedTypeSpecifier newElaboratedTypeSpecifier(int kind, IASTName name) { + return new CPPASTElaboratedTypeSpecifier(kind, name); + } + + public IASTEnumerationSpecifier newEnumerationSpecifier(IASTName name) { + return new CPPASTEnumerationSpecifier(name); + } + + public IASTEnumerator newEnumerator(IASTName name, IASTExpression value) { + return new CPPASTEnumerator(name, value); + } + + public IASTEqualsInitializer newEqualsInitializer(IASTInitializerClause initClause) { + return new CPPASTEqualsInitializer(initClause); + } + + public ICPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiation(IASTDeclaration declaration) { + return new CPPASTExplicitTemplateInstantiation(declaration); + } + + @Deprecated + public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiationGPP(IASTDeclaration declaration) { + return new GPPASTExplicitTemplateInstantiation(declaration); + } + + public ICPPASTExpressionList newExpressionList() { + return new CPPASTExpressionList(); + } + + public IASTExpressionStatement newExpressionStatement(IASTExpression expression) { + return new CPPASTExpressionStatement(expression); + } + + public ICPPASTFieldDeclarator newFieldDeclarator(IASTName name, IASTExpression bitFieldSize) { + return new CPPASTFieldDeclarator(name, bitFieldSize); + } + + public ICPPASTFieldReference newFieldReference(IASTName name, IASTExpression owner) { + return new CPPASTFieldReference(name, owner); + } + + public ICPPASTForStatement newForStatement() { + return new CPPASTForStatement(); + } + + public ICPPASTForStatement newForStatement(IASTStatement init, IASTDeclaration condition, + IASTExpression iterationExpression, IASTStatement body) { + return new CPPASTForStatement(init, condition, iterationExpression, body); + } + + public ICPPASTForStatement newForStatement(IASTStatement init, IASTExpression condition, + IASTExpression iterationExpr, IASTStatement body) { + return new CPPASTForStatement(init, condition, iterationExpr, body); + } + + @Deprecated + public ICPPASTFunctionCallExpression newFunctionCallExpression(IASTExpression idExpr, IASTExpression argList) { + CPPASTFunctionCallExpression result = new CPPASTFunctionCallExpression(idExpr, null); + result.setParameterExpression(argList); + return result; + } + + public ICPPASTFunctionCallExpression newFunctionCallExpression(IASTExpression idExpr, IASTInitializerClause[] arguments) { + return new CPPASTFunctionCallExpression(idExpr, arguments); + } + + public ICPPASTFunctionDeclarator newFunctionDeclarator(IASTName name) { + return new CPPASTFunctionDeclarator(name); + } + + public ICPPASTFunctionDefinition newFunctionDefinition(IASTDeclSpecifier declSpecifier, IASTFunctionDeclarator declarator, + IASTStatement bodyStatement) { + return new CPPASTFunctionDefinition(declSpecifier, declarator, bodyStatement); + } + + public ICPPASTFunctionWithTryBlock newFunctionTryBlock(IASTDeclSpecifier declSpecifier, IASTFunctionDeclarator declarator, + IASTStatement bodyStatement) { + return new CPPASTFunctionWithTryBlock(declSpecifier, declarator, bodyStatement); + } + + public IGNUASTCompoundStatementExpression newGNUCompoundStatementExpression(IASTCompoundStatement compoundStatement) { + return new CPPASTCompoundStatementExpression(compoundStatement); + } + + public IASTGotoStatement newGotoStatement(IASTName name) { + return new CPPASTGotoStatement(name); + } + + public IASTIdExpression newIdExpression(IASTName name) { + return new CPPASTIdExpression(name); + } + + public ICPPASTIfStatement newIfStatement() { + return new CPPASTIfStatement(); + } + + public ICPPASTIfStatement newIfStatement(IASTDeclaration condition, IASTStatement then, IASTStatement elseClause) { + return new CPPASTIfStatement(condition, then, elseClause); + } + + public ICPPASTIfStatement newIfStatement(IASTExpression condition, IASTStatement then, IASTStatement elseClause) { + return new CPPASTIfStatement(condition, then, elseClause); + } + + @Deprecated + public org.eclipse.cdt.core.dom.ast.IASTInitializerExpression newInitializerExpression(IASTExpression expression) { + return new CPPASTInitializerExpression(expression); + } + + public ICPPASTInitializerList newInitializerList() { + return new CPPASTInitializerList(); + } + + public IASTLabelStatement newLabelStatement(IASTName name, IASTStatement nestedStatement) { + return new CPPASTLabelStatement(name, nestedStatement); + } + + public ICPPASTLinkageSpecification newLinkageSpecification(String literal) { + return new CPPASTLinkageSpecification(literal); + } + + public ICPPASTLiteralExpression newLiteralExpression(int kind, String rep) { + return new CPPASTLiteralExpression(kind, rep.toCharArray()); + } + public IASTName newName() { return new CPPASTName(); } + public IASTName newName(char[] name) { + return new CPPASTName(name); + } + + public ICPPASTNamespaceAlias newNamespaceAlias(IASTName alias, IASTName qualifiedName) { + return new CPPASTNamespaceAlias(alias, qualifiedName); + } + + public ICPPASTNamespaceDefinition newNamespaceDefinition(IASTName name) { + return new CPPASTNamespaceDefinition(name); + } + + @Deprecated + public ICPPASTNewExpression newNewExpression(IASTExpression placement, IASTExpression initializer, IASTTypeId typeId) { + final ICPPASTNewExpression result = new CPPASTNewExpression(null, null, typeId); + result.setNewPlacement(placement); + result.setNewInitializer(initializer); + return result; + } + + public ICPPASTNewExpression newNewExpression(IASTInitializerClause[] placement, IASTInitializer initializer, IASTTypeId typeId) { + return new CPPASTNewExpression(placement, initializer, typeId); + } + + public IASTNullStatement newNullStatement() { + return new CPPASTNullStatement(); + } + public ICPPASTOperatorName newOperatorName(char[] name) { return new CPPASTOperatorName(name); } + public ICPPASTPackExpansionExpression newPackExpansionExpression(IASTExpression pattern) { + return new CPPASTPackExpansionExpression(pattern); + } + + public ICPPASTParameterDeclaration newParameterDeclaration(IASTDeclSpecifier declSpec, IASTDeclarator declarator) { + return new CPPASTParameterDeclaration(declSpec, declarator); + } + + public IASTPointer newPointer() { + return new CPPASTPointer(); + } + + public IGPPASTPointer newPointerGPP() { + return new GPPASTPointer(); + } + + public ICPPASTPointerToMember newPointerToMember(IASTName name) { + return new CPPASTPointerToMember(name); + } + + public IGPPASTPointerToMember newPointerToMemberGPP(IASTName name) { + return new GPPASTPointerToMember(name); + } + public IASTProblem newProblem(int id, char[] arg, boolean error) { return new CPPASTProblem(id, arg, error); } @@ -163,215 +434,134 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory { return new CPPASTProblemStatement(problem); } - public ICPPASTLiteralExpression newLiteralExpression(int kind, String rep) { - return new CPPASTLiteralExpression(kind, rep.toCharArray()); - } - - public ICPPASTUnaryExpression newUnaryExpression(int operator, IASTExpression operand) { - return new CPPASTUnaryExpression(operator, operand); - } - - public IASTIdExpression newIdExpression(IASTName name) { - return new CPPASTIdExpression(name); - } - - public ICPPASTArraySubscriptExpression newArraySubscriptExpression(IASTExpression arrayExpr, IASTExpression subscript) { - return new CPPASTArraySubscriptExpression(arrayExpr, subscript); - } - - public ICPPASTExpressionList newExpressionList() { - return new CPPASTExpressionList(); - } - - public ICPPASTFunctionCallExpression newFunctionCallExpression(IASTExpression idExpr, IASTExpression argList) { - return new CPPASTFunctionCallExpression(idExpr, argList); - } - - public ICPPASTCastExpression newCastExpression(int operator, IASTTypeId typeId, IASTExpression operand) { - return new CPPASTCastExpression(operator, typeId, operand); - } - - public ICPPASTNewExpression newNewExpression(IASTExpression placement, IASTExpression initializer, IASTTypeId typeId) { - return new CPPASTNewExpression(placement, initializer, typeId); - } - - public ICPPASTBinaryExpression newBinaryExpression(int op, IASTExpression expr1, IASTExpression expr2) { - return new CPPASTBinaryExpression(op, expr1, expr2); - } - - public IASTConditionalExpression newConditionalExpession(IASTExpression expr1, IASTExpression expr2, IASTExpression expr3) { - return new CPPASTConditionalExpression(expr1, expr2, expr3); - } - - public IASTTypeIdInitializerExpression newTypeIdInitializerExpression(IASTTypeId typeId, IASTInitializer initializer) { - return new CPPASTTypeIdInitializerExpression(typeId, initializer); - } - - public ICPPASTFieldReference newFieldReference(IASTName name, IASTExpression owner) { - return new CPPASTFieldReference(name, owner); - } - - public ICPPASTTemplateId newTemplateId(IASTName templateName) { - return new CPPASTTemplateId(templateName); - } - - public ICPPASTConversionName newConversionName(IASTTypeId typeId) { - return new CPPASTConversionName(typeId); + public IASTProblemTypeId newProblemTypeId(IASTProblem problem) { + return new CPPASTProblemTypeId(problem); } public ICPPASTQualifiedName newQualifiedName() { return new CPPASTQualifiedName(); } - public IASTCaseStatement newCaseStatement(IASTExpression expr) { - return new CPPASTCaseStatement(expr); + public ICPPASTReferenceOperator newReferenceOperator() { + return new CPPASTReferenceOperator(false); } - public IASTDefaultStatement newDefaultStatement() { - return new CPPASTDefaultStatement(); - } - - public IASTLabelStatement newLabelStatement(IASTName name, IASTStatement nestedStatement) { - return new CPPASTLabelStatement(name, nestedStatement); - } - - public IASTExpressionStatement newExpressionStatement(IASTExpression expression) { - return new CPPASTExpressionStatement(expression); - } - - public IASTNullStatement newNullStatement() { - return new CPPASTNullStatement(); - } - - public IASTCompoundStatement newCompoundStatement() { - return new CPPASTCompoundStatement(); - } - - public ICPPASTIfStatement newIfStatement(IASTExpression condition, IASTStatement then, IASTStatement elseClause) { - return new CPPASTIfStatement(condition, then, elseClause); - } - - public ICPPASTIfStatement newIfStatement(IASTDeclaration condition, IASTStatement then, IASTStatement elseClause) { - return new CPPASTIfStatement(condition, then, elseClause); - } - - public ICPPASTIfStatement newIfStatement() { - return new CPPASTIfStatement(); - } - - public ICPPASTSwitchStatement newSwitchStatement(IASTExpression controller, IASTStatement body) { - return new CPPASTSwitchStatement(controller, body); - } - - public ICPPASTSwitchStatement newSwitchStatement(IASTDeclaration controller, IASTStatement body) { - return new CPPASTSwitchStatement(controller, body); - } - - public ICPPASTSwitchStatement newSwitchStatement() { - return new CPPASTSwitchStatement(); - } - - public ICPPASTWhileStatement newWhileStatement(IASTDeclaration condition, IASTStatement body) { - return new CPPASTWhileStatement(condition, body); - } - - public ICPPASTWhileStatement newWhileStatement(IASTExpression condition, IASTStatement body) { - return new CPPASTWhileStatement(condition, body); - } - - public ICPPASTWhileStatement newWhileStatement() { - return new CPPASTWhileStatement(); - } - - public IASTDoStatement newDoStatement(IASTStatement body, IASTExpression condition) { - return new CPPASTDoStatement(body, condition); - } - - public IASTBreakStatement newBreakStatement() { - return new CPPASTBreakStatement(); - } - - public IASTContinueStatement newContinueStatement() { - return new CPPASTContinueStatement(); - } - - public IASTGotoStatement newGotoStatement(IASTName name) { - return new CPPASTGotoStatement(name); + public ICPPASTReferenceOperator newReferenceOperator(boolean isRValueReference) { + return new CPPASTReferenceOperator(isRValueReference); } public IASTReturnStatement newReturnStatement(IASTExpression retValue) { return new CPPASTReturnStatement(retValue); } - public ICPPASTForStatement newForStatement(IASTStatement init, IASTExpression condition, - IASTExpression iterationExpr, IASTStatement body) { - return new CPPASTForStatement(init, condition, iterationExpr, body); + public IASTReturnStatement newReturnStatement(IASTInitializerClause retValue) { + return new CPPASTReturnStatement(retValue); } - public ICPPASTForStatement newForStatement(IASTStatement init, IASTDeclaration condition, - IASTExpression iterationExpression, IASTStatement body) { - return new CPPASTForStatement(init, condition, iterationExpression, body); + public IASTSimpleDeclaration newSimpleDeclaration(IASTDeclSpecifier declSpecifier) { + return new CPPASTSimpleDeclaration(declSpecifier); } - public ICPPASTForStatement newForStatement() { - return new CPPASTForStatement(); + public ICPPASTSimpleDeclSpecifier newSimpleDeclSpecifier() { + return new CPPASTSimpleDeclSpecifier(); + } + + @Deprecated + public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier newSimpleDeclSpecifierGPP() { + return new GPPASTSimpleDeclSpecifier(); + } + + @Deprecated + public ICPPASTSimpleTypeConstructorExpression newSimpleTypeConstructorExpression(int type, IASTExpression expression) { + CPPASTSimpleTypeConstructorExpression result = new CPPASTSimpleTypeConstructorExpression(); + result.setSimpleType(type); + result.setInitialValue(expression); + return result; } - public IASTDeclarationStatement newDeclarationStatement(IASTDeclaration declaration) { - return new CPPASTDeclarationStatement(declaration); + public ICPPASTSimpleTypeConstructorExpression newSimpleTypeConstructorExpression( + ICPPASTDeclSpecifier declSpec, IASTInitializer initializer) { + return new CPPASTSimpleTypeConstructorExpression(declSpec, initializer); } - public ICPPASTTypeIdExpression newTypeIdExpression(int operator, IASTTypeId typeId) { - return new CPPASTTypeIdExpression(operator, typeId); + public ICPPASTSimpleTypeTemplateParameter newSimpleTypeTemplateParameter(int type, IASTName name, IASTTypeId typeId) { + return new CPPASTSimpleTypeTemplateParameter(type, name, typeId); } - public ICPPASTDeclarator newDeclarator(IASTName name) { - return new CPPASTDeclarator(name); + public ICPPASTStaticAssertDeclaration newStaticAssertion(IASTExpression condition, + ICPPASTLiteralExpression message) { + return new CPPASTStaticAssertionDeclaration(condition, message); + } + + public ICPPASTSwitchStatement newSwitchStatement() { + return new CPPASTSwitchStatement(); + } + + public ICPPASTSwitchStatement newSwitchStatement(IASTDeclaration controller, IASTStatement body) { + return new CPPASTSwitchStatement(controller, body); + } + + public ICPPASTSwitchStatement newSwitchStatement(IASTExpression controller, IASTStatement body) { + return new CPPASTSwitchStatement(controller, body); + } + + public ICPPASTTemplateDeclaration newTemplateDeclaration(IASTDeclaration declaration) { + return new CPPASTTemplateDeclaration(declaration); + } + + public ICPPASTTemplatedTypeTemplateParameter newTemplatedTypeTemplateParameter(IASTName name, IASTExpression defaultValue) { + return new CPPASTTemplatedTypeTemplateParameter(name, defaultValue); + } + + public ICPPASTTemplateId newTemplateId(IASTName templateName) { + return new CPPASTTemplateId(templateName); + } + + public ICPPASTTemplateSpecialization newTemplateSpecialization(IASTDeclaration declaration) { + return new CPPASTTemplateSpecialization(declaration); + } + + public ICPPASTTranslationUnit newTranslationUnit() { + return newTranslationUnit(null); + } + + public ICPPASTTranslationUnit newTranslationUnit(IScanner scanner) { + CPPASTTranslationUnit tu = new CPPASTTranslationUnit(); + + if (scanner != null) { + tu.setLocationResolver(scanner.getLocationResolver()); + } + tu.setASTNodeFactory(this); + return tu; + } + + public ICPPASTTryBlockStatement newTryBlockStatement(IASTStatement body) { + return new CPPASTTryBlockStatement(body); + } + + public ICPPASTNamedTypeSpecifier newTypedefNameSpecifier(IASTName name) { + return new CPPASTNamedTypeSpecifier(name); } public ICPPASTTypeId newTypeId(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator) { return new CPPASTTypeId(declSpecifier, declarator); } - public ICPPASTDeleteExpression newDeleteExpression(IASTExpression operand) { - return new CPPASTDeleteExpression(operand); + public ICPPASTTypeIdExpression newTypeIdExpression(int operator, IASTTypeId typeId) { + return new CPPASTTypeIdExpression(operator, typeId); } - public IASTSimpleDeclaration newSimpleDeclaration(IASTDeclSpecifier declSpecifier) { - return new CPPASTSimpleDeclaration(declSpecifier); + public IASTTypeIdInitializerExpression newTypeIdInitializerExpression(IASTTypeId typeId, IASTInitializer initializer) { + return new CPPASTTypeIdInitializerExpression(typeId, initializer); } - public ICPPASTInitializerExpression newInitializerExpression(IASTExpression expression) { - return new CPPASTInitializerExpression(expression); + @Deprecated + public org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression newTypenameExpression(IASTName qualifiedName, IASTExpression expr, boolean isTemplate) { + return new CPPASTTypenameExpression(qualifiedName, expr); } - public ICPPASTFunctionDefinition newFunctionDefinition(IASTDeclSpecifier declSpecifier, IASTFunctionDeclarator declarator, - IASTStatement bodyStatement) { - return new CPPASTFunctionDefinition(declSpecifier, declarator, bodyStatement); - } - - public ICPPASTSimpleDeclSpecifier newSimpleDeclSpecifier() { - return new CPPASTSimpleDeclSpecifier(); - } - - public ICPPASTFunctionDeclarator newFunctionDeclarator(IASTName name) { - return new CPPASTFunctionDeclarator(name); - } - - public ICPPASTSimpleTypeConstructorExpression newSimpleTypeConstructorExpression(int type, IASTExpression expression) { - return new CPPASTSimpleTypeConstructorExpression(type, expression); - } - - public ICPPASTTypenameExpression newTypenameExpression(IASTName qualifiedName, IASTExpression expr, boolean isTemplate) { - return new CPPASTTypenameExpression(qualifiedName, expr, isTemplate); - } - - public IASTASMDeclaration newASMDeclaration(String assembly) { - return new CPPASTASMDeclaration(assembly); - } - - public ICPPASTNamespaceAlias newNamespaceAlias(IASTName alias, IASTName qualifiedName) { - return new CPPASTNamespaceAlias(alias, qualifiedName); + public ICPPASTUnaryExpression newUnaryExpression(int operator, IASTExpression operand) { + return new CPPASTUnaryExpression(operator, operand); } public ICPPASTUsingDeclaration newUsingDeclaration(IASTName name) { @@ -382,156 +572,19 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory { return new CPPASTUsingDirective(name); } - public ICPPASTLinkageSpecification newLinkageSpecification(String literal) { - return new CPPASTLinkageSpecification(literal); - } - - public ICPPASTNamespaceDefinition newNamespaceDefinition(IASTName name) { - return new CPPASTNamespaceDefinition(name); - } - - public ICPPASTTemplateDeclaration newTemplateDeclaration(IASTDeclaration declaration) { - return new CPPASTTemplateDeclaration(declaration); - } - - public ICPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiation(IASTDeclaration declaration) { - return new CPPASTExplicitTemplateInstantiation(declaration); - } - - public ICPPASTTemplateSpecialization newTemplateSpecialization(IASTDeclaration declaration) { - return new CPPASTTemplateSpecialization(declaration); - } - - public ICPPASTTryBlockStatement newTryBlockStatement(IASTStatement body) { - return new CPPASTTryBlockStatement(body); - } - - public ICPPASTCatchHandler newCatchHandler(IASTDeclaration decl, IASTStatement body) { - return new CPPASTCatchHandler(decl, body); - } - - public IASTEnumerationSpecifier newEnumerationSpecifier(IASTName name) { - return new CPPASTEnumerationSpecifier(name); - } - - public IASTEnumerator newEnumerator(IASTName name, IASTExpression value) { - return new CPPASTEnumerator(name, value); - } - public ICPPASTVisibilityLabel newVisibilityLabel(int visibility) { return new CPPASTVisibilityLabel(visibility); } - public ICPPASTBaseSpecifier newBaseSpecifier(IASTName name, int visibility, boolean isVirtual) { - return new CPPASTBaseSpecifier(name, visibility, isVirtual); + public ICPPASTWhileStatement newWhileStatement() { + return new CPPASTWhileStatement(); } - public ICPPASTCompositeTypeSpecifier newCompositeTypeSpecifier(int key, IASTName name) { - return new CPPASTCompositeTypeSpecifier(key, name); + public ICPPASTWhileStatement newWhileStatement(IASTDeclaration condition, IASTStatement body) { + return new CPPASTWhileStatement(condition, body); } - public ICPPASTNamedTypeSpecifier newTypedefNameSpecifier(IASTName name) { - return new CPPASTNamedTypeSpecifier(name); + public ICPPASTWhileStatement newWhileStatement(IASTExpression condition, IASTStatement body) { + return new CPPASTWhileStatement(condition, body); } - - public ICPPASTElaboratedTypeSpecifier newElaboratedTypeSpecifier(int kind, IASTName name) { - return new CPPASTElaboratedTypeSpecifier(kind, name); - } - - public IASTPointer newPointer() { - return new CPPASTPointer(); - } - - public IGPPASTPointer newPointerGPP() { - return new GPPASTPointer(); - } - - public ICPPASTReferenceOperator newReferenceOperator() { - return new CPPASTReferenceOperator(false); - } - - public ICPPASTReferenceOperator newReferenceOperator(boolean isRValueReference) { - return new CPPASTReferenceOperator(isRValueReference); - } - - public ICPPASTPointerToMember newPointerToMember(IASTName name) { - return new CPPASTPointerToMember(name); - } - - public IGPPASTPointerToMember newPointerToMemberGPP(IASTName name) { - return new GPPASTPointerToMember(name); - } - - public ICPPASTInitializerList newInitializerList() { - return new CPPASTInitializerList(); - } - - public ICPPASTConstructorInitializer newConstructorInitializer(IASTExpression exp) { - return new CPPASTConstructorInitializer(exp); - } - - public IASTArrayModifier newArrayModifier(IASTExpression expr) { - return new CPPASTArrayModifier(expr); - } - - public ICPPASTArrayDeclarator newArrayDeclarator(IASTName name) { - return new CPPASTArrayDeclarator(name); - } - - public ICPPASTParameterDeclaration newParameterDeclaration(IASTDeclSpecifier declSpec, IASTDeclarator declarator) { - return new CPPASTParameterDeclaration(declSpec, declarator); - } - - public ICPPASTConstructorChainInitializer newConstructorChainInitializer(IASTName memberInitializerid, IASTExpression initializerValue) { - return new CPPASTConstructorChainInitializer(memberInitializerid, initializerValue); - } - - public ICPPASTFunctionWithTryBlock newFunctionTryBlock(IASTDeclSpecifier declSpecifier, IASTFunctionDeclarator declarator, - IASTStatement bodyStatement) { - return new CPPASTFunctionWithTryBlock(declSpecifier, declarator, bodyStatement); - } - - public ICPPASTFieldDeclarator newFieldDeclarator(IASTName name, IASTExpression bitFieldSize) { - return new CPPASTFieldDeclarator(name, bitFieldSize); - } - - public ICPPASTSimpleTypeTemplateParameter newSimpleTypeTemplateParameter(int type, IASTName name, IASTTypeId typeId) { - return new CPPASTSimpleTypeTemplateParameter(type, name, typeId); - } - - public ICPPASTTemplatedTypeTemplateParameter newTemplatedTypeTemplateParameter(IASTName name, IASTExpression defaultValue) { - return new CPPASTTemplatedTypeTemplateParameter(name, defaultValue); - } - - public IGNUASTCompoundStatementExpression newGNUCompoundStatementExpression(IASTCompoundStatement compoundStatement) { - return new CPPASTCompoundStatementExpression(compoundStatement); - } - - public IASTProblemTypeId newProblemTypeId(IASTProblem problem) { - return new CPPASTProblemTypeId(problem); - } - - public ICPPASTStaticAssertDeclaration newStaticAssertion(IASTExpression condition, - ICPPASTLiteralExpression message) { - return new CPPASTStaticAssertionDeclaration(condition, message); - } - - public ICPPASTPackExpansionExpression newPackExpansionExpression(IASTExpression pattern) { - return new CPPASTPackExpansionExpression(pattern); - } - - @Deprecated - public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier newSimpleDeclSpecifierGPP() { - return new GPPASTSimpleDeclSpecifier(); - } - - /** - * @deprecated Replaced by {@link #newExplicitTemplateInstantiation(IASTDeclaration)}. - */ - @Deprecated - public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiationGPP(IASTDeclaration declaration) { - return new GPPASTExplicitTemplateInstantiation(declaration); - } - - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java index 75cf9a85905..55cdcaac118 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -13,9 +13,11 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; +import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTInitializer; -import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression; +import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; +import org.eclipse.cdt.core.dom.ast.IASTInitializerList; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IType; @@ -51,8 +53,14 @@ public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements if (parent instanceof IASTDeclarator) { IASTDeclarator dtor = (IASTDeclarator) parent; IASTInitializer initializer = dtor.getInitializer(); - if (initializer instanceof IASTInitializerExpression) - return ((IASTInitializerExpression) initializer).getExpression(); + if (initializer instanceof IASTEqualsInitializer) { + IASTInitializerClause clause= ((IASTEqualsInitializer) initializer).getInitializerClause(); + if (clause instanceof IASTExpression) + return (IASTExpression) clause; + if (clause instanceof IASTInitializerList) { + // mstodo handle braced init list + } + } } } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java index c502fddf109..f90408c2f8c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -26,7 +26,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; @@ -117,8 +116,7 @@ public class CPPUnknownScope implements ICPPInternalUnknownScope { } if (!type) { if (parent instanceof ICPPASTBaseSpecifier || - parent instanceof ICPPASTConstructorChainInitializer || - parent instanceof ICPPASTTypenameExpression) { + parent instanceof ICPPASTConstructorChainInitializer) { type= true; } else if (parent instanceof ICPPASTNamedTypeSpecifier) { ICPPASTNamedTypeSpecifier nts= (ICPPASTNamedTypeSpecifier) parent; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java index 157a94eb970..d8e851ddf60 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,9 +17,10 @@ import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; +import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTInitializer; -import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression; +import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; @@ -396,20 +397,25 @@ public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInt IASTDeclarator dtor= findDeclarator(name); if (dtor != null) { IASTInitializer init= dtor.getInitializer(); - if (init instanceof IASTInitializerExpression) { - IASTExpression expr= ((IASTInitializerExpression) init).getExpression(); - if (expr != null) - return Value.create(expr, maxDepth); - } else if (init instanceof ICPPASTConstructorInitializer) { - IType type= SemanticUtil.getUltimateTypeUptoPointers(getType()); - if (type instanceof IPointerType || type instanceof IBasicType) { - IASTExpression expr= ((ICPPASTConstructorInitializer) init).getExpression(); - if (expr != null) - return Value.create(expr, maxDepth); + if (init != null) { + IASTInitializerClause clause= null; + if (init instanceof IASTEqualsInitializer) { + clause= ((IASTEqualsInitializer) init).getInitializerClause(); + } else if (init instanceof ICPPASTConstructorInitializer) { + IASTInitializerClause[] args= ((ICPPASTConstructorInitializer) init).getArguments(); + if (args.length == 1 && args[0] instanceof IASTExpression) { + IType type= SemanticUtil.getUltimateTypeUptoPointers(getType()); + if (type instanceof IPointerType || type instanceof IBasicType) { + clause= args[0]; + } + } } - } - if (init != null) + if (clause instanceof IASTExpression) { + return Value.create((IASTExpression) clause, maxDepth); + } + // mstodo handle braced init list return Value.UNKNOWN; + } } return null; } 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 d073069b6b9..691d7fe1ef1 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 @@ -32,11 +32,14 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; +import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression; import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.IASTIdExpression; import org.eclipse.cdt.core.dom.ast.IASTInitializer; +import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; +import org.eclipse.cdt.core.dom.ast.IASTInitializerList; import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier; @@ -76,8 +79,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionWithTryBlock; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTIfStatement; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializer; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerList; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression; @@ -86,6 +87,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceAlias; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPackExpandable; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator; @@ -103,7 +105,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTryBlockStatement; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeId; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeIdExpression; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective; @@ -221,7 +222,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { loop: for(;;) { boolean forceTemplate= false; if (qname != null && LT(1) == IToken.t_template) { - consume().getEndOffset(); + consume(); forceTemplate= true; } @@ -695,11 +696,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { int lt1; int conditionCount= 0; BinaryOperator lastOperator= null; - IASTExpression expr= castExpression(castCtx); + IASTInitializerClause expr= castExpression(castCtx); loop: while(true) { - // typically after a binary operator there cannot be a throw expression + // Typically after a binary operator there cannot be a throw expression boolean allowThrow= false; + // Brace initializers are allowed on the right hand side of an expression + boolean allowBraceInitializer= false; lt1= LT(1); switch(lt1) { case IToken.tQUESTION: @@ -730,18 +733,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { allowAssignment= true; // assignment expressions will be subsumed by the conditional expression allowThrow= true; break; - - case IToken.tELLIPSIS: - if ((!allowComma && conditionCount == 0)) - break loop; - - // Precedence: To the left just stronger than ',', to the right no other choice. - lastOperator= new BinaryOperator(lastOperator, expr, lt1, 12, Integer.MAX_VALUE); - expr= nodeFactory.newPackExpansionExpression(null); - setRange(expr, 0, consume().getEndOffset()); - if (LT(1) == IToken.tCOMMA) - continue loop; - break loop; case IToken.tCOMMA: allowThrow= true; @@ -766,6 +757,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { break loop; // Assignments group right to left lastOperator= new BinaryOperator(lastOperator, expr, lt1, 21, 20); + allowBraceInitializer= true; break; case IToken.tOR: @@ -837,15 +829,17 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { consume(); // consume operator if (allowThrow && LT(1) == IToken.t_throw) { expr= throwExpression(); - switch (LT(1)) { - case IToken.tCOLON: - case IToken.tCOMMA: - break; - default: - break loop; - } - } - expr= castExpression(castCtx); // next cast expression + } else if (allowBraceInitializer && LT(1) == IToken.tLBRACE) { + expr= bracedInitList(); + } else { + expr= castExpression(castCtx); // next cast expression + continue loop; + } + + // For throw and braced initializers we require that the assignment expression ends. + lt1= LT(1); + if (lt1 != IToken.tCOLON && lt1 != IToken.tCOMMA) + break loop; } // Check for incomplete conditional expression @@ -855,6 +849,14 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { return buildExpression(lastOperator, expr); } + @Override + protected IASTExpression buildBinaryExpression(int operator, IASTExpression expr1, IASTInitializerClause expr2, int lastOffset) { + IASTBinaryExpression result = nodeFactory.newBinaryExpression(operator, expr1, expr2); + int o = ((ASTNode) expr1).getOffset(); + ((ASTNode) result).setOffsetAndLength(o, lastOffset - o); + return result; + } + private IASTExpression throwExpression() throws EndOfFileException, BacktrackException { IToken throwToken = consume(); IASTExpression throwExpression = null; @@ -902,7 +904,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { * and I for initializer the potential patterns (with the new omitted) are: * easy: T, T(I) * medium: (P) T(I), (P) (T)(I) - * hard: (T), (P) T, (P) T, (P) (T), (T)(I) + * hard: (T), (P) T, (P) (T), (T)(I) */ protected IASTExpression newExpression() throws BacktrackException, EndOfFileException { IToken la = LA(1); @@ -917,15 +919,15 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { consume(); // consider placement first (P) ... - IASTExpression plcmt= null; + List plcmt= null; IASTTypeId typeid= null; boolean isNewTypeId= true; - IASTExpression init= null; + IASTInitializer init= null; int endOffset= 0; IToken mark= mark(); IToken end= null; try { - plcmt= expression(); + plcmt= expressionList(); endOffset= consumeOrEOC(IToken.tRPAREN).getEndOffset(); if (LT(1) == IToken.tLPAREN) { @@ -949,18 +951,18 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { typeid= null; } - if (typeid != null && plcmt != null && LT(1) == IToken.tLPAREN) { + int lt1= LT(1); + if (typeid != null && plcmt != null && (lt1 == IToken.tLPAREN || lt1 == IToken.tLBRACE)) { // (P)(T)(I) or (P) T (I) - consume(IToken.tLPAREN); - init= possiblyEmptyExpressionList(IToken.tRPAREN); - endOffset= consumeOrEOC(IToken.tRPAREN).getEndOffset(); + init= bracedOrCtorStyleInitializer(); + endOffset= calculateEndOffset(init); return newExpression(isGlobal, plcmt, typeid, isNewTypeId, init, offset, endOffset); } // (T) ... backup(mark); IASTTypeId typeid2= null; - IASTExpression init2= null; + IASTInitializer init2= null; int endOffset2; try { typeid2= typeId(DeclarationOptions.TYPEID); @@ -968,16 +970,16 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { throw backtrack; endOffset2= consumeOrEOC(IToken.tRPAREN).getEndOffset(); - if (LT(1) == IToken.tLPAREN) { + lt1= LT(1); + if (lt1 == IToken.tLPAREN || lt1 == IToken.tLBRACE) { if (plcmt != null && ASTQueries.findTypeRelevantDeclarator(typeid2.getAbstractDeclarator()) instanceof IASTArrayDeclarator) { throwBacktrack(LA(1)); } // (T)(I) - consume(IToken.tLPAREN); - init2= possiblyEmptyExpressionList(IToken.tRPAREN); - endOffset2= consumeOrEOC(IToken.tRPAREN).getEndOffset(); + init2= bracedOrCtorStyleInitializer(); + endOffset2= calculateEndOffset(init2); } } catch (BacktrackException e) { if (plcmt == null) @@ -1008,20 +1010,27 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { final IASTTypeId typeid = typeId(DeclarationOptions.TYPEID_NEW); if (typeid == null) throw backtrack; + int endOffset = calculateEndOffset(typeid); - IASTExpression init= null; - if (LT(1) == IToken.tLPAREN) { + IASTInitializer init= null; + final int lt1= LT(1); + if (lt1 == IToken.tLPAREN || lt1 == IToken.tLBRACE) { // T(I) - consume(IToken.tLPAREN); - init= possiblyEmptyExpressionList(IToken.tRPAREN); - endOffset= consumeOrEOC(IToken.tRPAREN).getEndOffset(); + init= bracedOrCtorStyleInitializer(); + endOffset= calculateEndOffset(init); } return newExpression(isGlobal, null, typeid, true, init, offset, endOffset); } - private IASTExpression newExpression(boolean isGlobal, IASTExpression placement, IASTTypeId typeid, - boolean isNewTypeId, IASTExpression init, int offset, int endOffset) { - ICPPASTNewExpression result = nodeFactory.newNewExpression(placement, init, typeid); + + private IASTExpression newExpression(boolean isGlobal, List plcmt, IASTTypeId typeid, + boolean isNewTypeId, IASTInitializer init, int offset, int endOffset) { + + IASTInitializerClause[] plcmtArray= null; + if (plcmt != null && !plcmt.isEmpty()) { + plcmtArray= plcmt.toArray(new IASTInitializerClause[plcmt.size()]); + } + ICPPASTNewExpression result = nodeFactory.newNewExpression(plcmtArray, init, typeid); result.setIsGlobal(isGlobal); result.setIsNewTypeId(isNewTypeId); ((ASTNode) result).setOffsetAndLength(offset, endOffset - offset); @@ -1089,81 +1098,38 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { } } + /** + * postfix-expression: + * [gnu-extension, compound literals in c++] + * ( type-name ) { initializer-list } + * ( type-name ) { initializer-list , } + * + * primary-expression + * postfix-expression [ expression ] + * postfix-expression [ braced-init-list ] + * postfix-expression ( expression-list_opt ) + * simple-type-specifier ( expression-list_opt ) + * simple-type-specifier braced-init-list + * typename-specifier ( expression-list_opt ) + * typename-specifier braced-init-list + * postfix-expression . templateopt id-expression + * postfix-expression -> templateopt id-expression + * postfix-expression . pseudo-destructor-name + * postfix-expression -> pseudo-destructor-name + * postfix-expression ++ + * postfix-expression -- + * dynamic_cast < type-id > ( expression ) + * static_cast < type-id > ( expression ) + * reinterpret_cast < type-id > ( expression ) + * const_cast < type-id > ( expression ) + * typeid ( expression ) + * typeid ( type-id ) + */ private IASTExpression postfixExpression(CastExprCtx ctx) throws EndOfFileException, BacktrackException { IASTExpression firstExpression = null; boolean isTemplate = false; - switch (LT(1)) { - case IToken.tLPAREN: - // ( type-name ) { initializer-list } - // ( type-name ) { initializer-list , } - IToken m = mark(); - try { - int offset = consume().getOffset(); - IASTTypeId t= typeId(DeclarationOptions.TYPEID); - if (t != null) { - consume(IToken.tRPAREN); - if (LT(1) == IToken.tLBRACE) { - IASTInitializer i = initializerClause(false); - firstExpression= nodeFactory.newTypeIdInitializerExpression(t, i); - setRange(firstExpression, offset, calculateEndOffset(i)); - break; - } - } - } catch (BacktrackException bt) { - } - backup(m); - firstExpression= primaryExpression(ctx); - break; - - case IToken.t_typename: - int typenameOffset= consume().getOffset(); - - boolean templateTokenConsumed = false; - if (LT(1) == IToken.t_template) { - consume(); - templateTokenConsumed = true; - } - IASTName name = qualifiedName(CastExprCtx.eNotBExpr); // treat as not in binary to force template arguments - if (LT(1) != IToken.tLPAREN) { - throwBacktrack(LA(1)); - } - - ICPPASTTypenameExpression result = nodeFactory.newTypenameExpression(name, null, templateTokenConsumed); - setRange(result, typenameOffset, calculateEndOffset(name)); - firstExpression = result; - break; - // simple-type-specifier ( assignment-expression , .. ) - case IToken.t_char: - firstExpression = simpleTypeConstructorExpression(ICPPASTSimpleTypeConstructorExpression.t_char); - break; - case IToken.t_wchar_t: - firstExpression = simpleTypeConstructorExpression(ICPPASTSimpleTypeConstructorExpression.t_wchar_t); - break; - case IToken.t_bool: - firstExpression = simpleTypeConstructorExpression(ICPPASTSimpleTypeConstructorExpression.t_bool); - break; - case IToken.t_short: - firstExpression = simpleTypeConstructorExpression(ICPPASTSimpleTypeConstructorExpression.t_short); - break; - case IToken.t_int: - firstExpression = simpleTypeConstructorExpression(ICPPASTSimpleTypeConstructorExpression.t_int); - break; - case IToken.t_long: - firstExpression = simpleTypeConstructorExpression(ICPPASTSimpleTypeConstructorExpression.t_long); - break; - case IToken.t_signed: - firstExpression = simpleTypeConstructorExpression(ICPPASTSimpleTypeConstructorExpression.t_signed); - break; - case IToken.t_unsigned: - firstExpression = simpleTypeConstructorExpression(ICPPASTSimpleTypeConstructorExpression.t_unsigned); - break; - case IToken.t_float: - firstExpression = simpleTypeConstructorExpression(ICPPASTSimpleTypeConstructorExpression.t_float); - break; - case IToken.t_double: - firstExpression = simpleTypeConstructorExpression(ICPPASTSimpleTypeConstructorExpression.t_double); - break; + switch (LT(1)) { case IToken.t_dynamic_cast: firstExpression = specialCastExpression(ICPPASTCastExpression.op_dynamic_cast); break; @@ -1176,72 +1142,112 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { case IToken.t_const_cast: firstExpression = specialCastExpression(ICPPASTCastExpression.op_const_cast); break; + case IToken.t_typeid: + // 'typeid' ( expression ) + // 'typeid' ( type-id ) int so = consume().getOffset(); firstExpression = parseTypeidInParenthesisOrUnaryExpression(true, so, ICPPASTTypeIdExpression.op_typeid, ICPPASTUnaryExpression.op_typeid, ctx); break; + case IToken.tLPAREN: + // Gnu-extension: compound literals in c++ + // ( type-name ) { initializer-list } + // ( type-name ) { initializer-list , } + IToken m = mark(); + try { + int offset = consume().getOffset(); + IASTTypeId t= typeId(DeclarationOptions.TYPEID); + if (t != null) { + consume(IToken.tRPAREN); + if (LT(1) == IToken.tLBRACE) { + IASTInitializer i = bracedInitList(); + firstExpression= nodeFactory.newTypeIdInitializerExpression(t, i); + setRange(firstExpression, offset, calculateEndOffset(i)); + break; + } + } + } catch (BacktrackException bt) { + } + backup(m); + firstExpression= primaryExpression(ctx); + break; + + // typename-specifier ( expression-list_opt ) + // typename-specifier braced-init-list + // simple-type-specifier ( expression-list_opt ) + // simple-type-specifier braced-init-list + case IToken.t_typename: + case IToken.t_char: + case IToken.t_wchar_t: + case IToken.t_bool: + case IToken.t_short: + case IToken.t_int: + case IToken.t_long: + case IToken.t_signed: + case IToken.t_unsigned: + case IToken.t_float: + case IToken.t_double: + case IToken.t_decltype: + case IGCCToken.t_typeof: + firstExpression = simpleTypeConstructorExpression(simpleTypeSpecifier()); + break; + default: firstExpression = primaryExpression(ctx); + if (firstExpression instanceof IASTIdExpression && LT(1) == IToken.tLBRACE) { + IASTName name = ((IASTIdExpression) firstExpression).getName(); + ICPPASTDeclSpecifier declSpec= nodeFactory.newTypedefNameSpecifier(name); + firstExpression = simpleTypeConstructorExpression(setRange(declSpec, name)); + } break; } - IASTExpression secondExpression = null; + for (;;) { switch (LT(1)) { case IToken.tLBRACKET: - // array access - consume(); - int lastOffset; - secondExpression = expression(); - switch (LT(1)) { - case IToken.tRBRACKET: - case IToken.tEOC: - lastOffset = consume().getEndOffset(); - break; - default: - throw backtrack; + // postfix-expression [ expression ] + // postfix-expression [ braced-init-list ] + consume(IToken.tLBRACKET); + IASTInitializerClause expression; + if (LT(1) == IToken.tLBRACE) { + expression= bracedInitList(); + } else { + expression= expression(); } - - IASTArraySubscriptExpression s = nodeFactory.newArraySubscriptExpression(firstExpression, secondExpression); - ((ASTNode) s).setOffsetAndLength(((ASTNode) firstExpression) - .getOffset(), lastOffset - ((ASTNode) firstExpression).getOffset()); - firstExpression = s; + int endOffset= consumeOrEOC(IToken.tRBRACKET).getEndOffset(); + IASTArraySubscriptExpression s = nodeFactory.newArraySubscriptExpression(firstExpression, expression); + firstExpression= setRange(s, firstExpression, endOffset); break; case IToken.tLPAREN: - // function call - consume(); + // postfix-expression ( expression-list_opt ) + // simple-type-specifier ( expression-list_opt ) // cannot be distinguished + consume(IToken.tLPAREN); + IASTInitializerClause[] initArray; + if (LT(1) == IToken.tRPAREN) { + initArray= IASTExpression.EMPTY_EXPRESSION_ARRAY; + } else { + final List exprList = expressionList(); + initArray = exprList.toArray(new IASTInitializerClause[exprList.size()]); + } + endOffset = consumeOrEOC(IToken.tRPAREN).getEndOffset(); - if (LT(1) != IToken.tRPAREN) - secondExpression = expression(); - else - secondExpression = null; - switch (LT(1)) { - case IToken.tRPAREN: - case IToken.tEOC: - lastOffset = consume().getEndOffset(); - break; - default: - throw backtrack; - } - - IASTFunctionCallExpression fce = nodeFactory.newFunctionCallExpression(firstExpression, secondExpression); - ((ASTNode) fce).setOffsetAndLength(((ASTNode) firstExpression) - .getOffset(), lastOffset - ((ASTNode) firstExpression).getOffset()); - firstExpression = fce; + IASTFunctionCallExpression fce = nodeFactory.newFunctionCallExpression(firstExpression, initArray); + firstExpression= setRange(fce, firstExpression, endOffset); break; + case IToken.tINCR: - int offset = consume().getEndOffset(); - firstExpression = buildUnaryExpression( - IASTUnaryExpression.op_postFixIncr, firstExpression, - ((ASTNode) firstExpression).getOffset(), offset); + endOffset = consume().getEndOffset(); + firstExpression = buildUnaryExpression(IASTUnaryExpression.op_postFixIncr, firstExpression, + ((ASTNode) firstExpression).getOffset(), endOffset); break; case IToken.tDECR: - offset = consume().getEndOffset(); - firstExpression = buildUnaryExpression( - IASTUnaryExpression.op_postFixDecr, firstExpression, - ((ASTNode) firstExpression).getOffset(), offset); + endOffset = consume().getEndOffset(); + firstExpression = buildUnaryExpression(IASTUnaryExpression.op_postFixDecr, firstExpression, + ((ASTNode) firstExpression).getOffset(), endOffset); break; + case IToken.tDOT: // member access IToken dot = consume(); @@ -1293,7 +1299,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { } } - @Override + @Override protected IASTAmbiguousExpression createAmbiguousExpression() { return new CPPASTAmbiguousExpression(); } @@ -1313,20 +1319,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { } - protected IASTExpression simpleTypeConstructorExpression(int operator) throws EndOfFileException, BacktrackException { - int startingOffset = LA(1).getOffset(); - consume(); - consume(IToken.tLPAREN); - IASTExpression operand = null; - if (LT(1) != IToken.tRPAREN) - operand = expression(); - int l = consume(IToken.tRPAREN).getEndOffset(); - ICPPASTSimpleTypeConstructorExpression result = nodeFactory.newSimpleTypeConstructorExpression(operator, operand); - ((ASTNode) result).setOffsetAndLength(startingOffset, l - startingOffset); - return result; + private IASTExpression simpleTypeConstructorExpression(ICPPASTDeclSpecifier declSpec) throws EndOfFileException, BacktrackException { + IASTInitializer initializer = bracedOrCtorStyleInitializer(); + ICPPASTSimpleTypeConstructorExpression result = nodeFactory.newSimpleTypeConstructorExpression( + declSpec, initializer); + return setRange(result, declSpec, calculateEndOffset(initializer)); } - @Override protected IASTExpression primaryExpression(CastExprCtx ctx) throws EndOfFileException, BacktrackException { IToken t = null; @@ -2063,62 +2062,44 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { return fdef; } - - /** - * This method parses a constructor chain ctorinitializer: : - * meminitializerlist meminitializerlist: meminitializer | meminitializer , - * meminitializerlist meminitializer: meminitializerid | ( expressionlist? ) - * meminitializerid: ::? nestednamespecifier? classname identifier - * - * @throws BacktrackException - * request a backtrack - */ + /** + * ctor-initializer: + * : mem-initializer-list + * mem-initializer-list: + * mem-initializer ...? + * mem-initializer ...?, mem-initializer-list + * mem-initializer: + * mem-initializer-id ( expression-list? ) + * mem-initializer-id braced-init-list + * mem-initializer-id: + * ::? nested-name-specifier? class-name + * identifier + */ protected void ctorInitializer(ICPPASTFunctionDefinition fdef) throws EndOfFileException, BacktrackException { - consume(); - ctorLoop: for (;;) { - int offset= LA(1).getOffset(); - IASTName name = qualifiedName(CastExprCtx.eNotBExpr); - + consume(IToken.tCOLON); + loop: for(;;) { + final int offset= LA(1).getOffset(); + final IASTName name = qualifiedName(CastExprCtx.eNotBExpr); + final IASTInitializer init; int endOffset; - IASTExpression expressionList = null; - switch (LT(1)) { - case IToken.tLPAREN: - consume(); - - if (LT(1) != IToken.tRPAREN) - expressionList = expression(); - - switch (LT(1)) { - case IToken.tRPAREN: - case IToken.tEOC: - endOffset = consume().getEndOffset(); - break; - default: - throw backtrack; - } - break; - case IToken.tEOC: - endOffset = consume().getEndOffset(); - break; - default: - throw backtrack; + if (LT(1) != IToken.tEOC) { + init = bracedOrCtorStyleInitializer(); + endOffset= calculateEndOffset(init); + } else { + init= null; + endOffset= calculateEndOffset(name); } - - ICPPASTConstructorChainInitializer ctorInitializer = nodeFactory.newConstructorChainInitializer(name, expressionList); + ICPPASTConstructorChainInitializer ctorInitializer = nodeFactory.newConstructorChainInitializer(name, init); if (LT(1) == IToken.tELLIPSIS) { ctorInitializer.setIsPackExpansion(true); endOffset= consume().getEndOffset(); - } - setRange(ctorInitializer, offset, endOffset); - fdef.addMemberInitializer(ctorInitializer); + } + fdef.addMemberInitializer(setRange(ctorInitializer, offset, endOffset)); - switch (LT(1)) { - case IToken.tCOMMA: - consume(); - break; - case IToken.tLBRACE: - case IToken.tEOC: - break ctorLoop; + if (LT(1) == IToken.tCOMMA) { + consume(); + } else { + break loop; } } } @@ -2177,6 +2158,15 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { */ @Override protected Decl declSpecifierSeq(final DeclarationOptions option) throws BacktrackException, EndOfFileException { + return declSpecifierSeq(option.fAllowEmptySpecifier, false); + } + + private ICPPASTDeclSpecifier simpleTypeSpecifier() throws BacktrackException, EndOfFileException { + Decl d= declSpecifierSeq(false, true); + return (ICPPASTDeclSpecifier) d.fDeclSpec1; + } + + private Decl declSpecifierSeq(final boolean allowEmpty, final boolean single) throws BacktrackException, EndOfFileException { int storageClass = IASTDeclSpecifier.sc_unspecified; int simpleType = IASTSimpleDeclSpecifier.t_unspecified; int options= 0; @@ -2362,7 +2352,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { if (encounteredRawType || encounteredTypename) break declSpecifiers; - if (option.fAllowEmptySpecifier && LT(1) != IToken.tCOMPLETION) { + if (allowEmpty && LT(1) != IToken.tCOMPLETION) { if ((options & FORBID_IN_EMPTY_DECLSPEC) == 0 && storageClass == IASTDeclSpecifier.sc_unspecified) { altResult= buildSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset); returnToken= mark(); @@ -2456,10 +2446,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { if (encounteredRawType && encounteredTypename) throwBacktrack(LA(1)); + + if (single) + break declSpecifiers; } // check for empty specification - if (!encounteredRawType && !encounteredTypename && LT(1) != IToken.tEOC && !option.fAllowEmptySpecifier) { + if (!encounteredRawType && !encounteredTypename && LT(1) != IToken.tEOC && !allowEmpty) { throwBacktrack(LA(1)); } @@ -2590,14 +2583,22 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { switch(lt1) { case 0: return dtor1; + + case IToken.tLBRACE: + if (option.fAllowBracedInitializer || option == DeclarationOptions.TYPEID_NEW + || ASTQueries.findTypeRelevantDeclarator(dtor1) instanceof IASTFunctionDeclarator) + return dtor1; + + dtor1= null; + throwBacktrack(LA(1)); + break; + case IToken.tCOLON: // a colon can be used after a type-id in a conditional expression if (option != DeclarationOptions.CPP_MEMBER && option != DeclarationOptions.GLOBAL) break; //$FALL-THROUGH$ - - case IToken.tLBRACE: - case IToken.t_throw: case IToken.t_try: + case IToken.t_throw: case IToken.t_try: case IToken.t_const: case IToken.t_volatile: if (ASTQueries.findTypeRelevantDeclarator(dtor1) instanceof IASTFunctionDeclarator) { return dtor1; @@ -2615,7 +2616,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { bt= e; } - if (!option.fAllowConstructorInitializer || !canHaveConstructorInitializer(declspec, dtor1)) { + if (!option.fAllowCtorStyleInitializer || !canHaveConstructorInitializer(declspec, dtor1)) { if (bt != null) throw bt; return dtor1; @@ -2734,15 +2735,46 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { private IASTDeclarator initDeclarator(DtorStrategy strategy, IASTDeclSpecifier declspec, DeclarationOptions option) throws EndOfFileException, BacktrackException, FoundAggregateInitializer { final IASTDeclarator dtor= declarator(strategy, option); - if (option.fAllowInitializer) { - if (LTcatchEOF(1) == IToken.tASSIGN && LTcatchEOF(2) == IToken.tLBRACE) - throw new FoundAggregateInitializer(declspec, dtor); + if (option.fAllowInitializer) { + final IASTDeclarator typeRelevantDtor = ASTQueries.findTypeRelevantDeclarator(dtor); + if (option != DeclarationOptions.PARAMETER && typeRelevantDtor instanceof IASTFunctionDeclarator) { + // Function declarations don't have initializers + // For member functions we need to consider pure-virtual syntax + if (option == DeclarationOptions.CPP_MEMBER && LTcatchEOF(1) == IToken.tASSIGN + && LTcatchEOF(2) == IToken.tINTEGER) { + consume(); + IToken t = consume(); + char[] image = t.getCharImage(); + if (image.length != 1 || image[0] != '0') { + throwBacktrack(t); + } + ((ICPPASTFunctionDeclarator) typeRelevantDtor).setPureVirtual(true); + adjustEndOffset(dtor, t.getEndOffset()); // we can only adjust the offset of the outermost dtor. + } + } else { + if (LTcatchEOF(1) == IToken.tASSIGN && LTcatchEOF(2) == IToken.tLBRACE) + throw new FoundAggregateInitializer(declspec, dtor); - IASTInitializer initializer= optionalCPPInitializer(dtor, option); - if (initializer != null) { - dtor.setInitializer(initializer); - adjustLength(dtor, initializer); - } + IASTInitializer initializer= optionalInitializer(option); + if (initializer != null) { + if (initializer instanceof IASTInitializerList + && ((IASTInitializerList) initializer).getSize() == 0) { + // Avoid ambiguity between constructor with body and variable with initializer + switch (LTcatchEOF(1)) { + case IToken.tCOMMA: + case IToken.tSEMI: + case IToken.tRPAREN: + break; + case 0: + throw backtrack; + default: + throwBacktrack(LA(1)); + } + } + dtor.setInitializer(initializer); + adjustLength(dtor, initializer); + } + } } return dtor; } @@ -2751,112 +2783,175 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { protected IASTDeclarator addInitializer(FoundAggregateInitializer e, DeclarationOptions option) throws EndOfFileException { final IASTDeclarator d = e.fDeclarator; try { - IASTInitializer i = optionalCPPInitializer(e.fDeclarator, option); + IASTInitializer i = optionalInitializer(option); if (i != null) { d.setInitializer(i); ((ASTNode) d).setLength(calculateEndOffset(i) - ((ASTNode) d).getOffset()); } } catch (BacktrackException e1) { // mstodo add problem node + failParse(); } return d; } - protected IASTInitializer optionalCPPInitializer(IASTDeclarator d, DeclarationOptions option) throws EndOfFileException, BacktrackException { - // handle initializer + /** + * initializer: + * brace-or-equal-initializer + * ( expression-list ) + * + * brace-or-equal-initializer: + * = initializer-clause + * braced-init-list + */ + private IASTInitializer optionalInitializer(DeclarationOptions option) throws EndOfFileException, BacktrackException { final int lt1= LTcatchEOF(1); + + // = initializer-clause if (lt1 == IToken.tASSIGN) { - consume(); - // for member functions we need to consider pure-virtual syntax - if (option == DeclarationOptions.CPP_MEMBER && LTcatchEOF(1) == IToken.tINTEGER) { - IASTDeclarator relDtor = ASTQueries.findTypeRelevantDeclarator(d); - // note the declarator for a member function cannot be ambiguous because it cannot be abstract - if (relDtor instanceof ICPPASTFunctionDeclarator) { - // check for pure virtual - IToken t = consume(); - char[] image = t.getCharImage(); - if (image.length != 1 || image[0] != '0') { - throwBacktrack(t); - } - - ((ICPPASTFunctionDeclarator) relDtor).setPureVirtual(true); - adjustEndOffset(d, t.getEndOffset()); // we can only adjust the offset of the outermost dtor. - return null; - } - } - try { - return initializerClause(false); - } catch (EndOfFileException eof) { - failParse(); - throw eof; - } - } else if (option.fAllowConstructorInitializer && lt1 == IToken.tLPAREN) { - if (d instanceof IASTFunctionDeclarator && d.getNestedDeclarator() == null) { - // constructor initializer doesn't make sense for a function - // declarator, - // we must have an object to initialize, a function doesn't - // work. - return null; - } - // initializer in constructor - IToken t = consume(); // EAT IT! - int o = t.getOffset(); - IASTExpression astExpression = expression(); - if( astExpression == null ) - throwBacktrack( t ); - int l = consumeOrEOC(IToken.tRPAREN).getEndOffset(); - ICPPASTConstructorInitializer result = nodeFactory.newConstructorInitializer(astExpression); - ((ASTNode) result).setOffsetAndLength(o, l - o); - return result; + int offset= consume().getOffset(); + IASTInitializerClause initClause = initClause(false); + IASTEqualsInitializer initExpr= nodeFactory.newEqualsInitializer(initClause); + return setRange(initExpr, offset, calculateEndOffset(initClause)); } + + // braced-init-list + if (option.fAllowBracedInitializer && lt1 == IToken.tLBRACE) { + return bracedInitList(); + } + + // ( expression-list ) + if (option.fAllowCtorStyleInitializer && lt1 == IToken.tLPAREN) { + return ctorStyleInitializer(false); + } return null; } + + private IASTInitializer bracedOrCtorStyleInitializer() throws EndOfFileException, BacktrackException { + final int lt1= LT(1); + if (lt1 == IToken.tLPAREN) { + return ctorStyleInitializer(true); + } + return bracedInitList(); + } + /** + * ( expression-list_opt ) + */ + private ICPPASTConstructorInitializer ctorStyleInitializer(boolean optionalExpressionList) + throws EndOfFileException, BacktrackException { + IASTInitializerClause[] initArray; + int offset = consume(IToken.tLPAREN).getOffset(); + + // ( ) + if (optionalExpressionList && LT(1) == IToken.tRPAREN) { + initArray= IASTExpression.EMPTY_EXPRESSION_ARRAY; + } else { + final List exprList = expressionList(); + initArray = exprList.toArray(new IASTInitializerClause[exprList.size()]); + } + int endOffset = consumeOrEOC(IToken.tRPAREN).getEndOffset(); + return setRange(nodeFactory.newConstructorInitializer(initArray), offset, endOffset); + } - protected ICPPASTInitializer initializerClause(boolean inAggregateInitializer) throws EndOfFileException, + private List expressionList() throws EndOfFileException, BacktrackException { + return initializerList(false); + } + + /** + * initializer-clause: + * assignment-expression + * braced-init-list + */ + private IASTInitializerClause initClause(boolean inBraces) throws EndOfFileException, BacktrackException { + // braced-init-list if (LT(1) == IToken.tLBRACE) { - return initializerList(); + return bracedInitList(); } - // no brace, so try an assignment expression + // assignment expression final BinaryExprCtx ctx = fInTemplateParameterList ? BinaryExprCtx.eTmplID : BinaryExprCtx.eNoTmplID; IASTExpression assignmentExpression = expression(ExprKind.eAssignment, ctx); - if (inAggregateInitializer && skipTrivialExpressionsInAggregateInitializers) { + if (inBraces && skipTrivialExpressionsInAggregateInitializers) { if (!ASTQueries.canContainName(assignmentExpression)) return null; } - - ICPPASTInitializerExpression result = nodeFactory.newInitializerExpression(assignmentExpression); - setRange(result, assignmentExpression); - return result; + return assignmentExpression; } - private ICPPASTInitializerList initializerList() throws EndOfFileException, BacktrackException { - int startingOffset = consume(IToken.tLBRACE).getOffset(); - - ICPPASTInitializerList result = nodeFactory.newInitializerList(); - - // List of initializer clauses - while (LT(1) != IToken.tRBRACE && LT(1) != IToken.tEOC) { - // Clause may be null, add to initializer anyways, such that the - // actual size can be computed. - ICPPASTInitializer clause = initializerClause(true); - if (LT(1) == IToken.tELLIPSIS) { - clause.setIsPackExpansion(true); - adjustEndOffset(clause, consume().getEndOffset()); - } - result.addInitializer(clause); - if (LT(1) == IToken.tRBRACE || LT(1) == IToken.tEOC) - break; - consume(IToken.tCOMMA); // Allow for trailing commas + /** + * braced-init-list: + * { initializer-list ,opt } + * { } + */ + private ICPPASTInitializerList bracedInitList() throws EndOfFileException, BacktrackException { + int offset = consume(IToken.tLBRACE).getOffset(); + + // { } + if (LT(1) == IToken.tRBRACE) { + return setRange(nodeFactory.newInitializerList(), offset, consume().getEndOffset()); } - int endOffset = consume().getEndOffset(); // tRBRACE - setRange(result, startingOffset, endOffset); + + // { initializer-list ,opt } + List initList= initializerList(true); + if (LT(1) == IToken.tCOMMA) + consume(); + + int endOffset= consumeOrEOC(IToken.tRBRACE).getEndOffset(); + ICPPASTInitializerList result = nodeFactory.newInitializerList(); + for (IASTInitializerClause init : initList) { + result.addClause(init); + } + return setRange(result, offset, endOffset); + } + + /** + * initializerList: + * initializer-clause ...opt + * initializer-list , initializer-clause ...opt + */ + private List initializerList(boolean inAggregateInit) throws EndOfFileException, + BacktrackException { + + List result= null; + // List of initializer clauses + loop: for(;;) { + // Clause may be null, add to initializer anyways, such that the size can be computed. + IASTInitializerClause clause = initClause(inAggregateInit); + if (LT(1) == IToken.tELLIPSIS) { + final int endOffset = consume(IToken.tELLIPSIS).getEndOffset(); + if (clause instanceof ICPPASTPackExpandable) { + // Mark initializer lists directly as pack expansions + ((ICPPASTPackExpandable) clause).setIsPackExpansion(true); + adjustEndOffset(clause, endOffset); + } else if (clause instanceof IASTExpression){ + // Wrap pack expanded assignment expressions + IASTExpression packExpansion= nodeFactory.newPackExpansionExpression((IASTExpression) clause); + clause= setRange(packExpansion, clause, endOffset); + } + } + if (result == null) { + result= new ArrayList(); + } + result.add(clause); + if (LT(1) != IToken.tCOMMA) + break; + switch(LT(2)) { + case IToken.tRBRACE: + case IToken.tRPAREN: + case IToken.tEOC: + break loop; + } + consume(IToken.tCOMMA); + } + + if (result == null) + return Collections.emptyList(); + return result; } - @Override protected ICPPASTTypeId typeId(DeclarationOptions option) throws EndOfFileException { if (!canBeTypeSpecifier()) { @@ -3986,4 +4081,22 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { } return for_statement; } + + @Override + protected IASTStatement parseReturnStatement() throws EndOfFileException, BacktrackException { + final int offset= consume(IToken.t_return).getOffset(); // t_return + + // Optional expression + IASTInitializerClause expr = null; + final int lt1 = LT(1); + if (lt1 == IToken.tLBRACE) { + expr= bracedInitList(); + } else if (lt1 != IToken.tSEMI) { + expr = expression(); + } + // Semicolon + final int endOffset= consumeOrEOC(IToken.tSEMI).getEndOffset(); + + return setRange(nodeFactory.newReturnStatement(expr), offset, endOffset); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java index fc48735332a..0d16e654ce9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java @@ -41,15 +41,15 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier; +import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer; import org.eclipse.cdt.core.dom.ast.IASTExpression; -import org.eclipse.cdt.core.dom.ast.IASTExpressionList; import org.eclipse.cdt.core.dom.ast.IASTFieldReference; import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression; 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.IASTInitializer; -import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression; +import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; import org.eclipse.cdt.core.dom.ast.IASTLabelStatement; import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression; import org.eclipse.cdt.core.dom.ast.IASTName; @@ -83,6 +83,7 @@ import org.eclipse.cdt.core.dom.ast.IBasicType.Kind; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclarator; @@ -554,8 +555,8 @@ public class CPPSemantics { } if (parent.getPropertyInParent() == IASTFunctionCallExpression.FUNCTION_NAME) { parent = parent.getParent(); - IASTExpression exp = ((IASTFunctionCallExpression)parent).getParameterExpression(); - data.setFunctionArguments(exp); + IASTInitializerClause[] args = ((IASTFunctionCallExpression)parent).getArguments(); + data.setFunctionArguments(args); } } else if (parent instanceof ICPPASTFieldReference) { IASTNode grand= parent.getParent(); @@ -565,20 +566,30 @@ public class CPPSemantics { grand = grand.getParent(); } if (parent.getPropertyInParent() == IASTFunctionCallExpression.FUNCTION_NAME) { - IASTExpression exp = ((IASTFunctionCallExpression)parent.getParent()).getParameterExpression(); + IASTInitializerClause[] exp = ((IASTFunctionCallExpression)parent.getParent()).getArguments(); data.setFunctionArguments(exp); } } else if (parent instanceof ICPPASTNamedTypeSpecifier && parent.getParent() instanceof IASTTypeId) { IASTTypeId typeId = (IASTTypeId) parent.getParent(); if (typeId.getParent() instanceof ICPPASTNewExpression) { ICPPASTNewExpression newExp = (ICPPASTNewExpression) typeId.getParent(); - IASTExpression init = newExp.getNewInitializer(); - data.setFunctionArguments(init); + IASTInitializer init = newExp.getInitializer(); + if (init == null) { + data.setFunctionArguments(); + } else if (init instanceof ICPPASTConstructorInitializer) { + data.setFunctionArguments(((ICPPASTConstructorInitializer) init).getArguments()); + } else { + // mstodo handle braced init list + } } } else if (parent instanceof ICPPASTConstructorChainInitializer) { ICPPASTConstructorChainInitializer ctorinit = (ICPPASTConstructorChainInitializer) parent; - IASTExpression val = ctorinit.getInitializerValue(); - data.setFunctionArguments(val); + IASTInitializer init = ctorinit.getInitializer(); + if (init instanceof ICPPASTConstructorInitializer) { + data.setFunctionArguments(((ICPPASTConstructorInitializer) init).getArguments()); + } else { + // mstodo handle braced init list + } } return data; @@ -2350,8 +2361,8 @@ public class CPPSemantics { // target is an object or reference being initialized IASTDeclarator dtor = (IASTDeclarator) node.getParent(); return CPPVisitor.createType(dtor); - } else if (prop == IASTInitializerExpression.INITIALIZER_EXPRESSION) { - IASTInitializerExpression initExp = (IASTInitializerExpression) node.getParent(); + } else if (prop == IASTEqualsInitializer.INITIALIZER) { + IASTEqualsInitializer initExp = (IASTEqualsInitializer) node.getParent(); if (initExp.getParent() instanceof IASTDeclarator) { IASTDeclarator dtor = (IASTDeclarator) initExp.getParent(); return CPPVisitor.createType(dtor); @@ -2363,30 +2374,24 @@ public class CPPSemantics { IASTBinaryExpression binaryExp = (IASTBinaryExpression) node.getParent(); IASTExpression exp = binaryExp.getOperand1(); return exp.getExpressionType(); - } else if (prop == IASTFunctionCallExpression.PARAMETERS || - (prop == IASTExpressionList.NESTED_EXPRESSION && - node.getParent().getPropertyInParent() == IASTFunctionCallExpression.PARAMETERS)) { + } else if (prop == IASTFunctionCallExpression.ARGUMENT) { // target is a parameter of a function // if this function call refers to an overloaded function, there is more than one possibility // for the target type - IASTFunctionCallExpression fnCall = null; - int idx = -1; - if (prop == IASTFunctionCallExpression.PARAMETERS) { - fnCall = (IASTFunctionCallExpression) node.getParent(); - idx = 0; - } else { - IASTExpressionList list = (IASTExpressionList) node.getParent(); - fnCall = (IASTFunctionCallExpression) list.getParent(); - IASTExpression[] exps = list.getExpressions(); - for (int i = 0; i < exps.length; i++) { - if (exps[i] == node) { - idx = i; - break; - } - } - } + IASTFunctionCallExpression fnCall = (IASTFunctionCallExpression) node.getParent(); + int idx = 0; + final IASTInitializerClause[] arguments = fnCall.getArguments(); + for (IASTInitializerClause arg : arguments) { + if (arg == node) + break; + idx++; + } + if (idx >= arguments.length) + return null; + IFunctionType[] types = getPossibleFunctions(fnCall); - if (types == null) return null; + if (types == null) + return null; IType[] result = null; for (int i = 0; i < types.length && types[i] != null; i++) { IType[] pts = null; @@ -2596,21 +2601,13 @@ public class CPPSemantics { public static ICPPFunction findOverloadedOperator(IASTFunctionCallExpression exp, ICPPClassType type) { char[] name = OverloadableOperator.PAREN.toCharArray(); - IASTExpression param = exp.getParameterExpression(); - IASTExpression[] args; - if (param instanceof IASTExpressionList) { - IASTExpression[] actualArgs = ((IASTExpressionList)param).getExpressions(); - ArrayList argsToPass = new ArrayList(actualArgs.length + 1); - argsToPass.add(exp.getFunctionNameExpression()); - for (IASTExpression e : actualArgs) { - argsToPass.add(e); - } - args = argsToPass.toArray(new IASTExpression[argsToPass.size()]); - } else if (param != null) { - args = new IASTExpression[] { exp.getFunctionNameExpression(), param }; - } else { - args = new IASTExpression[] { exp.getFunctionNameExpression() }; + IASTInitializerClause[] args = exp.getArguments(); + ArrayList argsToPass = new ArrayList(args.length + 1); + argsToPass.add(exp.getFunctionNameExpression()); + for (IASTInitializerClause e : args) { + argsToPass.add(e); } + args = argsToPass.toArray(new IASTInitializerClause[argsToPass.size()]); return findOverloadedOperator(exp, args, type, name, NonMemberMode.none); } @@ -2627,17 +2624,15 @@ public class CPPSemantics { IASTExpression sizeExpression = new CPPASTTypeIdExpression(IASTTypeIdExpression.op_sizeof, typeId); sizeExpression.setParent(exp); - IASTExpression placement = exp.getNewPlacement(); - List args = new ArrayList(); + IASTInitializerClause[] placement = exp.getPlacementArguments(); + List args = new ArrayList(); args.add(sizeExpression); - if (placement instanceof IASTExpressionList) { - for (IASTExpression p : ((IASTExpressionList) placement).getExpressions()) + if (placement != null) { + for (IASTInitializerClause p : placement) { args.add(p); - } else if (placement != null) { - args.add(placement); - } - - IASTExpression[] argArray = args.toArray(new IASTExpression[args.size()]); + } + } + IASTInitializerClause[] argArray = args.toArray(new IASTInitializerClause[args.size()]); return findOverloadedOperator(exp, argArray, type, op.toCharArray(), NonMemberMode.all); } @@ -2758,7 +2753,7 @@ public class CPPSemantics { } enum NonMemberMode {none, limited, all} - private static ICPPFunction findOverloadedOperator(IASTExpression parent, IASTExpression[] args, IType methodLookupType, + private static ICPPFunction findOverloadedOperator(IASTExpression parent, IASTInitializerClause[] args, IType methodLookupType, char[] operatorName, NonMemberMode mode) { ICPPClassType callToObjectOfClassType= null; @@ -2820,7 +2815,10 @@ public class CPPSemantics { // 13.3.1.2.3 // However, if no operand type has class type, only those non-member functions ... if (mode == NonMemberMode.limited) { - IType type2= args.length < 2 ? null : getUltimateTypeUptoPointers(args[1].getExpressionType()); + IType type2= null; + if (args.length >= 2 && args[1] instanceof IASTExpression) { + type2= getUltimateTypeUptoPointers(((IASTExpression) args[1]).getExpressionType()); + } if (funcData.foundItems != null && !(methodLookupType instanceof ICPPClassType) && !(type2 instanceof ICPPClassType)) { IEnumeration enum1= null; IEnumeration enum2= null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java index bdc3b98b0ce..42324e7a76e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java @@ -29,6 +29,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier; +import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTFieldReference; import org.eclipse.cdt.core.dom.ast.IASTForStatement; @@ -39,7 +40,6 @@ import org.eclipse.cdt.core.dom.ast.IASTGotoStatement; import org.eclipse.cdt.core.dom.ast.IASTIdExpression; import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner; import org.eclipse.cdt.core.dom.ast.IASTInitializer; -import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression; import org.eclipse.cdt.core.dom.ast.IASTInitializerList; import org.eclipse.cdt.core.dom.ast.IASTLabelStatement; import org.eclipse.cdt.core.dom.ast.IASTName; @@ -56,7 +56,6 @@ import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.IASTStatement; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IASTTypeId; -import org.eclipse.cdt.core.dom.ast.IASTTypeIdInitializerExpression; import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression; import org.eclipse.cdt.core.dom.ast.IArrayType; import org.eclipse.cdt.core.dom.ast.IBasicType; @@ -106,7 +105,6 @@ 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.ICPPASTTemplatedTypeTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeId; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTWhileStatement; @@ -817,26 +815,37 @@ public class CPPVisitor extends ASTQueries { } else if (parent instanceof ICPPASTTemplateDeclaration) { return CPPTemplates.getContainingScope(node); } - } else if (node instanceof IASTInitializerExpression) { - IASTNode parent = node.getParent(); - while (!(parent instanceof IASTDeclarator || parent instanceof IASTTypeIdInitializerExpression)) - parent = parent.getParent(); - if(parent instanceof IASTDeclarator) { - IASTDeclarator dtor = (IASTDeclarator) parent; - IASTName name = dtor.getName(); - if (name instanceof ICPPASTQualifiedName) { - IASTName[] ns = ((ICPPASTQualifiedName) name).getNames(); - return getContainingScope(ns[ns.length - 1]); - } + } else if (node instanceof IASTInitializer) { + if (node instanceof ICPPASTConstructorChainInitializer) { + // The name of the member initializer is resolved in the scope of the + // owner of the ctor. + ICPPASTConstructorChainInitializer initializer = (ICPPASTConstructorChainInitializer) node; + IASTFunctionDefinition fdef= (IASTFunctionDefinition) initializer.getParent(); + IBinding binding = fdef.getDeclarator().getName().resolveBinding(); + try { + return binding.getScope(); + } catch (DOMException e) { + } + } else { + IASTNode parent = node.getParent(); + if (parent instanceof IASTDeclarator) { + IASTDeclarator dtor = (IASTDeclarator) parent; + IASTName name = dtor.getName(); + if (name instanceof ICPPASTQualifiedName) { + IASTName[] ns = ((ICPPASTQualifiedName) name).getNames(); + return getContainingScope(ns[ns.length - 1]); + } + } else if (parent instanceof ICPPASTConstructorChainInitializer) { + // The initializer for the member initializer is resolved in + // the body of the ctor. + IASTNode temp = getContainingBlockItem(node); + if (temp instanceof IASTFunctionDefinition) { + IASTCompoundStatement body = (IASTCompoundStatement) ((IASTFunctionDefinition)temp).getBody(); + return body.getScope(); + } + node= parent; + } } - } else if (node instanceof ICPPASTConstructorChainInitializer) { - ICPPASTConstructorChainInitializer initializer = (ICPPASTConstructorChainInitializer) node; - IASTFunctionDefinition fdef= (IASTFunctionDefinition) initializer.getParent(); - IBinding binding = fdef.getDeclarator().getName().resolveBinding(); - try { - return binding.getScope(); - } catch (DOMException e) { - } } else if (node instanceof IASTExpression) { IASTNode parent = node.getParent(); if (parent instanceof IASTForStatement) { @@ -849,27 +858,21 @@ public class CPPVisitor extends ASTQueries { return ((ICPPASTWhileStatement) parent).getScope(); } else if (parent instanceof IASTCompoundStatement) { return ((IASTCompoundStatement) parent).getScope(); - } else if (parent instanceof ICPPASTConstructorChainInitializer) { - IASTNode temp = getContainingBlockItem(parent); - if (temp instanceof IASTFunctionDefinition) { - IASTCompoundStatement body = (IASTCompoundStatement) ((IASTFunctionDefinition)temp).getBody(); - return body.getScope(); - } - } else if (parent instanceof IASTArrayModifier || parent instanceof IASTInitializer) { + } else if (parent instanceof IASTArrayModifier) { IASTNode d = parent.getParent(); - while (!(d instanceof IASTDeclarator || d instanceof IASTTypeIdInitializerExpression)) { + while (!(d instanceof IASTDeclarator || d instanceof IASTExpression)) { d = d.getParent(); } - if(d instanceof IASTDeclarator) { - IASTDeclarator dtor = (IASTDeclarator) d; - while (dtor.getNestedDeclarator() != null) - dtor = dtor.getNestedDeclarator(); - IASTName name = dtor.getName(); - if (name instanceof ICPPASTQualifiedName) { - IASTName[] ns = ((ICPPASTQualifiedName) name).getNames(); - return getContainingScope(ns[ns.length - 1]); - } - } + if (d instanceof IASTDeclarator) { + IASTDeclarator dtor = (IASTDeclarator) d; + while (dtor.getNestedDeclarator() != null) + dtor = dtor.getNestedDeclarator(); + IASTName name = dtor.getName(); + if (name instanceof ICPPASTQualifiedName) { + IASTName[] ns = ((ICPPASTQualifiedName) name).getNames(); + return getContainingScope(ns[ns.length - 1]); + } + } } else if (parent instanceof ICPPASTTemplateId && node.getPropertyInParent() == ICPPASTTemplateId.TEMPLATE_ID_ARGUMENT) { node= parent; // template-id @@ -1433,7 +1436,6 @@ public class CPPVisitor extends ASTQueries { case KIND_COMPOSITE: if (prop == IASTNamedTypeSpecifier.NAME || prop == ICPPASTPointerToMember.NAME || - prop == ICPPASTTypenameExpression.TYPENAME || prop == ICPPASTUsingDeclaration.NAME || prop == ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier.NAME || prop == ICPPASTTemplateId.TEMPLATE_NAME || @@ -1707,13 +1709,16 @@ public class CPPVisitor extends ASTQueries { type = createType(type, declarator); // C++ specification 8.3.4.3 and 8.5.1.4 - IASTInitializer initializer= declarator.getInitializer(); - if (initializer instanceof IASTInitializerList) { + IASTNode initClause= declarator.getInitializer(); + if (initClause instanceof IASTEqualsInitializer) { + initClause= ((IASTEqualsInitializer) initClause).getInitializerClause(); + } + if (initClause instanceof IASTInitializerList) { IType t= SemanticUtil.getNestedType(type, TDEF); if (t instanceof IArrayType) { IArrayType at= (IArrayType) t; if (at.getSize() == null) { - type= new CPPArrayType(at.getType(), Value.create(((IASTInitializerList) initializer).getSize())); + type= new CPPArrayType(at.getType(), Value.create(((IASTInitializerList) initClause).getSize())); } } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java index 3bc91ff21b5..a6739ee5254 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java @@ -27,12 +27,12 @@ import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTExpression; -import org.eclipse.cdt.core.dom.ast.IASTExpressionList; import org.eclipse.cdt.core.dom.ast.IASTFieldReference; import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression; import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; import org.eclipse.cdt.core.dom.ast.IASTIdExpression; import org.eclipse.cdt.core.dom.ast.IASTInitializer; +import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTNode; @@ -556,25 +556,7 @@ public class LookupData { return false; } - public void setFunctionArguments(IASTExpression args) { - IASTExpression[] exprs; - if (args instanceof IASTExpressionList) { - ASTNodeProperty prop = args.getPropertyInParent(); - if (prop == IASTFunctionCallExpression.PARAMETERS || prop == ICPPASTNewExpression.NEW_INITIALIZER - || prop == ICPPASTConstructorChainInitializer.INITIALIZER) { - exprs= ((IASTExpressionList) args).getExpressions(); - } else { - exprs= new IASTExpression[] {args}; - } - } else if (args != null) { - exprs= new IASTExpression[] { args }; - } else { - exprs = IASTExpression.EMPTY_EXPRESSION_ARRAY; - } - setFunctionArguments(exprs); - } - - public void setFunctionArguments(IASTExpression... exprs) { + public void setFunctionArguments(IASTInitializerClause... exprs) { functionArgs= exprs; if (exprs.length != 0) { IASTNode node= exprs[0]; @@ -607,13 +589,17 @@ public class LookupData { functionArgTypes[i] = SemanticUtil.getSimplifiedType(CPPVisitor.createParameterType( pdecls[i], true)); } - } else if (functionArgs instanceof IASTExpression[]) { - IASTExpression[] exprs= (IASTExpression[]) functionArgs; + } else if (functionArgs instanceof IASTInitializerClause[]) { + IASTInitializerClause[] exprs= (IASTInitializerClause[]) functionArgs; functionArgTypes= new IType[exprs.length]; for (int i = 0; i < exprs.length; i++) { - IASTExpression e = exprs[i]; - IType etype= e.getExpressionType(); - functionArgTypes[i]= SemanticUtil.getSimplifiedType(etype); + IASTInitializerClause e = exprs[i]; + if (e instanceof IASTExpression) { + IType etype= ((IASTExpression) e).getExpressionType(); + functionArgTypes[i]= SemanticUtil.getSimplifiedType(etype); + } else { + // mstodo handle braced init list + } } } } @@ -623,12 +609,14 @@ public class LookupData { public BitSet getFunctionArgumentLValues() { if (functionArgLValues == null) { functionArgLValues= new BitSet(); - IASTExpression[] args= getFunctionArguments(); + IASTInitializerClause[] args= getFunctionArguments(); if (args != null) { for (int i = 0; i < args.length; i++) { - final IASTExpression arg = args[i]; - if (arg != null) { - functionArgLValues.set(i, arg.isLValue()); + final IASTInitializerClause arg = args[i]; + if (arg instanceof IASTExpression) { + functionArgLValues.set(i, ((IASTExpression) arg).isLValue()); + } else { + // mstodo handle braced init list } } } else { @@ -653,9 +641,9 @@ public class LookupData { functionArgs= parameters; } - public IASTExpression[] getFunctionArguments() { - if (functionArgs instanceof IASTExpression[]) - return (IASTExpression[]) functionArgs; + public IASTInitializerClause[] getFunctionArguments() { + if (functionArgs instanceof IASTInitializerClause[]) + return (IASTInitializerClause[]) functionArgs; return null; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java index 75380101325..ce5714b5aa0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -27,7 +27,6 @@ import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.IASTTypeId; import org.eclipse.cdt.core.dom.ast.c.ICASTPointer; import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator; @@ -81,9 +80,6 @@ public class DeclaratorWriter extends NodeWriter { name.accept(visitor); IASTInitializer init = getInitializer(declarator); if(init!= null) { - if (! (init instanceof ICPPASTConstructorInitializer)) { - scribe.print(EQUALS); - } init.accept(visitor); } } @@ -109,7 +105,6 @@ public class DeclaratorWriter extends NodeWriter { private void writeInitializer(IASTStandardFunctionDeclarator funcDec) { IASTInitializer init = getInitializer(funcDec); if(init != null) { - scribe.print(EQUALS); init.accept(visitor); } } @@ -219,7 +214,6 @@ public class DeclaratorWriter extends NodeWriter { writeArrayModifiers(arrDecl, arrMods); IASTInitializer initializer = getInitializer(arrDecl); if(initializer != null) { - scribe.print(EQUALS); initializer.accept(visitor); } } @@ -253,7 +247,6 @@ public class DeclaratorWriter extends NodeWriter { fieldDecl.getBitFieldSize().accept(visitor); IASTInitializer initializer = getInitializer(fieldDecl); if(initializer != null) { - scribe.print(EQUALS); initializer.accept(visitor); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/InitializerWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/InitializerWriter.java index 33ad9d12aa3..6f3c8f2d40c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/InitializerWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/InitializerWriter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -12,8 +12,9 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.rewrite.astwriter; +import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer; import org.eclipse.cdt.core.dom.ast.IASTInitializer; -import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression; +import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; import org.eclipse.cdt.core.dom.ast.IASTInitializerList; import org.eclipse.cdt.core.dom.ast.c.ICASTArrayDesignator; import org.eclipse.cdt.core.dom.ast.c.ICASTDesignatedInitializer; @@ -43,8 +44,8 @@ public class InitializerWriter extends NodeWriter{ } protected void writeInitializer(IASTInitializer initializer) { - if (initializer instanceof IASTInitializerExpression) { - ((IASTInitializerExpression) initializer).getExpression().accept(visitor); + if (initializer instanceof IASTEqualsInitializer) { + writeEqualsInitializer((IASTEqualsInitializer) initializer); }else if (initializer instanceof IASTInitializerList) { writeInitializerList((IASTInitializerList) initializer); }else if (initializer instanceof ICPPASTConstructorInitializer) { @@ -59,23 +60,29 @@ public class InitializerWriter extends NodeWriter{ } + private void writeEqualsInitializer(IASTEqualsInitializer initializer) { + scribe.print(EQUALS); + IASTInitializerClause init = initializer.getInitializerClause(); + if (init != null) { + init.accept(visitor); + } + } + private void writeConstructorChainInitializer(ICPPASTConstructorChainInitializer initializer) { initializer.getMemberInitializerId().accept(visitor); - scribe.print('('); - initializer.getInitializerValue().accept(visitor); - scribe.print(')'); + initializer.getInitializer().accept(visitor); } private void writeInitializerList(IASTInitializerList initList) { scribe.printLBrace(); - IASTInitializer[] inits = initList.getInitializers(); + IASTInitializerClause[] inits = initList.getClauses(); writeNodeList(inits); scribe.printRBrace(); } private void writeConstructorInitializer(ICPPASTConstructorInitializer ctorInit) { scribe.print('('); - ctorInit.getExpression().accept(visitor); + writeNodeList(ctorInit.getArguments()); scribe.print(')'); } @@ -85,7 +92,7 @@ public class InitializerWriter extends NodeWriter{ writeDesignator(designator); } scribe.print(EQUALS); - desigInit.getOperandInitializer().accept(visitor); + desigInit.getOperand().accept(visitor); } private void writeDesignator(ICASTDesignator designator) { diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java index bfb37a8764e..c80856438f7 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java @@ -40,6 +40,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDefaultStatement; import org.eclipse.cdt.core.dom.ast.IASTDoStatement; import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier; +import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpressionList; import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement; @@ -53,7 +54,7 @@ import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; import org.eclipse.cdt.core.dom.ast.IASTIdExpression; import org.eclipse.cdt.core.dom.ast.IASTIfStatement; import org.eclipse.cdt.core.dom.ast.IASTInitializer; -import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression; +import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; import org.eclipse.cdt.core.dom.ast.IASTInitializerList; import org.eclipse.cdt.core.dom.ast.IASTLabelStatement; import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression; @@ -408,8 +409,8 @@ public class CodeFormatterVisitor extends CPPASTVisitor { if (!startNode(node)) { return PROCESS_SKIP; } try { - if (node instanceof IASTInitializerExpression) { - visit((IASTInitializerExpression)node); + if (node instanceof IASTEqualsInitializer) { + visit((IASTEqualsInitializer) node); } else if (node instanceof IASTInitializerList) { visit((IASTInitializerList)node); } else if (node instanceof ICASTDesignatedInitializer) { @@ -956,7 +957,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor { if (!startNode(node)) { return PROCESS_SKIP; } try { // format like a function call - formatFunctionCallArguments(node.getExpression()); + formatFunctionCallArguments(node.getArguments()); } finally { endOfNode(node); } @@ -965,10 +966,10 @@ public class CodeFormatterVisitor extends CPPASTVisitor { private int visit(ICPPASTConstructorChainInitializer node) { final IASTName member= node.getMemberInitializerId(); - if (member!= null) { + final IASTInitializer init= node.getInitializer(); + if (member!= null && init != null) { member.accept(this); - // format like a function call - formatFunctionCallArguments(node.getInitializerValue()); + init.accept(this); } else { formatRaw(node); } @@ -1825,9 +1826,9 @@ public class CodeFormatterVisitor extends CPPASTVisitor { private int visit(IASTFunctionCallExpression node) { node.getFunctionNameExpression().accept(this); - IASTExpression paramExpr= node.getParameterExpression(); + IASTInitializerClause[] paramExpr= node.getArguments(); if (peekNextToken() == Token.tIDENTIFIER) { - skipNode(paramExpr); + skipNode(node); } else { formatFunctionCallArguments(paramExpr); } @@ -1839,17 +1840,10 @@ public class CodeFormatterVisitor extends CPPASTVisitor { * * @param argumentExpr the argument expression, may be null */ - private void formatFunctionCallArguments(IASTExpression argumentExpr) { - final List expressions; - if (argumentExpr != null) { - if (argumentExpr instanceof IASTExpressionList) { - // argument list - final IASTExpressionList exprList= (IASTExpressionList)argumentExpr; - expressions= Arrays.asList(exprList.getExpressions()); - } else { - // single argument - expressions= Collections.singletonList(argumentExpr); - } + private void formatFunctionCallArguments(IASTInitializerClause[] args) { + final List expressions; + if (args != null) { + expressions= Arrays.asList(args); } else { // no arguments expressions= Collections.emptyList(); @@ -1941,10 +1935,11 @@ public class CodeFormatterVisitor extends CPPASTVisitor { return PROCESS_SKIP; } - private int visit(IASTInitializerExpression node) { + private int visit(IASTEqualsInitializer node) { if (node.getPropertyInParent() == IASTInitializerList.NESTED_INITIALIZER) { + assert false; // nested initializer expression, no need to apply extra alignment - node.getExpression().accept(this); + // node.getExpression().accept(this); } else { // declaration initializer Alignment expressionAlignment= scribe.createAlignment( @@ -1960,7 +1955,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor { try { scribe.alignFragment(expressionAlignment, 0); - node.getExpression().accept(this); + node.getInitializerClause().accept(this); ok = true; } catch (AlignmentException e) { @@ -1975,7 +1970,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor { private int visit(IASTInitializerList node) { scribe.printComment(); - final List initializers = Arrays.asList(node.getInitializers()); + final List initializers = Arrays.asList(node.getClauses()); if (initializers.isEmpty() && preferences.keep_empty_initializer_list_on_one_line) { scribe.printNextToken(Token.tLBRACE, preferences.insert_space_before_opening_brace_in_initializer_list); scribe.printNextToken(Token.tRBRACE, preferences.insert_space_between_empty_braces_in_initializer_list); @@ -2071,7 +2066,6 @@ public class CodeFormatterVisitor extends CPPASTVisitor { } operand.accept(this); break; - case IASTUnaryExpression.op_typeof: case IASTUnaryExpression.op_alignOf: default: int operatorToken= peekNextToken(); @@ -2277,9 +2271,9 @@ public class CodeFormatterVisitor extends CPPASTVisitor { scribe.space(); // placement - final IASTExpression newPlacement= node.getNewPlacement(); + final IASTInitializerClause[] newPlacement= node.getPlacementArguments(); if (newPlacement != null) { - formatParenthesizedExpression(newPlacement); + formatFunctionCallArguments(newPlacement); } // type-id @@ -2295,9 +2289,9 @@ public class CodeFormatterVisitor extends CPPASTVisitor { } // initializer - final IASTExpression newInitializer= node.getNewInitializer(); - if (newInitializer != null || peekNextToken() == Token.tLPAREN) { - formatFunctionCallArguments(newInitializer); + final IASTInitializer newInitializer= node.getInitializer(); + if (newInitializer != null) { + visit(newInitializer); } return PROCESS_SKIP; } @@ -2324,6 +2318,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor { } private int visit(ICPPASTSimpleTypeConstructorExpression node) { + // tletodo The first part of the expression can consist of multiple tokens scribe.printNextToken(peekNextToken()); final IASTExpression operand= node.getInitialValue(); formatParenthesizedExpression(operand); diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/MachOParser64.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/MachOParser64.java index fdd2b895f52..36c3ea43c2a 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/MachOParser64.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/MachOParser64.java @@ -118,7 +118,6 @@ public class MachOParser64 extends AbstractCExtension implements IBinaryParser { return cppfilt; } - @SuppressWarnings("deprecation") protected IPath getCPPFiltPath() { ICConfigExtensionReference ref = getConfigExtensionReference(); String value = ref.getExtensionData("c++filt"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoring.java index 018f2bd5aca..41ee41e4d7a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoring.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoring.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -33,9 +33,9 @@ import org.eclipse.text.edits.TextEditGroup; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; +import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; -import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression; import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression; import org.eclipse.cdt.core.dom.ast.IASTMacroExpansionLocation; import org.eclipse.cdt.core.dom.ast.IASTName; @@ -52,8 +52,8 @@ import org.eclipse.cdt.core.dom.rewrite.ASTRewrite; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDeclarator; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTEqualsInitializer; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTInitializerExpression; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNamespaceDefinition; @@ -373,12 +373,12 @@ public class ExtractConstantRefactoring extends CRefactoring { declSpec.setType(IASTSimpleDeclSpecifier.t_int); break; case IASTLiteralExpression.lk_string_literal: - declSpec.setType(ICPPASTSimpleDeclSpecifier.t_wchar_t); + declSpec.setType(IASTSimpleDeclSpecifier.t_wchar_t); break; case IASTLiteralExpression.lk_false: //Like lk_true a boolean type case IASTLiteralExpression.lk_true: - declSpec.setType(ICPPASTSimpleDeclSpecifier.t_bool); + declSpec.setType(IASTSimpleDeclSpecifier.t_bool); break; case IASTLiteralExpression.lk_this: break; @@ -390,13 +390,13 @@ public class ExtractConstantRefactoring extends CRefactoring { IASTDeclarator decl = new CPPASTDeclarator(); IASTName name = new CPPASTName(newName.toCharArray()); decl.setName(name); - IASTInitializerExpression init = new CPPASTInitializerExpression(); + IASTEqualsInitializer init = new CPPASTEqualsInitializer(); if (target.getParent() instanceof IASTUnaryExpression) { IASTUnaryExpression unary = (IASTUnaryExpression) target.getParent(); - init.setExpression(unary); + init.setInitializerClause(unary); } else { CPPASTLiteralExpression expression = new CPPASTLiteralExpression(target.getKind(), target.getValue()); - init.setExpression(expression); + init.setInitializerClause(expression); } decl.setInitializer(init); simple.addDeclarator(decl); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java index f5f05d9b3a6..491c71aab75 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -42,6 +42,7 @@ import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; +import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpressionList; import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement; @@ -49,7 +50,6 @@ import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression; 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.IASTInitializerExpression; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTNode; @@ -85,12 +85,12 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTBinaryExpression; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCompoundStatement; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDeclarationStatement; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDeclarator; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTEqualsInitializer; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTExpressionList; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTExpressionStatement; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionCallExpression; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDefinition; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTInitializerExpression; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTQualifiedName; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTReturnStatement; @@ -831,8 +831,8 @@ public class ExtractFunctionRefactoring extends CRefactoring { declarator.addPointerOperator(pointer.copy()); } - IASTInitializerExpression initializer = new CPPASTInitializerExpression(); - initializer.setExpression(callExpression); + IASTEqualsInitializer initializer = new CPPASTEqualsInitializer(); + initializer.setInitializerClause(callExpression); declarator.setInitializer(initializer); decl.addDeclarator(declarator); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoring.java index eca1a2c0914..ce22598e788 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoring.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoring.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Google and others. All rights reserved. This program and + * Copyright (c) 2008, 2010 Google and others. All rights reserved. This program and * the accompanying materials are made available under the terms of the Eclipse * Public License v1.0 which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html @@ -32,11 +32,11 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; +import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.core.dom.ast.IASTForStatement; import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; -import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression; import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; @@ -52,8 +52,8 @@ import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDeclarationStatement; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDeclarator; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTEqualsInitializer; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTInitializerExpression; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclaration; @@ -308,8 +308,8 @@ public class ExtractLocalVariableRefactoring extends CRefactoring { IASTName name = new CPPASTName(newName.toCharArray()); decl.setName(name); - IASTInitializerExpression init = new CPPASTInitializerExpression(); - init.setExpression(deblock(target.copy())); + IASTEqualsInitializer init = new CPPASTEqualsInitializer(); + init.setInitializerClause(deblock(target.copy())); decl.setInitializer(init); simple.addDeclarator(decl);