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 858e8723c9f..f3542d29009 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 @@ -8882,7 +8882,23 @@ public class AST2CPPTests extends AST2TestBase { public void testListInitialization_458679() throws Exception { parseAndCheckImplicitNameBindings(); } - + + // namespace std { template class initializer_list; } + // + // struct A { + // A(const char* s); + // }; + // + // void waldo(A p); + // void waldo(std::initializer_list p); + // + // void test() { + // waldo({""}); + // } + public void testListInitialization_491842() throws Exception { + parseAndCheckBindings(); + } + // namespace std { // template class initializer_list; // } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java index 03115494616..227d06c0e77 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java @@ -608,7 +608,7 @@ public class Conversions { ICPPConstructor[] filteredConstructors = constructors; if (expandedArgs.length == 1) { filteredConstructors= new ICPPConstructor[constructors.length]; - int j=0; + int j= 0; for (ICPPConstructor ctor : constructors) { if (ctor.getRequiredArgumentCount() < 2) { IType[] ptypes= ctor.getType().getParameterTypes(); @@ -633,6 +633,11 @@ public class Conversions { } else { c= Cost.NO_CONVERSION; } + // This cost came from listInitializationSequence() with an std::initializer_list + // type as the list initialization target. From the point of view of the caller, + // however, the target is the class type, not std::initializer_list, so update it + // accordingly. + c.setListInitializationTarget(t); return c; }