From a40a2797d80d510bcd36bb72cf3eafba4cee1bd5 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Fri, 17 Aug 2018 17:21:24 +0200 Subject: 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. --- cparser/Elab.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cparser') 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 -- cgit