Skip to content

Commit 514b147

Browse files
committed
CHC: extend const check with pconst and deref type
1 parent 8e96d57 commit 514b147

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

CodeHawk/CHC/cchlib/cCHTypesUtil.ml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,20 @@ let is_bool_type (ik:ikind) =
385385

386386
let has_const_attribute (t:typ) =
387387
List.exists
388-
(fun a -> match a with | Attr ("const",_) -> true | _ -> false)
388+
(fun a ->
389+
match a with
390+
| Attr ("const", _) -> true
391+
| Attr ("pconst", _) -> true
392+
| _ -> false)
389393
(get_typ_attributes t)
390394

395+
396+
let has_deref_const_attribute (t: typ) =
397+
match t with
398+
| TPtr (tgt, _) -> has_const_attribute tgt
399+
| _ -> false
400+
401+
391402
let is_char ik =
392403
match ik with IChar | ISChar | IUChar -> true | _ -> false
393404

CodeHawk/CHC/cchlib/cCHTypesUtil.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ val enum_fits_kind: string -> ikind -> bool
7676

7777
val has_const_attribute: typ -> bool
7878

79+
val has_deref_const_attribute: typ -> bool
80+
7981
val is_not_zero: exp -> bool
8082

8183
val is_safe_int_cast: ikind -> ikind -> bool

0 commit comments

Comments
 (0)