ruby-changes:57714
From: Aaron <ko1@a...>
Date: Wed, 11 Sep 2019 06:02:02 +0900 (JST)
Subject: [ruby-changes:57714] 91ee9584f9 (master): Macros can't be expressions, so make a function
https://git.ruby-lang.org/ruby.git/commit/?id=91ee9584f9 From 91ee9584f9a3e8b8e5e0e9c2f1f2b229ca10323e Mon Sep 17 00:00:00 2001 From: Aaron Patterson <tenderlove@r...> Date: Tue, 10 Sep 2019 14:00:48 -0700 Subject: Macros can't be expressions, so make a function Macros can't be expressions, that is a GNU extension (I didn't know that). This commit converts the macro to a function so that everything will compile correctly on non-GNU compatible compilers. diff --git a/node.h b/node.h index 6d4ee68..73b9444 100644 --- a/node.h +++ b/node.h @@ -281,15 +281,11 @@ typedef struct RNode { https://github.com/ruby/ruby/blob/trunk/node.h#L281 #define nd_apinfo u3.apinfo #define NEW_NODE(t,a0,a1,a2,loc) rb_node_newnode((t),(VALUE)(a0),(VALUE)(a1),(VALUE)(a2),loc) +#define NEW_NODE_WITH_LOCALS(t,a1,a2,loc) node_newnode_with_locals(p, (t),(VALUE)(a1),(VALUE)(a2),loc) #define NEW_DEFN(i,a,d,loc) NEW_NODE(NODE_DEFN,0,i,NEW_SCOPE(a,d,loc),loc) #define NEW_DEFS(r,i,a,d,loc) NEW_NODE(NODE_DEFS,r,i,NEW_SCOPE(a,d,loc),loc) -#define NEW_SCOPE(a,b,loc) ({ \ - VALUE tbl = 0; \ - NODE * _n = NEW_NODE(NODE_SCOPE,local_tbl(p, &tbl),b,a,loc); \ - tbl && RB_OBJ_WRITTEN(p->ast, Qnil, tbl); \ - _n; \ -}) +#define NEW_SCOPE(a,b,loc) NEW_NODE_WITH_LOCALS(NODE_SCOPE,b,a,loc) #define NEW_BLOCK(a,loc) NEW_NODE(NODE_BLOCK,a,0,0,loc) #define NEW_IF(c,t,e,loc) NEW_NODE(NODE_IF,c,t,e,loc) #define NEW_UNLESS(c,t,e,loc) NEW_NODE(NODE_UNLESS,c,t,e,loc) diff --git a/parse.y b/parse.y index a7d43b7..1ba07b4 100644 --- a/parse.y +++ b/parse.y @@ -347,6 +347,8 @@ add_mark_object(struct parser_params *p, VALUE obj) https://github.com/ruby/ruby/blob/trunk/parse.y#L347 } return obj; } +#else +static NODE* node_newnode_with_locals(struct parser_params *, enum node_type, VALUE, VALUE, const rb_code_location_t*); #endif static NODE* node_newnode(struct parser_params *, enum node_type, VALUE, VALUE, VALUE, const rb_code_location_t*); @@ -11660,6 +11662,20 @@ local_tbl(struct parser_params *p, VALUE *tmp) https://github.com/ruby/ruby/blob/trunk/parse.y#L11662 return buf; } + +static NODE* +node_newnode_with_locals(struct parser_params *p, enum node_type type, VALUE a1, VALUE a2, const rb_code_location_t *loc) +{ + ID *a0; + NODE *n; + VALUE tbl = 0; + + a0 = local_tbl(p, &tbl); + n = NEW_NODE(type, a0, a1, a2, loc); + tbl && RB_OBJ_WRITTEN(p->ast, Qnil, tbl); + return n; +} + #endif static void -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/