@@ -51,16 +51,19 @@
5151#defineERROR -1
52525353#defineRETURN_IF_ERROR(X) \
54- if ((X) == -1) { \
55- return ERROR; \
56- }
57-58-#defineRETURN_IF_ERROR_IN_SCOPE(C, CALL) { \
59- if ((CALL) < 0) { \
60- _PyCompile_ExitScope((C)); \
61- return ERROR; \
62- } \
63-}
54+ do { \
55+ if ((X) == -1) { \
56+ return ERROR; \
57+ } \
58+ } while (0)
59+60+#defineRETURN_IF_ERROR_IN_SCOPE(C, CALL) \
61+ do { \
62+ if ((CALL) < 0) { \
63+ _PyCompile_ExitScope((C)); \
64+ return ERROR; \
65+ } \
66+ } while (0)
64676568struct_PyCompiler;
6669typedefstruct_PyCompilercompiler;
@@ -261,7 +264,7 @@ codegen_addop_i(instr_sequence *seq, int opcode, Py_ssize_t oparg, location loc)
261264 RETURN_IF_ERROR(codegen_addop_i(INSTR_SEQUENCE(C), (OP), (O), (LOC)))
262265263266#defineADDOP_I_IN_SCOPE(C, LOC, OP, O) \
264- RETURN_IF_ERROR_IN_SCOPE(C, codegen_addop_i(INSTR_SEQUENCE(C), (OP), (O), (LOC)));
267+ RETURN_IF_ERROR_IN_SCOPE(C, codegen_addop_i(INSTR_SEQUENCE(C), (OP), (O), (LOC)))
265268266269staticint
267270codegen_addop_noarg(instr_sequence*seq, intopcode, locationloc)
@@ -303,17 +306,18 @@ codegen_addop_load_const(compiler *c, location loc, PyObject *o)
303306 RETURN_IF_ERROR_IN_SCOPE((C), codegen_addop_load_const((C), (LOC), (O)))
304307305308/* Same as ADDOP_LOAD_CONST, but steals a reference. */
306-#defineADDOP_LOAD_CONST_NEW(C, LOC, O) { \
307- PyObject *__new_const = (O); \
308- if (__new_const == NULL) { \
309- return ERROR; \
310- } \
311- if (codegen_addop_load_const((C), (LOC), __new_const) < 0) { \
312- Py_DECREF(__new_const); \
313- return ERROR; \
314- } \
315- Py_DECREF(__new_const); \
316-}
309+#defineADDOP_LOAD_CONST_NEW(C, LOC, O) \
310+ do { \
311+ PyObject *__new_const = (O); \
312+ if (__new_const == NULL) { \
313+ return ERROR; \
314+ } \
315+ if (codegen_addop_load_const((C), (LOC), __new_const) < 0) { \
316+ Py_DECREF(__new_const); \
317+ return ERROR; \
318+ } \
319+ Py_DECREF(__new_const); \
320+ } while (0)
317321318322staticint
319323codegen_addop_o(compiler*c, locationloc,
@@ -325,19 +329,23 @@ codegen_addop_o(compiler *c, location loc,
325329returnSUCCESS;
326330}
327331328-#defineADDOP_N(C, LOC, OP, O, TYPE) { \
329- assert(!OPCODE_HAS_CONST(OP)); /* use ADDOP_LOAD_CONST_NEW */ \
330-int ret = codegen_addop_o((C), (LOC), (OP), METADATA(C)->u_ ## TYPE, (O)); \
331- Py_DECREF((O)); \
332- RETURN_IF_ERROR(ret); \
333-}
334-335-#defineADDOP_N_IN_SCOPE(C, LOC, OP, O, TYPE) { \
336- assert(!OPCODE_HAS_CONST(OP)); /* use ADDOP_LOAD_CONST_NEW */ \
337-int ret = codegen_addop_o((C), (LOC), (OP), METADATA(C)->u_ ## TYPE, (O)); \
338- Py_DECREF((O)); \
339- RETURN_IF_ERROR_IN_SCOPE((C), ret); \
340-}
332+#defineADDOP_N(C, LOC, OP, O, TYPE) \
333+ do { \
334+ assert(!OPCODE_HAS_CONST(OP)); /* use ADDOP_LOAD_CONST_NEW */ \
335+intret=codegen_addop_o((C), (LOC), (OP), \
336+METADATA(C)->u_ ## TYPE, (O)); \
337+ Py_DECREF((O)); \
338+ RETURN_IF_ERROR(ret); \
339+ } while (0)
340+341+#defineADDOP_N_IN_SCOPE(C, LOC, OP, O, TYPE) \
342+ do { \
343+ assert(!OPCODE_HAS_CONST(OP)); /* use ADDOP_LOAD_CONST_NEW */ \
344+intret=codegen_addop_o((C), (LOC), (OP), \
345+METADATA(C)->u_ ## TYPE, (O)); \
346+ Py_DECREF((O)); \
347+ RETURN_IF_ERROR_IN_SCOPE((C), ret); \
348+ } while (0)
341349342350#defineLOAD_METHOD -1
343351#defineLOAD_SUPER_METHOD -2
@@ -426,31 +434,31 @@ codegen_addop_j(instr_sequence *seq, location loc,
426434*/
427435428436#defineVISIT(C, TYPE, V) \
429- RETURN_IF_ERROR(codegen_visit_ ## TYPE((C), (V)));
437+ RETURN_IF_ERROR(codegen_visit_ ## TYPE((C), (V)))
430438431439#defineVISIT_IN_SCOPE(C, TYPE, V) \
432440 RETURN_IF_ERROR_IN_SCOPE((C), codegen_visit_ ## TYPE((C), (V)))
433441434-#defineVISIT_SEQ(C, TYPE, SEQ) { \
435-int _i; \
436- asdl_ ## TYPE ## _seq *seq = (SEQ); /* avoid variable capture */ \
437-for (_i = 0; _i < asdl_seq_LEN(seq); _i++) { \
438- TYPE ## _ty elt = (TYPE ## _ty)asdl_seq_GET(seq, _i); \
439- RETURN_IF_ERROR(codegen_visit_ ## TYPE((C), elt)); \
440-} \
441-}
442-443-#defineVISIT_SEQ_IN_SCOPE(C, TYPE, SEQ) { \
444-int _i; \
445- asdl_ ## TYPE ## _seq *seq = (SEQ); /* avoid variable capture */ \
446-for (_i = 0; _i < asdl_seq_LEN(seq); _i++) { \
447- TYPE ## _ty elt = (TYPE ## _ty)asdl_seq_GET(seq, _i); \
448- if (codegen_visit_ ## TYPE((C), elt) < 0) { \
449- _PyCompile_ExitScope(C); \
450- return ERROR; \
451-} \
452-} \
453-}
442+#defineVISIT_SEQ(C, TYPE, SEQ) \
443+do { \
444+asdl_ ## TYPE ## _seq *seq = (SEQ); /* avoid variable capture */ \
445+for (int_i=0; _i<asdl_seq_LEN(seq); _i++) { \
446+TYPE ## _tyelt= (TYPE ## _ty)asdl_seq_GET(seq, _i); \
447+RETURN_IF_ERROR(codegen_visit_ ## TYPE((C), elt)); \
448+ } \
449+ } while (0)
450+451+#defineVISIT_SEQ_IN_SCOPE(C, TYPE, SEQ) \
452+do { \
453+asdl_ ## TYPE ## _seq *seq = (SEQ); /* avoid variable capture */ \
454+for (int_i=0; _i<asdl_seq_LEN(seq); _i++) { \
455+TYPE ## _tyelt= (TYPE ## _ty)asdl_seq_GET(seq, _i); \
456+if (codegen_visit_ ## TYPE((C), elt) < 0) { \
457+_PyCompile_ExitScope(C); \
458+return ERROR; \
459+ } \
460+ } \
461+ } while (0)
454462455463staticint
456464codegen_call_exit_with_nones(compiler*c, locationloc)
@@ -2866,7 +2874,7 @@ codegen_visit_stmt(compiler *c, stmt_ty s)
28662874caseReturn_kind:
28672875returncodegen_return(c, s);
28682876caseDelete_kind:
2869-VISIT_SEQ(c, expr, s->v.Delete.targets)
2877+VISIT_SEQ(c, expr, s->v.Delete.targets);
28702878break;
28712879caseAssign_kind:
28722880 {
@@ -4759,7 +4767,7 @@ codegen_async_with(compiler *c, stmt_ty s, int pos)
47594767pos++;
47604768if (pos==asdl_seq_LEN(s->v.AsyncWith.items)) {
47614769/* BLOCK code */
4762-VISIT_SEQ(c, stmt, s->v.AsyncWith.body)
4770+VISIT_SEQ(c, stmt, s->v.AsyncWith.body);
47634771 }
47644772else {
47654773RETURN_IF_ERROR(codegen_async_with(c, s, pos));
@@ -4858,7 +4866,7 @@ codegen_with(compiler *c, stmt_ty s, int pos)
48584866pos++;
48594867if (pos==asdl_seq_LEN(s->v.With.items)) {
48604868/* BLOCK code */
4861-VISIT_SEQ(c, stmt, s->v.With.body)
4869+VISIT_SEQ(c, stmt, s->v.With.body);
48624870 }
48634871else {
48644872RETURN_IF_ERROR(codegen_with(c, s, pos));