summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2019-09-10 14:00:48 -0700
committerAaron Patterson <tenderlove@ruby-lang.org>2019-09-10 14:00:48 -0700
commit91ee9584f9a3e8b8e5e0e9c2f1f2b229ca10323e (patch)
tree6126a870d9d99cf52dca474b7b59064b3579b935
parent139510238bcbb8d7fd8022c23a603c51d2acbe2e (diff)
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.
-rw-r--r--node.h8
-rw-r--r--parse.y16
2 files changed, 18 insertions, 6 deletions
diff --git a/node.h b/node.h
index 6d4ee686f9..73b9444214 100644
--- a/node.h
+++ b/node.h
@@ -281,15 +281,11 @@ typedef struct RNode {
#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 a7d43b783b..1ba07b4133 100644
--- a/parse.y
+++ b/parse.y
@@ -347,6 +347,8 @@ add_mark_object(struct parser_params *p, VALUE obj)
}
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)
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