Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Recoskie2010-09-01 09:41:49 -0400
committerChris Recoskie2010-09-01 09:41:49 -0400
commited2d483f12e5bdd0e87525c6ad14bb22e9f9d672 (patch)
tree7d0fd701394c5cf63723a2adfe37ea5c07af4d4c /lrparser
parent6a00f7487a06bb857117a2e226f20f8dbf92fe8f (diff)
downloadorg.eclipse.cdt-ed2d483f12e5bdd0e87525c6ad14bb22e9f9d672.tar.gz
org.eclipse.cdt-ed2d483f12e5bdd0e87525c6ad14bb22e9f9d672.tar.xz
org.eclipse.cdt-ed2d483f12e5bdd0e87525c6ad14bb22e9f9d672.zip
Bug 324150 - LR Parser's action class CPPBuildASTParserAction throws UnsupportedOperationException by its function consumeDeclarationSimple.
Diffstat (limited to 'lrparser')
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPBuildASTParserAction.java8
1 files changed, 5 insertions, 3 deletions
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 a7ca0726c8..3a4c71e29f 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 <openscope-ast> init_declarator_list_opt ';'
*/
public void consumeDeclarationSimple(boolean hasDeclaratorList) {
- List<Object> declarators = hasDeclaratorList ? astStack.closeScope() : Collections.emptyList();
+ List<Object> declarators = hasDeclaratorList ? astStack.closeScope() : new ArrayList<Object>();
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) astStack.pop(); // may be null
List<IToken> 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<Object>(); // 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) {

Back to the top