aboutsummaryrefslogtreecommitdiff
path: root/Sil/Check.icl
diff options
context:
space:
mode:
Diffstat (limited to 'Sil/Check.icl')
-rw-r--r--Sil/Check.icl9
1 files changed, 9 insertions, 0 deletions
diff --git a/Sil/Check.icl b/Sil/Check.icl
index c51d73c..f9147bf 100644
--- a/Sil/Check.icl
+++ b/Sil/Check.icl
@@ -34,6 +34,8 @@ where
= "Type error: no return from non-void function '" <+ f <+ "'."
toString (LocalVoid f l)
= "Type error: local variable '" <+ l <+ "' in '" <+ f <+ "' cannot have type Void."
+ toString (BasicGlobal g)
+ = "Error: global variable '" <+ g <+ "' cannot have a basic type."
instance <<< CheckError where <<< f e = f <<< toString e <<< "\r\n"
@@ -42,6 +44,7 @@ checkProgram err prog
= checkErrors
[ checkFunctionNames
, checkMainFunction
+ , checkGlobals
] prog
$ appFst flatten $ mapSt (flip checkFunction) prog.p_funs err
where
@@ -56,6 +59,12 @@ where
\\ fs <- tails [f.f_name \\ f <- p.p_funs]
| not (isEmpty fs) && isMember (hd fs) (tl fs)]
+ checkGlobals :: Program -> [CheckError]
+ checkGlobals p =
+ [ BasicGlobal g.init_name
+ \\ g <- p.p_globals
+ | (typeSize g.init_type).bsize <> 0]
+
checkFunction :: *(Maybe *File) Function -> *([CheckError], *Maybe *File)
checkFunction err f = checkErrors
[ checkLocals