Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java14
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ArithmeticConversion.java3
2 files changed, 17 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
index fa70316b125..3259e16e93b 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
@@ -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 {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ArithmeticConversion.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ArithmeticConversion.java
index 26728ebdc3c..0c9937daa5b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ArithmeticConversion.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ArithmeticConversion.java
@@ -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()) {

Back to the top