Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Kucera2008-04-04 15:12:22 +0000
committerMike Kucera2008-04-04 15:12:22 +0000
commit5297a903b036d28bc5cef4227a0013dab1793093 (patch)
treee4ab3dc274f594b9b166781099dbe6abf40337e8 /lrparser
parent1fd0bf48d8f1d5361cc77dabd6f6c1baf050b8eb (diff)
downloadorg.eclipse.cdt-5297a903b036d28bc5cef4227a0013dab1793093.tar.gz
org.eclipse.cdt-5297a903b036d28bc5cef4227a0013dab1793093.tar.xz
org.eclipse.cdt-5297a903b036d28bc5cef4227a0013dab1793093.zip
dummy name nodes no longer counted as problems when resolving ambiguous declarator
Diffstat (limited to 'lrparser')
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/cpp/ISOCPPTests.java28
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/BuildASTParserAction.java2
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPASTAmbiguousDeclarator.java28
3 files changed, 47 insertions, 11 deletions
diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/cpp/ISOCPPTests.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/cpp/ISOCPPTests.java
index a9619da15cb..938f4a28df1 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/cpp/ISOCPPTests.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/cpp/ISOCPPTests.java
@@ -70,4 +70,32 @@ public class ISOCPPTests extends AST2CPPTests {
} catch(AssertionFailedError _) {
}
}
+
+ @Override
+ public void testBug108202() throws Exception { // gcc attributes not supported
+ try {
+ super.testBug108202();
+ fail();
+ } catch(AssertionFailedError _) {
+ }
+ }
+
+
+ @Override
+ public void testBug195701() throws Exception { // gcc attributes not supported
+ try {
+ super.testBug195701();
+ fail();
+ } catch(AssertionFailedError _) {
+ }
+ }
+
+ @Override
+ public void testBug179712() throws Exception { // gcc attributes not supported
+ try {
+ super.testBug179712();
+ fail();
+ } catch(AssertionFailedError _) {
+ }
+ }
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/BuildASTParserAction.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/BuildASTParserAction.java
index 48fc7563829..b3000630440 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/BuildASTParserAction.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/BuildASTParserAction.java
@@ -613,8 +613,6 @@ public abstract class BuildASTParserAction {
public void consumeExpressionName() {
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
- System.out.println("Exression name: " + parser.getRuleTokens());
-
IASTName name = (IASTName) astStack.pop();
IASTIdExpression expr = nodeFactory.newIdExpression(name);
setOffsetAndLength(expr);
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPASTAmbiguousDeclarator.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPASTAmbiguousDeclarator.java
index bbbc784d742..f7ff4a1def3 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPASTAmbiguousDeclarator.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPASTAmbiguousDeclarator.java
@@ -19,10 +19,14 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTAmbiguity;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
+@SuppressWarnings("restriction")
public class CPPASTAmbiguousDeclarator extends CPPASTAmbiguity implements IASTDeclarator {
private List<IASTDeclarator> declarators = new ArrayList<IASTDeclarator>(2);
+ private int defaultDeclarator = 0;
+
+
public CPPASTAmbiguousDeclarator(IASTDeclarator ... ds) {
for(IASTDeclarator declarator : ds)
addDeclarator(declarator);
@@ -45,6 +49,7 @@ public class CPPASTAmbiguousDeclarator extends CPPASTAmbiguity implements IASTDe
int[] problems = new int[nodez.length];
for(int i = 0; i < nodez.length; ++i) {
+ defaultDeclarator = i;
IASTNode node = nodez[i];
owner.replace(nodeToReplace, node);
nodeToReplace = node;
@@ -54,14 +59,17 @@ public class CPPASTAmbiguousDeclarator extends CPPASTAmbiguity implements IASTDe
node.accept(nameCollector);
IASTName[] names = nameCollector.getNames();
for(IASTName name : names) {
- try {
- IBinding b = name.resolveBinding();
- if(b == null || b instanceof IProblemBinding)
- ++problems[i];
- } catch (Exception t) {
- t.printStackTrace();
- ++problems[i];
- }
+ if(name.toCharArray().length > 0) { // don't count dummy name nodes
+ try {
+ IBinding b = name.resolveBinding();
+ if(b == null || b instanceof IProblemBinding) {
+ ++problems[i];
+ }
+ } catch (Exception t) {
+ t.printStackTrace();
+ ++problems[i];
+ }
+ }
}
if(names.length > 0) {
IScope scope = CPPVisitor.getContainingScope(names[0]);
@@ -77,6 +85,7 @@ public class CPPASTAmbiguousDeclarator extends CPPASTAmbiguity implements IASTDe
}
}
}
+
int bestIndex = 0;
int bestValue = problems[0];
for (int i = 1; i < problems.length; ++i) {
@@ -88,6 +97,7 @@ public class CPPASTAmbiguousDeclarator extends CPPASTAmbiguity implements IASTDe
//IASTAmbiguityParent owner = (IASTAmbiguityParent) getParent();
owner.replace(nodeToReplace, nodez[bestIndex]);
+ defaultDeclarator = 0;
return true;
}
@@ -100,7 +110,7 @@ public class CPPASTAmbiguousDeclarator extends CPPASTAmbiguity implements IASTDe
}
private IASTDeclarator getDefaultDeclarator() {
- return declarators.get(0);
+ return declarators.get(defaultDeclarator);
}
public void addPointerOperator(IASTPointerOperator operator) {

Back to the top