aboutsummaryrefslogtreecommitdiff
path: root/Source/CParse
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2013-04-18 22:47:41 +0100
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2013-04-18 22:48:42 +0100
commit857e447654c72184a9bace33ec3ad33ddb354c1d (patch)
tree200bfaf76585cdbf635d55bbc6bfa87b83e3fdcf /Source/CParse
parent2a3e687c19385bb516b89343ffa0f347465ade82 (diff)
downloadswig-857e447654c72184a9bace33ec3ad33ddb354c1d.tar.gz
Fix syntax error when preprocessor macros are defined inside of enum lists
Fixes SF Bug 428, Patch 333
Diffstat (limited to 'Source/CParse')
-rw-r--r--Source/CParse/parser.y46
1 files changed, 24 insertions, 22 deletions
diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
index 74d41079c..92c518e1f 100644
--- a/Source/CParse/parser.y
+++ b/Source/CParse/parser.y
@@ -1788,6 +1788,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
%type <ptype> type_specifier primitive_type_list ;
%type <node> fname stringtype;
%type <node> featattr;
+%type <node> optional_constant_directive;
%%
@@ -5647,29 +5648,31 @@ definetype : { /* scanner_check_typedef(); */ } expr {
/* Some stuff for handling enums */
ename : ID { $$ = $1; }
- | empty { $$ = (char *) 0;}
- ;
+ | empty { $$ = (char *) 0;}
+ ;
-enumlist : enumlist COMMA edecl {
+optional_constant_directive : constant_directive { $$ = $1; }
+ | empty { $$ = 0; }
+ ;
- /* Ignore if there is a trailing comma in the enum list */
- if ($3) {
- Node *leftSibling = Getattr($1,"_last");
- if (!leftSibling) {
- leftSibling=$1;
- }
- set_nextSibling(leftSibling,$3);
- Setattr($1,"_last",$3);
- }
- $$ = $1;
- }
- | edecl {
- $$ = $1;
- if ($1) {
- Setattr($1,"_last",$1);
- }
- }
- ;
+/* Enum lists - any #define macros (constant directives) within the enum list are ignored. Trailing commas accepted. */
+enumlist : enumlist COMMA optional_constant_directive edecl optional_constant_directive {
+ Node *leftSibling = Getattr($1,"_last");
+ set_nextSibling(leftSibling,$4);
+ Setattr($1,"_last",$4);
+ $$ = $1;
+ }
+ | enumlist COMMA optional_constant_directive {
+ $$ = $1;
+ }
+ | optional_constant_directive edecl optional_constant_directive {
+ Setattr($2,"_last",$2);
+ $$ = $2;
+ }
+ | optional_constant_directive {
+ $$ = 0;
+ }
+ ;
edecl : ID {
SwigType *type = NewSwigType(T_INT);
@@ -5689,7 +5692,6 @@ edecl : ID {
Setattr($$,"value",$1);
Delete(type);
}
- | empty { $$ = 0; }
;
etype : expr {