Commit f6dd9e42 authored by Virgile Prevosto's avatar Virgile Prevosto
Browse files

[typing] always push current pack status on pragma pack push directives

Even if we don't know what to do with the argument of the push, this at least
ensures that push/pop directives stay well parenthesized.
parent 7d53d71a
......@@ -448,6 +448,19 @@ let process_pack_pragma name args =
current_packing_pragma:= new_pragma; None
end else
Some (Attr (name, args))
| ACons ("push",[]) :: args (* unknown push directive *) ->
Kernel.warning ~current:true
"Unsupported argument for pragma pack push directive: `%a'."
~pp_sep:(fun fmt ()->pp_print_string fmt ", ")
(* We don't change the current packing directive, but
nevertheless push it on the stack, to avoid a mismatched
pop somewhere later. *)
Stack.push !current_packing_pragma packing_pragma_stack;
| [ACons ("pop",[])] (* #pragma pack(pop) *) ->
begin try
current_packing_pragma := Stack.pop packing_pragma_stack;
[kernel] Parsing tests/syntax/pragma.i (no preprocessing)
[kernel] tests/syntax/pragma.i:1: Warning:
Unsupported argument for pragma pack push directive: `_CRT_PACKING'.
/* Generated by Frama-C */
int main(void)
int __retres;
__retres = 0;
return __retres;
#pragma pack(push, _CRT_PACKING)
#pragma pack(pop)
int main() {
return 0;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment