From a70741f8abc2e03346eed98e420f9a2e0c8531cc Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Tue, 29 May 2018 16:21:16 +0200 Subject: Allow align attribute of zero. (#120) As the standard says (and is already implemented) an _Alignas(0) does not change the alignment at all. The same holds for the gcc attribute. Bug 23387 --- cparser/Elab.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cparser') diff --git a/cparser/Elab.ml b/cparser/Elab.ml index 4d2a33b7..1d88e4ea 100644 --- a/cparser/Elab.ml +++ b/cparser/Elab.ml @@ -499,7 +499,7 @@ let extract_alignas loc a = match a with | Attr(("aligned"|"__aligned__"), args) -> begin match args with - | [AInt n] when is_power_of_two n -> AAlignas (Int64.to_int n) + | [AInt n] when is_power_of_two n || n = 0L -> AAlignas (Int64.to_int n) | [AInt n] -> error loc "requested alignment is not a power of 2"; a | [_] -> error loc "requested alignment is not an integer constant"; a | [] -> a (* Use the default alignment as the gcc does *) @@ -519,7 +519,7 @@ let elab_attribute env = function | ALIGNAS_ATTR ([a], loc) -> begin match elab_attr_arg loc env a with | AInt n -> - if is_power_of_two n then + if is_power_of_two n || n = 0L then [AAlignas (Int64.to_int n)] else begin error loc "requested alignment is not a power of 2"; [] -- cgit