Skip to content

Commit 36246e1

Browse files
andreast271tautschnig
authored andcommitted
Swap order of subtypes in construction of merged_type nodes,
so that the main type is at the end. Handle and record GCC function attribute noreturn.
1 parent d7a6d9b commit 36246e1

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

src/cpp/cpp_convert_type.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class cpp_convert_typet
2828
unsigned unsigned_cnt, signed_cnt, char_cnt, int_cnt, short_cnt,
2929
long_cnt, const_cnt, restrict_cnt, constexpr_cnt, volatile_cnt,
3030
double_cnt, float_cnt, complex_cnt, cpp_bool_cnt, proper_bool_cnt,
31-
extern_cnt, wchar_t_cnt, char16_t_cnt, char32_t_cnt,
31+
extern_cnt, noreturn_cnt, wchar_t_cnt, char16_t_cnt, char32_t_cnt,
3232
int8_cnt, int16_cnt, int32_cnt, int64_cnt, ptr32_cnt, ptr64_cnt,
3333
float128_cnt, int128_cnt;
3434

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

@@ -130,6 +130,10 @@ void cpp_convert_typet::read_rec(const typet &type)
130130
constexpr_cnt++;
131131
else if(type.id()==ID_extern)
132132
extern_cnt++;
133+
else if(type.id()==ID_noreturn)
134+
{
135+
noreturn_cnt++;
136+
}
133137
else if(type.id()==ID_function_type)
134138
{
135139
read_function_type(type);

src/cpp/parse.cpp

Lines changed: 12 additions & 13 deletions
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

@@ -3201,12 +3206,9 @@ bool Parser::optPtrOperator(typet &ptrs)
32013206
cv.make_nil();
32023207
optCvQualify(cv); // the qualifier is for the pointer
32033208
if(cv.is_not_nil())
3204-
{
3205-
merge_types(op, cv);
3206-
t_list.push_back(cv);
3207-
}
3208-
else
3209-
t_list.push_back(op);
3209+
merge_types(cv, op);
3210+
3211+
t_list.push_back(op);
32103212
}
32113213
else if(t=='^')
32123214
{
@@ -3220,12 +3222,9 @@ bool Parser::optPtrOperator(typet &ptrs)
32203222
cv.make_nil();
32213223
optCvQualify(cv); // the qualifier is for the pointer
32223224
if(cv.is_not_nil())
3223-
{
3224-
merge_types(op, cv);
3225-
t_list.push_back(cv);
3226-
}
3227-
else
3228-
t_list.push_back(op);
3225+
merge_types(cv, op);
3226+
3227+
t_list.push_back(op);
32293228
}
32303229
else if(isPtrToMember(0))
32313230
{

0 commit comments

Comments
 (0)