diff options
author | Xavier Leroy <xavier.leroy@college-de-france.fr> | 2022-05-06 09:36:35 +0200 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@college-de-france.fr> | 2022-05-06 09:36:35 +0200 |
commit | 8610d8faad033d957509ceaa2b5c16b5a466e5a9 (patch) | |
tree | 2eaaa3b332837501a2d24d896d2d4c1f8714152f | |
parent | 4920f93e4f933c8616a3376da5264d63bd58afdc (diff) | |
download | compcert-8610d8faad033d957509ceaa2b5c16b5a466e5a9.tar.gz compcert-8610d8faad033d957509ceaa2b5c16b5a466e5a9.zip |
Enum is only compatible with IInt.
Enum types should only be compatible with the underlying integer type,
not all integer types.
Bug 33212
-rw-r--r-- | cparser/Cutil.ml | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/cparser/Cutil.ml b/cparser/Cutil.ml index bcdea107..6fd12323 100644 --- a/cparser/Cutil.ml +++ b/cparser/Cutil.ml @@ -320,6 +320,8 @@ let packing_parameters al = (* Type compatibility *) +let enum_ikind = IInt + exception Incompat type attr_handling = @@ -400,8 +402,8 @@ let combine_types mode env t1 t2 = TUnion(comp_base s1 s2, comp_attr m a1 a2) | TEnum(s1, a1), TEnum(s2, a2) -> TEnum(comp_base s1 s2, comp_attr m a1 a2) - | TEnum(s,a1), TInt(enum_ikind,a2) - | TInt(enum_ikind,a2), TEnum (s,a1) -> + | TEnum(s,a1), TInt(ik,a2) + | TInt(ik,a2), TEnum (s,a1) when ik = enum_ikind -> TEnum(s,comp_attr m a1 a2) | _, _ -> raise Incompat @@ -465,8 +467,6 @@ let alignof_fkind = function (* Return natural alignment of given type, or None if the type is incomplete *) -let enum_ikind = IInt - let rec alignof env t = let a = alignas_attribute (attributes_of_type env t) in if a > 0 then Some a else |