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/cpp/semantics/EvalTypeId.java11
2 files changed, 24 insertions, 1 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 40f235a4f4b..adfb3bedc7c 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
@@ -13405,4 +13405,18 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testAggregateInitOfAnonymousUnion_549362() throws Exception {
parseAndCheckImplicitNameBindings();
}
+
+ // namespace std {
+ // template<typename T> class initializer_list;
+ // }
+ //
+ // struct A {
+ // A(std::initializer_list<int> list)
+ // {}
+ // };
+ //
+ // auto a = A{1, 2};
+ public void testClassFromInitList_549036() throws Exception {
+ parseAndCheckImplicitNameBindings();
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java
index 85bd7612c16..291a175a599 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java
@@ -300,8 +300,17 @@ public class EvalTypeId extends CPPDependentEvaluation {
ICPPClassType classType = (ICPPClassType) simplifiedType;
ICPPEvaluation[] arguments = fArguments;
ICPPConstructor[] constructors = classType.getConstructors();
- if (arguments.length == 1 && arguments[0] instanceof EvalInitList && !fUsesBracedInitList) {
+ if (fUsesBracedInitList && arguments.length > 0) {
// List-initialization of a class (dcl.init.list-3).
+ // e.g. A{1,2}
+ ICPPConstructor[] ctors = getInitializerListConstructors(constructors);
+ if (ctors.length != 0) {
+ constructors = ctors;
+ arguments = new EvalInitList[] { new EvalInitList(arguments, getTemplateDefinition()) };
+ }
+ } else if (arguments.length == 1 && arguments[0] instanceof EvalInitList && !fUsesBracedInitList) {
+ // List-initialization of a class (dcl.init.list-3).
+ // e.g. A({1,2})
if (TypeTraits.isAggregateClass(classType)) {
// Pretend that aggregate initialization is calling the default constructor.
return findDefaultConstructor(classType, constructors);

Back to the top