Skip to content

Commit 55c0046

Browse files
committed
Translate braced constructor call to parens
1 parent aaf9797 commit 55c0046

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

src/cppconv/dwriter.d

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3762,6 +3762,15 @@ void parseTreeToDCode(T)(ref CodeWriter code, DWriterData data, T tree, immutabl
37623762
{
37633763
parseTreeToDCode(code, data, tree.childs[1], condition, currentScope);
37643764
}
3765+
else if (tree.nonterminalID == nonterminalIDFor!"BracedInitList"
3766+
&& parent.nonterminalID == nonterminalIDFor!"PostfixExpression" && parent.childs.length == 2 && indexInParent == 1)
3767+
{
3768+
skipToken(code, data, tree.childs[0]);
3769+
code.write("(");
3770+
parseTreeToDCode(code, data, tree.childs[1], condition, currentScope);
3771+
skipToken(code, data, tree.childs[2]);
3772+
code.write(")");
3773+
}
37653774
else if (tree.nonterminalID == nonterminalIDFor!"BracedInitList")
37663775
{
37673776
auto codeWrapper = ConditionalCodeWrapper(condition, data);

tests/single/test373.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
struct S
2+
{
3+
S(int i){}
4+
};
5+
6+
void f()
7+
{
8+
S x = S{1};
9+
}

tests/single/test373.d

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module test373;
2+
3+
import config;
4+
import cppconvhelpers;
5+
6+
struct S
7+
{
8+
this(int i){}
9+
}
10+
11+
void f()
12+
{
13+
S x = S(1);
14+
}
15+

0 commit comments

Comments
 (0)