diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2018-08-17 17:21:24 +0200 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2018-08-17 17:21:24 +0200 |
commit | a40a2797d80d510bcd36bb72cf3eafba4cee1bd5 (patch) | |
tree | 02d3b7725405b49c565f1f7cc2f528518392be99 | |
parent | 7f6149a019d796c479a1bbb6f1ad0a3181732dd2 (diff) | |
download | compcert-a40a2797d80d510bcd36bb72cf3eafba4cee1bd5.tar.gz compcert-a40a2797d80d510bcd36bb72cf3eafba4cee1bd5.zip |
For "packed" attribute, check that 3rd parameter is 0 or 1
It's meant as a Boolean (byte-swap or not), so any other value is dangerous.
The error message is the generic "ill-formed 'packed' attribute".
Maybe we don't need a custom error message.
-rw-r--r-- | cparser/Elab.ml | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/cparser/Elab.ml b/cparser/Elab.ml index 668b65d8..6b2db3da 100644 --- a/cparser/Elab.ml +++ b/cparser/Elab.ml @@ -523,7 +523,7 @@ let enter_gcc_attr loc a = | [AInt n] -> if check_alignment loc n then [a] else [] | [AInt n; AInt p] -> if check_alignment loc n && check_alignment loc p then [a] else [] - | [AInt n; AInt p; AInt q] -> + | [AInt n; AInt p; AInt q] when q = 0L || q = 1L -> if check_alignment loc n && check_alignment loc p then [a] else [] | _ -> error loc "ill-formed 'packed' attribute"; [] end |