@@ -210,7 +210,7 @@ def fail(self, site):
210210class IgnoreFailure (Failure ):
211211 '''Ignore exceptions'''
212212 def fail (self , site ):
213- return mkNull (site )
213+ return mkNoop (site )
214214
215215class ExitHandler (ABC ):
216216 current = None
@@ -1916,9 +1916,10 @@ def codegen_statements(trees, *args):
19161916 return stmts
19171917
19181918def codegen_statement (tree , * args ):
1919- rbrace_site = tree .args [1 ] if tree .kind == 'compound' else None
1920- return mkCompound (tree .site , codegen_statements ([tree ], * args ),
1921- rbrace_site )
1919+ stmts = codegen_statements ([tree ], * args )
1920+ if len (stmts ) == 1 and not stmts [0 ].is_declaration :
1921+ return stmts [0 ]
1922+ return mkCompound (tree .site , stmts )
19221923
19231924@statement_dispatcher
19241925def stmt_compound (stmt , location , scope ):
@@ -2190,7 +2191,7 @@ def stmt_saved(stmt, location, scope):
21902191
21912192@statement_dispatcher
21922193def stmt_null (stmt , location , scope ):
2193- return []
2194+ return [mkNull ( stmt . site ) ]
21942195
21952196@statement_dispatcher
21962197def stmt_if (stmt , location , scope ):
@@ -3207,7 +3208,7 @@ def stmt_while(stmt, location, scope):
32073208 [cond , statement ] = stmt .args
32083209 cond = as_bool (codegen_expression (cond , location , scope ))
32093210 if stmt .site .dml_version () == (1 , 2 ) and cond .constant and not cond .value :
3210- return [mkNull (stmt .site )]
3211+ return [mkNoop (stmt .site )]
32113212 else :
32123213 with CLoopContext ():
32133214 res = mkWhile (stmt .site , cond ,
@@ -3345,7 +3346,7 @@ def mkcall_method(site, func, indices):
33453346
33463347def common_inline (site , method , indices , inargs , outargs ):
33473348 if not verify_args (site , method .inp , method .outp , inargs , outargs ):
3348- return mkNull (site )
3349+ return mkNoop (site )
33493350
33503351 if dml .globals .debuggable :
33513352 if method .fully_typed and (
@@ -3999,7 +4000,7 @@ def codegen_call_traitmethod(site, expr, inargs, outargs):
39994000 if not isinstance (expr , TraitMethodRef ):
40004001 raise ICE (site , "cannot call %r: not a trait method" % (expr ,))
40014002 if not verify_args (site , expr .inp , expr .outp , inargs , outargs ):
4002- return mkNull (site )
4003+ return mkNoop (site )
40034004 def mkcall (args ):
40044005 rettype = c_rettype (expr .outp , expr .throws )
40054006 # implicitly convert endian int arguments to integers
@@ -4011,7 +4012,7 @@ def mkcall(args):
40114012def codegen_call (site , meth_node , indices , inargs , outargs ):
40124013 '''Generate a call using a direct reference to the method node'''
40134014 if not verify_args (site , meth_node .inp , meth_node .outp , inargs , outargs ):
4014- return mkNull (site )
4015+ return mkNoop (site )
40154016 require_fully_typed (site , meth_node )
40164017 func = method_instance (meth_node )
40174018
0 commit comments