Skip to content

Commit

Permalink
Swap order of subtypes in construction of merged_type nodes
Browse files Browse the repository at this point in the history
Main type needs to be at the end.
Handle and record GCC function attribute noreturn.
  • Loading branch information
andreast271 authored and tautschnig committed Jun 11, 2018
1 parent 4a47de6 commit 999ad15
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
8 changes: 6 additions & 2 deletions src/cpp/cpp_convert_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class cpp_convert_typet
unsigned unsigned_cnt, signed_cnt, char_cnt, int_cnt, short_cnt,
long_cnt, const_cnt, restrict_cnt, constexpr_cnt, volatile_cnt,
double_cnt, float_cnt, complex_cnt, cpp_bool_cnt, proper_bool_cnt,
extern_cnt, wchar_t_cnt, char16_t_cnt, char32_t_cnt,
extern_cnt, noreturn_cnt, wchar_t_cnt, char16_t_cnt, char32_t_cnt,
int8_cnt, int16_cnt, int32_cnt, int64_cnt, ptr32_cnt, ptr64_cnt,
float128_cnt, int128_cnt;

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

Expand Down Expand Up @@ -132,6 +132,10 @@ void cpp_convert_typet::read_rec(const typet &type)
constexpr_cnt++;
else if(type.id()==ID_extern)
extern_cnt++;
else if(type.id()==ID_noreturn)
{
noreturn_cnt++;
}
else if(type.id()==ID_function_type)
{
read_function_type(type);
Expand Down
25 changes: 12 additions & 13 deletions src/cpp/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,12 @@ void Parser::merge_types(const typet &src, typet &dest)
dest=tmp;
}

dest.copy_to_subtypes(src);
// the end of the subtypes container needs to stay the same,
// since several analysis functions traverse via the end for
// merged_types
typet::subtypest &sub=dest.subtypes();
sub.emplace(sub.begin(), src);
POSTCONDITION(!dest.subtypes().empty());
}
}

Expand Down Expand Up @@ -3199,12 +3204,9 @@ bool Parser::optPtrOperator(typet &ptrs)
cv.make_nil();
optCvQualify(cv); // the qualifier is for the pointer
if(cv.is_not_nil())
{
merge_types(op, cv);
t_list.push_back(cv);
}
else
t_list.push_back(op);
merge_types(cv, op);

t_list.push_back(op);
}
else if(t=='^')
{
Expand All @@ -3218,12 +3220,9 @@ bool Parser::optPtrOperator(typet &ptrs)
cv.make_nil();
optCvQualify(cv); // the qualifier is for the pointer
if(cv.is_not_nil())
{
merge_types(op, cv);
t_list.push_back(cv);
}
else
t_list.push_back(op);
merge_types(cv, op);

t_list.push_back(op);
}
else if(isPtrToMember(0))
{
Expand Down

0 comments on commit 999ad15

Please sign in to comment.