Skip to content

Generating compound expression returning compound literal incorrectly omits final semicolon #573

Open
@bbb23exposed

Description

@bbb23exposed
ast = pycparserext.ext_c_parser.GnuCParser().parse("""
struct a {
    int m;
};

struct a test() {
    int x = 1;
    return ({
        (struct a){x};
    });
}""")

print(pycparserext.ext_c_generator.GnuCGenerator().visit(ast))

output:

{
  int m;
};
struct a test()
{
  int x = 1;
  return   {
    (struct a){x}
  }
;
}

Compare with:

ast = pycparserext.ext_c_parser.GnuCParser().parse("""
struct a {
    int m;
};

struct a test() {
    int x = 1;
    return ({
        x;
    });
}""")

output:

struct a
{
  int m;
};
struct a test()
{
  int x = 1;
  return   {
    x;
  }
;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions