Skip to content

Commit 325a51a

Browse files
committed
gcc-style asm aliases have multiple subtypes
The front-end generates ireps with multiple sub-ireps for gcc's __asm__ aliases. This changes the use of .has_subtype() to checking whether there is more than one.
1 parent b7c4940 commit 325a51a

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/ansi-c/ansi_c_convert_type.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@ void ansi_c_convert_typet::read_rec(const typet &type)
4545
c_qualifiers.is_volatile=true;
4646
else if(type.id()==ID_asm)
4747
{
48-
if(type.has_subtype() &&
49-
type.subtype().id()==ID_string_constant)
50-
c_storage_spec.asm_label = to_string_constant(type.subtype()).get_value();
48+
// These can have up to 5 subtypes; we only use the first one.
49+
const auto &type_with_subtypes = to_type_with_subtypes(type);
50+
if(
51+
!type_with_subtypes.subtypes().empty() &&
52+
type_with_subtypes.subtypes()[0].id() == ID_string_constant)
53+
c_storage_spec.asm_label =
54+
to_string_constant(type_with_subtypes.subtypes()[0]).get_value();
5155
}
5256
else if(type.id()==ID_section &&
5357
type.has_subtype() &&

src/ansi-c/c_storage_spec.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,12 @@ void c_storage_spect::read(const typet &type)
5252
{
5353
alias = to_string_constant(type.subtype()).get_value();
5454
}
55-
else if(type.id()==ID_asm &&
56-
type.has_subtype() &&
57-
type.subtype().id()==ID_string_constant)
55+
else if(
56+
type.id() == ID_asm && !to_type_with_subtypes(type).subtypes().empty() &&
57+
to_type_with_subtypes(type).subtypes()[0].id() == ID_string_constant)
5858
{
59-
asm_label = to_string_constant(type.subtype()).get_value();
59+
asm_label =
60+
to_string_constant(to_type_with_subtypes(type).subtypes()[0]).get_value();
6061
}
6162
else if(type.id()==ID_section &&
6263
type.has_subtype() &&

0 commit comments

Comments
 (0)