aboutsummaryrefslogtreecommitdiffstats
path: root/cparser/Cprint.ml
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2016-08-16 16:17:20 +0200
committerBernhard Schommer <bernhardschommer@gmail.com>2016-08-16 16:17:20 +0200
commit3208e22ea89c459a5a7944ad8e82511d4a5328fa (patch)
treee206e0e048ac85667374117010f58d3b97d918fb /cparser/Cprint.ml
parent8a740c6d441afd980e3bdb43d1844bd23e0ad55b (diff)
downloadcompcert-kvx-3208e22ea89c459a5a7944ad8e82511d4a5328fa.tar.gz
compcert-kvx-3208e22ea89c459a5a7944ad8e82511d4a5328fa.zip
Added raw printing of types without formatting.
This avoids introducing line breaks during printing of function types. Bug 18004
Diffstat (limited to 'cparser/Cprint.ml')
-rw-r--r--cparser/Cprint.ml11
1 files changed, 8 insertions, 3 deletions
diff --git a/cparser/Cprint.ml b/cparser/Cprint.ml
index e80a4c8e..2a110104 100644
--- a/cparser/Cprint.ml
+++ b/cparser/Cprint.ml
@@ -126,7 +126,7 @@ let name_of_fkind = function
| FDouble -> "double"
| FLongDouble -> "long double"
-let rec dcl pp ty n =
+let rec dcl ?(pp_indication=true) pp ty n =
match ty with
| TVoid a ->
fprintf pp "void%a%t" attributes a n
@@ -160,7 +160,8 @@ let rec dcl pp ty n =
| [] -> n pp
| _ -> fprintf pp " (%a%t)" attributes a n
end;
- fprintf pp "(@[<hov 0>";
+ fprintf pp "(";
+ if pp_indication then fprintf pp "@[<hov 0>";
begin match args with
| None -> ()
| Some [] -> if vararg then fprintf pp "..." else fprintf pp "void"
@@ -169,7 +170,8 @@ let rec dcl pp ty n =
List.iter (fun a -> fprintf pp ",@ "; param a) al;
if vararg then fprintf pp ",@ ..."
end;
- fprintf pp "@])" in
+ if pp_indication then fprintf pp "@]";
+ fprintf pp ")" in
dcl pp tres n'
| TNamed(id, a) ->
fprintf pp "%a%a%t" ident id attributes a n
@@ -183,6 +185,9 @@ let rec dcl pp ty n =
let typ pp ty =
dcl pp ty (fun _ -> ())
+let typ_raw pp ty =
+ dcl ~pp_indication:false pp ty (fun _ -> ())
+
type associativity = LtoR | RtoL | NA
let precedence = function (* H&S section 7.2 *)