Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sv2v
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
sv2v
Commits
72ab6396
Commit
72ab6396
authored
Dec 23, 2022
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
forbid non-void return inside void functions
parent
36cff4ab
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
4 deletions
+19
-4
src/Convert/Jump.hs
+5
-4
test/error/return_task.sv
+7
-0
test/error/return_void_func.sv
+7
-0
No files found.
src/Convert/Jump.hs
View file @
72ab6396
...
...
@@ -41,7 +41,9 @@ convertModuleItem :: ModuleItem -> ModuleItem
convertModuleItem
(
MIPackageItem
(
Function
ml
t
f
decls
stmtsOrig
))
=
MIPackageItem
$
Function
ml
t
f
decls'
stmts''
where
stmts
=
map
(
traverseNestedStmts
convertReturn
)
stmtsOrig
stmts
=
if
t
==
Void
then
stmtsOrig
else
map
(
traverseNestedStmts
convertReturn
)
stmtsOrig
convertReturn
::
Stmt
->
Stmt
convertReturn
(
Return
Nil
)
=
Return
Nil
convertReturn
(
Return
e
)
=
...
...
@@ -223,11 +225,12 @@ convertStmt (Break) = do
assertMsg
jumpAllowed
"encountered break inside fork-join"
modify
$
\
s
->
s
{
sHasJump
=
True
}
return
$
asgn
jumpState
jsBreak
convertStmt
(
Return
Nil
)
=
do
convertStmt
(
Return
e
)
=
do
jumpAllowed
<-
gets
sJumpAllowed
returnAllowed
<-
gets
sReturnAllowed
assertMsg
jumpAllowed
"encountered return inside fork-join"
assertMsg
returnAllowed
"encountered return outside of task or function"
assertMsg
(
e
==
Nil
)
"non-void return inside task or void function"
modify
$
\
s
->
s
{
sHasJump
=
True
}
return
$
asgn
jumpState
jsReturn
...
...
@@ -253,8 +256,6 @@ convertStmt (Timing timing stmt) =
convertStmt
(
StmtAttr
attr
stmt
)
=
convertStmt
stmt
>>=
return
.
StmtAttr
attr
convertStmt
(
Return
{})
=
return
$
error
"non-void return should have been elaborated already"
convertStmt
(
Foreach
{})
=
return
$
error
"foreach should have been elaborated already"
...
...
test/error/return_task.sv
0 → 100644
View file @
72ab6396
// pattern: non-void return inside task or void function
module
top
;
task
t
;
return
1
;
endtask
initial
t
;
endmodule
test/error/return_void_func.sv
0 → 100644
View file @
72ab6396
// pattern: non-void return inside task or void function
module
top
;
function
void
f
;
return
1
;
endfunction
initial
f
;
endmodule
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment