slicc: support for local variable declarations in action blocks
This commit is contained in:
parent
1850ed410f
commit
9324239922
1 changed files with 5 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
||||||
# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
|
# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
|
||||||
# Copyright (c) 2009 The Hewlett-Packard Development Company
|
# Copyright (c) 2009 The Hewlett-Packard Development Company
|
||||||
|
# Copyright (c) 2013 Advanced Micro Devices, Inc.
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -26,6 +27,7 @@
|
||||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
from slicc.ast.StatementAST import StatementAST
|
from slicc.ast.StatementAST import StatementAST
|
||||||
|
from slicc.ast.LocalVariableAST import LocalVariableAST
|
||||||
from slicc.symbols import Type
|
from slicc.symbols import Type
|
||||||
|
|
||||||
class ExprStatementAST(StatementAST):
|
class ExprStatementAST(StatementAST):
|
||||||
|
@ -40,8 +42,9 @@ class ExprStatementAST(StatementAST):
|
||||||
actual_type,rcode = self.expr.inline(True)
|
actual_type,rcode = self.expr.inline(True)
|
||||||
code("$rcode;")
|
code("$rcode;")
|
||||||
|
|
||||||
# The return type must be void
|
# The return type must be void, except for local var decls
|
||||||
if actual_type != self.symtab.find("void", Type):
|
if (not isinstance(self.expr, LocalVariableAST) and
|
||||||
|
actual_type != self.symtab.find("void", Type)):
|
||||||
self.expr.warning("Non-void return ignored, " + \
|
self.expr.warning("Non-void return ignored, " + \
|
||||||
"return type is '%s'", actual_type.ident)
|
"return type is '%s'", actual_type.ident)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue