Skip to content

Commit 4309baf

Browse files
author
Daniel Kroening
committed
FLOAT_TYPECAST now gives destination type
1 parent 32800a3 commit 4309baf

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

src/ansi-c/expr2c.cpp

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4306,21 +4306,30 @@ std::string expr2ct::convert(
43064306

43074307
else if(src.id()==ID_floatbv_typecast)
43084308
{
4309-
#if 1
4310-
return convert_function(src, "FLOAT_TYPECAST", precedence=16);
4311-
#else
4309+
precedence=16;
4310+
std::string dest="FLOAT_TYPECAST(";
4311+
4312+
unsigned p0;
4313+
std::string tmp0=convert(src.op0(), p0);
4314+
4315+
if(p0<=1) dest+='(';
4316+
dest+=tmp0;
4317+
if(p0<=1) dest+=')';
4318+
43124319
const typet &to_type=ns.follow(src.type());
4313-
std::string dest="("+convert(to_type)+")";
4320+
dest+=", ";
4321+
dest+=convert(to_type);
4322+
dest+=", ";
43144323

4315-
unsigned p;
4316-
std::string tmp=convert(src.op0(), p);
4324+
unsigned p1;
4325+
std::string tmp1=convert(src.op1(), p1);
43174326

4318-
if(precedence>p) dest+='(';
4319-
dest+=tmp;
4320-
if(precedence>p) dest+=')';
4327+
if(p1<=1) dest+='(';
4328+
dest+=tmp1;
4329+
if(p1<=1) dest+=')';
43214330

4331+
dest+=')';
43224332
return dest;
4323-
#endif
43244333
}
43254334

43264335
else if(src.id()==ID_sign)

0 commit comments

Comments
 (0)