Skip to content

Commit fa73b8b

Browse files
thk123peterschrammel
thk123
authored andcommitted
Use the symbol in expr2c
1 parent e2614ef commit fa73b8b

File tree

1 file changed

+29
-17
lines changed

1 file changed

+29
-17
lines changed

src/ansi-c/expr2c.cpp

+29-17
Original file line numberDiff line numberDiff line change
@@ -518,28 +518,40 @@ std::string expr2ct::convert_rec(
518518
}
519519
else if(src.id()==ID_symbol)
520520
{
521-
const typet &followed=ns.follow(src);
521+
symbol_typet symbolic_type=to_symbol_type(src);
522+
const irep_idt &typedef_identifer=symbolic_type.get(ID_typedef);
522523

523-
if(followed.id()==ID_struct)
524+
// Providing we have a valid identifer, we can just use that rather than
525+
// trying to find the concrete type
526+
if(typedef_identifer!="")
524527
{
525-
std::string dest=q+"struct";
526-
const irep_idt &tag=to_struct_type(followed).get_tag();
527-
if(tag!="")
528-
dest+=" "+id2string(tag);
529-
dest+=d;
530-
return dest;
528+
return q+id2string(typedef_identifer)+d;
531529
}
532-
else if(followed.id()==ID_union)
530+
else
533531
{
534-
std::string dest=q+"union";
535-
const irep_idt &tag=to_union_type(followed).get_tag();
536-
if(tag!="")
537-
dest+=" "+id2string(tag);
538-
dest+=d;
539-
return dest;
532+
const typet &followed=ns.follow(src);
533+
534+
if(followed.id()==ID_struct)
535+
{
536+
std::string dest=q+"struct";
537+
const irep_idt &tag=to_struct_type(followed).get_tag();
538+
if(tag!="")
539+
dest+=" "+id2string(tag);
540+
dest+=d;
541+
return dest;
542+
}
543+
else if(followed.id()==ID_union)
544+
{
545+
std::string dest=q+"union";
546+
const irep_idt &tag=to_union_type(followed).get_tag();
547+
if(tag!="")
548+
dest+=" "+id2string(tag);
549+
dest+=d;
550+
return dest;
551+
}
552+
else
553+
return convert_rec(followed, new_qualifiers, declarator);
540554
}
541-
else
542-
return convert_rec(followed, new_qualifiers, declarator);
543555
}
544556
else if(src.id()==ID_struct_tag)
545557
{

0 commit comments

Comments
 (0)