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

Bug 521543 - Correctly identify narrowing conversion to boolean

Change-Id: I07672f5043cbb68070185d3d7d4993794b9caa2b
This commit is contained in:
Nathan Ridge 2017-08-30 19:20:50 -04:00
parent e75a209b9f
commit 47fe12a179
2 changed files with 17 additions and 0 deletions

View file

@ -9850,6 +9850,20 @@ public class AST2CPPTests extends AST2CPPTestBase {
dtor= (IASTImplicitNameOwner) name.getParent();
assertSame(ctor3, dtor.getImplicitNames()[0].resolveBinding());
}
// struct S {
// bool a;
// int b;
// };
//
// void waldo(S);
//
// int main() {
// waldo({1, 2});
// }
public void testIntToBoolConversionInInitList_521543() throws Exception {
parseAndCheckBindings();
}
// namespace A {
// inline namespace B {

View file

@ -341,6 +341,9 @@ public abstract class ArithmeticConversion {
public static boolean fitsIntoType(IBasicType basicTarget, long n) {
final Kind kind = basicTarget.getKind();
switch (kind) {
case eBoolean:
return n == 0 || n == 1;
case eInt:
if (!basicTarget.isUnsigned()) {
if (basicTarget.isShort()) {