Skip to content

Commit 66ecadb

Browse files
committed
CHC: add some Stmt validity rules
1 parent d9105b2 commit 66ecadb

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

CodeHawk/CHC/cchpre/cCHCheckValid.ml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,9 @@ let check_ppo_validity
766766
| AddrOf (Var (vname, _), _)
767767
| CastE (_, AddrOf (Var (vname, _), _)) ->
768768
make_violation ("address of non-local variable: " ^ vname)
769+
| StartOf (Var (vname, _), _)
770+
| CastE (_, StartOf (Var (vname, _), _)) ->
771+
make_violation ("address of array: " ^ vname)
769772
| _ -> ())
770773

771774
| PStackAddressEscape (_,e) when is_null_pointer e ->
@@ -1338,6 +1341,20 @@ let check_ppo_validity
13381341
| _ -> ()
13391342
end
13401343

1344+
| POutputParameterScalar (_, e) when not (is_pointer_type (type_of_exp env e)) ->
1345+
make ("expression " ^ (e2s e) ^ " is not a pointer type")
1346+
1347+
| POutputParameterScalar (_, e) when is_null_pointer e ->
1348+
make ("expression " ^ (e2s e) ^ " is a null pointer")
1349+
1350+
| POutputParameterScalar (_, e)
1351+
when (match e with
1352+
| Lval _ | CastE (_, Lval _) -> true | _ -> false) ->
1353+
make ("expression " ^ (e2s e) ^ " is an lval expression")
1354+
1355+
| POutputParameterScalar (_, e) when is_string_literal e ->
1356+
make ("expression " ^ (e2s e) ^ " is a string literal")
1357+
13411358
| PWidthOverflow (e, ik) ->
13421359
let safeBitWidth = mkNumerical (get_safe_bit_width ik) in
13431360
begin

0 commit comments

Comments
 (0)