aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Schommer <bschommer@users.noreply.github.com>2018-05-29 16:21:16 +0200
committerXavier Leroy <xavierleroy@users.noreply.github.com>2018-05-29 16:21:16 +0200
commita70741f8abc2e03346eed98e420f9a2e0c8531cc (patch)
tree99dbb3238b08c4f90c669205c16b19a148b3c432
parentc4d9dce2d316f3f9adeefcc523198093b7184ab6 (diff)
downloadcompcert-kvx-a70741f8abc2e03346eed98e420f9a2e0c8531cc.tar.gz
compcert-kvx-a70741f8abc2e03346eed98e420f9a2e0c8531cc.zip
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
-rw-r--r--cparser/Elab.ml4
1 files changed, 2 insertions, 2 deletions
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"; []