mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 23:05:47 +02:00
Allow aggregate initialization in template body
This commit is contained in:
parent
84322c30f4
commit
8091626ee4
2 changed files with 15 additions and 1 deletions
|
@ -11607,4 +11607,14 @@ public class AST2TemplateTests extends AST2CPPTestBase {
|
||||||
public void testRecognizeConstructorWithSemicolonAfterBody() throws Exception {
|
public void testRecognizeConstructorWithSemicolonAfterBody() throws Exception {
|
||||||
parseAndCheckImplicitNameBindings();
|
parseAndCheckImplicitNameBindings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template<typename T>
|
||||||
|
// void f() {
|
||||||
|
// struct S {
|
||||||
|
// T t;
|
||||||
|
// } s {};
|
||||||
|
// };
|
||||||
|
public void testAllowAggregateInitializationInTemplateBody() throws Exception {
|
||||||
|
parseAndCheckImplicitNameBindings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,11 @@ class AggregateInitialization {
|
||||||
* else recurses into the subaggregate.
|
* else recurses into the subaggregate.
|
||||||
*/
|
*/
|
||||||
private Cost checkElement(IType type, IValue initialValue, Cost worstCost) throws DOMException {
|
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);
|
IType nestedType = SemanticUtil.getNestedType(type, SemanticUtil.TDEF);
|
||||||
if (fIndex >= fInitializers.length)
|
if (fIndex >= fInitializers.length)
|
||||||
// TODO for arrays we could short-circuit default init instead of trying to init each element
|
// TODO for arrays we could short-circuit default init instead of trying to init each element
|
||||||
|
|
Loading…
Add table
Reference in a new issue