diff options
author | Markus Schorn | 2009-01-16 15:19:25 +0000 |
---|---|---|
committer | Markus Schorn | 2009-01-16 15:19:25 +0000 |
commit | a860fe6af94b064a541e894e38c7f42adda3ffe6 (patch) | |
tree | bb6bf57609c1531a182884ee847ecc44b6c0176d | |
parent | 86d9b5e48f06343bf1d822438c98158de1c5dfdf (diff) | |
download | org.eclipse.cdt-a860fe6af94b064a541e894e38c7f42adda3ffe6.tar.gz org.eclipse.cdt-a860fe6af94b064a541e894e38c7f42adda3ffe6.tar.xz org.eclipse.cdt-a860fe6af94b064a541e894e38c7f42adda3ffe6.zip |
Failure to update AST in ambiguity resolution, bug 261043.
2 files changed, 32 insertions, 18 deletions
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 54d3c8d4f4a..c94159e2369 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 @@ -5359,4 +5359,19 @@ public class AST2Tests extends AST2BaseTest { parseAndCheckBindings(code, ParserLanguage.C, true); parseAndCheckBindings(code, ParserLanguage.CPP, true); } + + // void test() { + // int a,b; + // if ((a)+b); + // } + public void testAmbiguityResolutionInIfCondition_Bug261043() throws Exception { + final String code= getAboveComment(); + for (ParserLanguage lang : ParserLanguage.values()) { + IASTTranslationUnit tu= parseAndCheckBindings(code, lang, true); + IASTFunctionDefinition fdef= getDeclaration(tu, 0); + IASTIfStatement ifstmt= getStatement(fdef, 1); + IASTExpression expr= ifstmt.getConditionExpression(); + assertInstance(expr, IASTBinaryExpression.class); + } + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTIfStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTIfStatement.java index 93a08ac6c43..1e07ebe4c81 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTIfStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTIfStatement.java @@ -108,24 +108,23 @@ public class CPPASTIfStatement extends CPPASTNode implements ICPPASTIfStatement, } public void replace(IASTNode child, IASTNode other) { - if( thenClause == child ) - { - other.setParent( child.getParent() ); - other.setPropertyInParent( child.getPropertyInParent() ); - thenClause = (IASTStatement) other; - } - else if( elseClause == child ) - { - other.setParent( child.getParent() ); - other.setPropertyInParent( child.getPropertyInParent() ); - elseClause = (IASTStatement) other; - } - if( condDecl == child ) - { - other.setParent( child.getParent() ); - other.setPropertyInParent( child.getPropertyInParent() ); - condDecl = (IASTDeclaration) other; - } + if (thenClause == child) { + other.setParent(child.getParent()); + other.setPropertyInParent(child.getPropertyInParent()); + thenClause = (IASTStatement) other; + } else if (elseClause == child) { + other.setParent(child.getParent()); + other.setPropertyInParent(child.getPropertyInParent()); + elseClause = (IASTStatement) other; + } else if (condDecl == child) { + other.setParent(child.getParent()); + other.setPropertyInParent(child.getPropertyInParent()); + condDecl = (IASTDeclaration) other; + } else if (condition == child) { + other.setParent(child.getParent()); + other.setPropertyInParent(child.getPropertyInParent()); + condition = (IASTExpression) other; + } } public IASTDeclaration getConditionDeclaration() { |