Skip to content

Commit 999ad15

Browse files
andreast271tautschnig
authored andcommitted
Swap order of subtypes in construction of merged_type nodes
Main type needs to be at the end. Handle and record GCC function attribute noreturn.
1 parent 4a47de6 commit 999ad15

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

src/cpp/cpp_convert_type.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class cpp_convert_typet
3030
unsigned unsigned_cnt, signed_cnt, char_cnt, int_cnt, short_cnt,
3131
long_cnt, const_cnt, restrict_cnt, constexpr_cnt, volatile_cnt,
3232
double_cnt, float_cnt, complex_cnt, cpp_bool_cnt, proper_bool_cnt,
33-
extern_cnt, wchar_t_cnt, char16_t_cnt, char32_t_cnt,
33+
extern_cnt, noreturn_cnt, wchar_t_cnt, char16_t_cnt, char32_t_cnt,
3434
int8_cnt, int16_cnt, int32_cnt, int64_cnt, ptr32_cnt, ptr64_cnt,
3535
float128_cnt, int128_cnt;
3636

@@ -53,7 +53,7 @@ void cpp_convert_typet::read(const typet &type)
5353
unsigned_cnt=signed_cnt=char_cnt=int_cnt=short_cnt=
5454
long_cnt=const_cnt=restrict_cnt=constexpr_cnt=volatile_cnt=
5555
double_cnt=float_cnt=complex_cnt=cpp_bool_cnt=proper_bool_cnt=
56-
extern_cnt=wchar_t_cnt=char16_t_cnt=char32_t_cnt=
56+
extern_cnt=noreturn_cnt=wchar_t_cnt=char16_t_cnt=char32_t_cnt=
5757
int8_cnt=int16_cnt=int32_cnt=int64_cnt=
5858
ptr32_cnt=ptr64_cnt=float128_cnt=int128_cnt=0;
5959

@@ -132,6 +132,10 @@ void cpp_convert_typet::read_rec(const typet &type)
132132
constexpr_cnt++;
133133
else if(type.id()==ID_extern)
134134
extern_cnt++;
135+
else if(type.id()==ID_noreturn)
136+
{
137+
noreturn_cnt++;
138+
}
135139
else if(type.id()==ID_function_type)
136140
{
137141
read_function_type(type);

src/cpp/parse.cpp

+12-13
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,12 @@ void Parser::merge_types(const typet &src, typet &dest)
480480
dest=tmp;
481481
}
482482

483-
dest.copy_to_subtypes(src);
483+
// the end of the subtypes container needs to stay the same,
484+
// since several analysis functions traverse via the end for
485+
// merged_types
486+
typet::subtypest &sub=dest.subtypes();
487+
sub.emplace(sub.begin(), src);
488+
POSTCONDITION(!dest.subtypes().empty());
484489
}
485490
}
486491

@@ -3199,12 +3204,9 @@ bool Parser::optPtrOperator(typet &ptrs)
31993204
cv.make_nil();
32003205
optCvQualify(cv); // the qualifier is for the pointer
32013206
if(cv.is_not_nil())
3202-
{
3203-
merge_types(op, cv);
3204-
t_list.push_back(cv);
3205-
}
3206-
else
3207-
t_list.push_back(op);
3207+
merge_types(cv, op);
3208+
3209+
t_list.push_back(op);
32083210
}
32093211
else if(t=='^')
32103212
{
@@ -3218,12 +3220,9 @@ bool Parser::optPtrOperator(typet &ptrs)
32183220
cv.make_nil();
32193221
optCvQualify(cv); // the qualifier is for the pointer
32203222
if(cv.is_not_nil())
3221-
{
3222-
merge_types(op, cv);
3223-
t_list.push_back(cv);
3224-
}
3225-
else
3226-
t_list.push_back(op);
3223+
merge_types(cv, op);
3224+
3225+
t_list.push_back(op);
32273226
}
32283227
else if(isPtrToMember(0))
32293228
{

0 commit comments

Comments
 (0)