From 1915258c8b2cd2e171bbce93658047a765232bc9 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Mon, 13 Oct 2014 09:00:12 +0200 Subject: Revised translation of '&&' and '||' to Clight. The previous translation (in SimplExpr) produced references to the same temporary variable with two different types (bool and int), which is not nice if we want to typecheck the generated Clight. The new translation avoids this and also gets rid of the double cast to bool then to int. The trick is to change Eparen (in CompCert C expressions) to take two types: the type to which the argument must be converted, and the type with which the resulting expression is seen. --- cfrontend/PrintCsyntax.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cfrontend/PrintCsyntax.ml') diff --git a/cfrontend/PrintCsyntax.ml b/cfrontend/PrintCsyntax.ml index 4e0ee7f3..e1b53af8 100644 --- a/cfrontend/PrintCsyntax.ml +++ b/cfrontend/PrintCsyntax.ml @@ -272,8 +272,8 @@ let rec expr p (prec, e) = fprintf p "%s@[(%a)@]" (extern_atom id) exprlist (true, args) | Ebuiltin(_, _, args, _) -> fprintf p "@[(%a)@]" exprlist (true, args) - | Eparen(a1, ty) -> - fprintf p "(%s) %a" (name_type ty) expr (prec', a1) + | Eparen(a1, tycast, ty) -> + fprintf p "(%s) %a" (name_type tycast) expr (prec', a1) end; if prec' < prec then fprintf p ")@]" else fprintf p "@]" -- cgit