Open
Description
I noticed this issue while investigating the test failure in PR #474. The field x
is converted to _Ptr<int>
even though it's initialized to 1
. This is converted correctly if we instead initialize c
with {{1}}
.
struct a {
int *x;
};
struct b {
struct a y;
};
void foo(){
struct b c = {.y.x = 1};
}
Broadly what happens is that we only see a InitListExpr
for the outer struct b
. The RecursiveASTVisitor
never visits an expression for initializing the inner struct a
. The ast dump for the variable declartion shows two InitListExpr
, so clearly clang is able to transform this sort of designated initialization to initialization lists, but I guess this hasn't happened for the AST that we traverse.
`-VarDecl 0x55e9fda02ca8 <col:3, col:25> col:12 c 'struct b':'struct b' cinit
`-InitListExpr 0x55e9fda02e80 <col:16, col:25> 'struct b':'struct b'
`-InitListExpr 0x55e9fda02ec8 <col:19, col:24> 'struct a':'struct a'
`-ImplicitCastExpr 0x55e9fda02f10 <col:24> 'int *' <IntegralToPointer>
`-IntegerLiteral 0x55e9fda02d20 <col:24> 'int' 1