1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 17:35:35 +02:00

Add another integer conversion test for issue 265

Bug: https://github.com/eclipse-cdt/cdt/issues/265
This commit is contained in:
Igor V. Kovalenko 2023-01-30 19:42:29 +03:00 committed by Jonah Graham
parent c0220469ad
commit dc8313b304

View file

@ -13821,4 +13821,28 @@ public class AST2CPPTests extends AST2CPPTestBase {
// Invalid argument (not null pointer constant)
assertTrue(collector.getName(callIndexStart + 13).resolveBinding() instanceof IProblemBinding);
}
// template <typename SignedType, typename UnsignedType>
// constexpr bool calculate(SignedType x, UnsignedType y) {
// if (sizeof(x) == sizeof(y)) {
// return x - y >= 0;
// } else {
// return true;
// }
// }
//
// constexpr auto test_32 = calculate<signed long, unsigned int>(1, 2);
// constexpr auto test_64 = calculate<signed long long, unsigned long>(1, 2);
public void testArithmeticConversionIssue_265() throws Exception {
// Depending on size of integer types above it may happen that the rank of unsigned type operand
// is less than rank of signed type operand, and both types are of same size.
// If so the conversion is to unsigned integer type corresponding to the type of the operand
// with signed integer type, and calculated result cannot be less than zero - check it.
// 32-bit case used to fail with signed long and unsigned int,
// 64-bit case used to fail with signed long long and unsigned long.
parseAndCheckBindings();
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableValue("test_32", 1);
helper.assertVariableValue("test_64", 1);
}
}