diff options
author | Xavier Leroy <xavier.leroy@college-de-france.fr> | 2022-05-07 15:59:53 +0200 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@college-de-france.fr> | 2022-05-07 18:11:03 +0200 |
commit | a4c98b19ccf5a72bfe551fd5b2f8689442a661a6 (patch) | |
tree | a5bf0b8044202c91dd408abd098064b7f8bd6c2c | |
parent | 8610d8faad033d957509ceaa2b5c16b5a466e5a9 (diff) | |
download | compcert-a4c98b19ccf5a72bfe551fd5b2f8689442a661a6.tar.gz compcert-a4c98b19ccf5a72bfe551fd5b2f8689442a661a6.zip |
Completely avoid line breaks in types when printing error messages
The `pp_indication` optional argument that governs formatting boxes
in types was not propagated recursively, causing boxes to appear.
-rw-r--r-- | cparser/Cprint.ml | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/cparser/Cprint.ml b/cparser/Cprint.ml index 93377989..caa4fa66 100644 --- a/cparser/Cprint.ml +++ b/cparser/Cprint.ml @@ -140,7 +140,7 @@ let rec dcl ?(pp_indication=true) pp ty n = match t with | TFun _ | TArray _ -> fprintf pp " (*%a%t)" attributes a n | _ -> fprintf pp " *%a%t" attributes a n in - dcl pp t n' + dcl ~pp_indication pp t n' | TArray(t, sz, a) -> let n' pp = n pp; @@ -152,10 +152,10 @@ let rec dcl ?(pp_indication=true) pp ty n = | None -> fprintf pp "]" | Some i -> fprintf pp "%Ld]" i end in - dcl pp t n' + dcl ~pp_indication pp t n' | TFun(tres, args, vararg, a) -> let param (id, ty) = - dcl pp ty + dcl ~pp_indication pp ty (fun pp -> fprintf pp " %a" ident id) in let n' pp = attributes pp a; @@ -167,12 +167,16 @@ let rec dcl ?(pp_indication=true) pp ty n = | Some [] -> if vararg then fprintf pp "..." else fprintf pp "void" | Some (a1 :: al) -> param a1; - List.iter (fun a -> fprintf pp ",@ "; param a) al; - if vararg then fprintf pp ",@ ..." + List.iter + (fun a -> + if pp_indication then fprintf pp ",@ " else fprintf pp ", "; + param a) + al; + if vararg then fprintf pp ", ..." end; if pp_indication then fprintf pp "@]"; fprintf pp ")" in - dcl pp tres n' + dcl ~pp_indication pp tres n' | TNamed(id, a) -> fprintf pp "%a%a%t" ident id attributes a n | TStruct(id, a) -> |