diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java index e2a6fbaf2f7..69d883daa88 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java @@ -11607,4 +11607,14 @@ public class AST2TemplateTests extends AST2CPPTestBase { public void testRecognizeConstructorWithSemicolonAfterBody() throws Exception { parseAndCheckImplicitNameBindings(); } + + // template + // void f() { + // struct S { + // T t; + // } s {}; + // }; + public void testAllowAggregateInitializationInTemplateBody() throws Exception { + parseAndCheckImplicitNameBindings(); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AggregateInitialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AggregateInitialization.java index 0f6eae40b77..c4dde1cd9e0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AggregateInitialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AggregateInitialization.java @@ -64,7 +64,11 @@ class AggregateInitialization { * else recurses into the subaggregate. */ private Cost checkElement(IType type, IValue initialValue, Cost worstCost) throws DOMException { - assert !CPPTemplates.isDependentType(type); + if (CPPTemplates.isDependentType(type)) { + // We can only get here looking for initialization constructor while scanning for implicit names. + // Return trivial conversion cost and no constructor because type is unknown at this point. + return new Cost(type, type, Rank.IDENTITY); + } IType nestedType = SemanticUtil.getNestedType(type, SemanticUtil.TDEF); if (fIndex >= fInitializers.length) // TODO for arrays we could short-circuit default init instead of trying to init each element