From ed2d483f12e5bdd0e87525c6ad14bb22e9f9d672 Mon Sep 17 00:00:00 2001 From: Chris Recoskie Date: Wed, 1 Sep 2010 13:41:49 +0000 Subject: Bug 324150 - LR Parser's action class CPPBuildASTParserAction throws UnsupportedOperationException by its function consumeDeclarationSimple. --- .../cdt/core/dom/lrparser/action/cpp/CPPBuildASTParserAction.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lrparser/org.eclipse.cdt.core.lrparser') diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPBuildASTParserAction.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPBuildASTParserAction.java index a7ca0726c84..3a4c71e29fb 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPBuildASTParserAction.java +++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPBuildASTParserAction.java @@ -15,6 +15,7 @@ import static org.eclipse.cdt.core.parser.util.CollectionUtils.findFirstAndRemov import static org.eclipse.cdt.core.parser.util.CollectionUtils.reverseIterable; import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.*; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.LinkedList; @@ -1176,7 +1177,7 @@ public class CPPBuildASTParserAction extends BuildASTParserAction { * ::= declaration_specifiers_opt init_declarator_list_opt ';' */ public void consumeDeclarationSimple(boolean hasDeclaratorList) { - List declarators = hasDeclaratorList ? astStack.closeScope() : Collections.emptyList(); + List declarators = hasDeclaratorList ? astStack.closeScope() : new ArrayList(); ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) astStack.pop(); // may be null List ruleTokens = stream.getRuleTokens(); @@ -1194,7 +1195,7 @@ public class CPPBuildASTParserAction extends BuildASTParserAction { IASTName name = createName(stream.getLeftIToken()); declSpec = nodeFactory.newTypedefNameSpecifier(name); ParserUtil.setOffsetAndLength(declSpec, offset(name), length(name)); - declarators = Collections.emptyList(); // throw away the bogus declarator + declarators = new ArrayList(); // throw away the bogus declarator } // can happen if implicit int is used @@ -1211,8 +1212,9 @@ public class CPPBuildASTParserAction extends BuildASTParserAction { // bug 80171, check for situation similar to: static var; // this will get parsed wrong, the following is a hack to rebuild the AST as it should have been parsed + // exclude syntax "friend xxx" else if(declarators.isEmpty() && - declSpec instanceof ICPPASTNamedTypeSpecifier && + declSpec instanceof ICPPASTNamedTypeSpecifier && ! declSpec.isFriend() && ruleTokens.size() >= 2 && baseKind(nameToken = ruleTokens.get(ruleTokens.size() - 2)) == TK_identifier) { -- cgit v1.2.3