Skip to content

Commit

Permalink
Allow aggregate initialization in template body
Browse files Browse the repository at this point in the history
  • Loading branch information
i-garrison committed Oct 9, 2023
1 parent 7a77945 commit 90c076b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11569,4 +11569,14 @@ public void testResolveFunctionTemplateInDeferredBaseArg() throws Exception {
public void testRecognizeConstructorWithSemicolonAfterBody() throws Exception {
parseAndCheckImplicitNameBindings();
}

// template<typename T>
// void f() {
// struct S {
// T t;
// } s {};
// };
public void testAllowAggregateInitializationInTemplateBody() throws Exception {
parseAndCheckImplicitNameBindings();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ private Cost checkImpl(IType target, EvalInitList list) throws DOMException {
* 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
Expand Down

0 comments on commit 90c076b

Please sign in to comment.