-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support designated initializaser style. (#35)
Fixes #32. * frontc/cabs.ml: Add `DESIGNATED` expression type for struct initialization. * frontc/cparser.mly: Add rules for compounds (struct initialization). A compound contains a list of expressions or designated, but a standard initialization cannot be a designated outside a compound. * frontc/cprint.ml: Print new AST type. * frontc/ctoxml.ml: Print XML for new designated AST type. * ctoxml/test.t/c99-struct-initializers.c: New test. * ctoxml/test.t/run.t: Update expected output for new test. Co-authored-by: Julien Lepiller <[email protected]>
- Loading branch information
Showing
6 changed files
with
97 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
struct point { | ||
int x; | ||
int y; | ||
}; | ||
|
||
struct point3d { | ||
int x; | ||
int y; | ||
int z; | ||
}; | ||
|
||
int main() { | ||
struct point p = { .y = 2, .x = 1 }; | ||
struct point3d p2 = { .z = 2, .x = 1, 5 }; // mixing both styles | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters