mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Bug 551689 - Fix equivalence computation for simple literals
We were using equals() on char[] array objects which returned false if the objects were distinct, even if they contained the same characters. Change-Id: Iff5da52c67a0c17d857d791f57e768aafa7e165d
This commit is contained in:
parent
5c77776dcd
commit
02789c6a1e
4 changed files with 22 additions and 3 deletions
|
@ -103,6 +103,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionCallExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionCallExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
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.ICPPASTFunctionDefinition;
|
||||||
|
@ -13407,4 +13408,22 @@ public class AST2CPPTests extends AST2CPPTestBase {
|
||||||
public void testClassFromInitList_549036() throws Exception {
|
public void testClassFromInitList_549036() throws Exception {
|
||||||
parseAndCheckImplicitNameBindings();
|
parseAndCheckImplicitNameBindings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// int a = 42, b = 42;
|
||||||
|
// float c = 3.14, d = 3.14;
|
||||||
|
// char e[] = "waldo", f[] = "waldo";
|
||||||
|
public void testLiteralExpressionEquivalence_551689() throws Exception {
|
||||||
|
BindingAssertionHelper helper = getAssertionHelper();
|
||||||
|
ICPPASTExpression a = helper.assertNode("a = 42", "42");
|
||||||
|
ICPPASTExpression b = helper.assertNode("b = 42", "42");
|
||||||
|
assertTrue(a.getEvaluation().isEquivalentTo(b.getEvaluation()));
|
||||||
|
|
||||||
|
ICPPASTExpression c = helper.assertNode("c = 3.14", "3.14");
|
||||||
|
ICPPASTExpression d = helper.assertNode("d = 3.14", "3.14");
|
||||||
|
assertTrue(c.getEvaluation().isEquivalentTo(d.getEvaluation()));
|
||||||
|
|
||||||
|
ICPPASTExpression e = helper.assertNode("e[] = \"waldo\"", "\"waldo\"");
|
||||||
|
ICPPASTExpression f = helper.assertNode("f[] = \"waldo\"", "\"waldo\"");
|
||||||
|
assertTrue(e.getEvaluation().isEquivalentTo(f.getEvaluation()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,6 +251,6 @@ public final class CStringValue implements IValue {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CStringValue o = (CStringValue) other;
|
CStringValue o = (CStringValue) other;
|
||||||
return fFixedValue.equals(o.fFixedValue);
|
return CharArrayUtils.equals(fFixedValue, o.fFixedValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -182,6 +182,6 @@ public final class FloatingPointValue implements IValue {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
FloatingPointValue o = (FloatingPointValue) other;
|
FloatingPointValue o = (FloatingPointValue) other;
|
||||||
return fFixedValue.equals(o.fFixedValue);
|
return CharArrayUtils.equals(fFixedValue, o.fFixedValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -297,6 +297,6 @@ public class IntegralValue implements IValue {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
IntegralValue o = (IntegralValue) other;
|
IntegralValue o = (IntegralValue) other;
|
||||||
return fFixedValue.equals(o.fFixedValue);
|
return CharArrayUtils.equals(fFixedValue, o.fFixedValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue