Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds support for unnamed bit fields #41

Merged
merged 1 commit into from
May 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions ctoxml/test.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -3866,7 +3866,7 @@
</fundec>
</file>

$ echo 'struct foo {int x;};' | dune exec ctoxml
$ echo 'struct foo {int x;};' | ctoxml
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<file>
<struct id="struct:foo">
Expand All @@ -3889,7 +3889,7 @@
</fundec>
</file>

$ echo 'const volatile int n;' | dune exec ctoxml
$ echo 'const volatile int n;' | ctoxml
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<file>
<var id="n" store="auto">
Expand Down Expand Up @@ -5448,7 +5448,7 @@
</fundef>
</file>

$ echo 'void fn(char xs[const static volatile]) {}' | dune exec ctoxml --
$ echo 'void fn(char xs[const static volatile]) {}' | ctoxml --
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<file>
<fundef id="fn" store="auto">
Expand All @@ -5472,7 +5472,7 @@
</body>
</fundef>
</file>
$ echo 'void fn(char xs[const static volatile 10]) {}' | dune exec ctoxml --
$ echo 'void fn(char xs[const static volatile 10]) {}' | ctoxml
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<file>
<fundef id="fn" store="auto">
Expand All @@ -5496,3 +5496,15 @@
</body>
</fundef>
</file>

$ echo 'struct s {int : 32;};' | ctoxml
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<file>
<struct id="struct:s">
<field name="">
<bits>
<int>32</int>
</bits>
</field>
</struct>
</file>
4 changes: 2 additions & 2 deletions frontc/cparser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,8 @@ field_dec:
{(fst $2, set_type (PROTO (NO_TYPE, fst $5, snd $5)) (snd $2))}
| LPAREN field_dec RPAREN
{$2}
| IDENT COLON expression
{($1, BITFIELD (NO_SIGN, $3))}
| IDENT? COLON expression
{((match $1 with None -> "" | Some x -> x), BITFIELD (NO_SIGN, $3))}
;


Expand Down