Skip to content

Commit 1fe7cd7

Browse files
author
Daniel Kroening
committed
remove mathematical_typet() constructor, which produces an incomplete object
1 parent 25d393b commit 1fe7cd7

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

src/solvers/smt2/smt2_parser.cpp

+16-14
Original file line numberDiff line numberDiff line change
@@ -1028,26 +1028,27 @@ typet smt2_parsert::function_signature_definition()
10281028
return sort();
10291029
}
10301030

1031-
mathematical_function_typet result;
1031+
mathematical_function_typet::domaint domain;
10321032

10331033
while(peek()!=CLOSE)
10341034
{
10351035
if(next_token()!=OPEN)
10361036
{
10371037
error() << "expected '(' at beginning of parameter" << eom;
1038-
return result;
1038+
return nil_typet();
10391039
}
10401040

10411041
if(next_token()!=SYMBOL)
10421042
{
10431043
error() << "expected symbol in parameter" << eom;
1044-
return result;
1044+
return nil_typet();
10451045
}
10461046

1047-
auto &var=result.add_variable();
1047+
mathematical_function_typet::variablet var;
10481048
std::string id=buffer;
10491049
var.set_identifier(id);
10501050
var.type()=sort();
1051+
domain.push_back(var);
10511052

10521053
auto &entry=id_map[id];
10531054
entry.type=var.type();
@@ -1056,15 +1057,15 @@ typet smt2_parsert::function_signature_definition()
10561057
if(next_token()!=CLOSE)
10571058
{
10581059
error() << "expected ')' at end of parameter" << eom;
1059-
return result;
1060+
return nil_typet();
10601061
}
10611062
}
10621063

10631064
next_token(); // eat the ')'
10641065

1065-
result.codomain()=sort();
1066+
typet codomain = sort();
10661067

1067-
return result;
1068+
return mathematical_function_typet(domain, codomain);
10681069
}
10691070

10701071
typet smt2_parsert::function_signature_declaration()
@@ -1081,37 +1082,38 @@ typet smt2_parsert::function_signature_declaration()
10811082
return sort();
10821083
}
10831084

1084-
mathematical_function_typet result;
1085+
mathematical_function_typet::domaint domain;
10851086

10861087
while(peek()!=CLOSE)
10871088
{
10881089
if(next_token()!=OPEN)
10891090
{
10901091
error() << "expected '(' at beginning of parameter" << eom;
1091-
return result;
1092+
return nil_typet();
10921093
}
10931094

10941095
if(next_token()!=SYMBOL)
10951096
{
10961097
error() << "expected symbol in parameter" << eom;
1097-
return result;
1098+
return nil_typet();
10981099
}
10991100

1100-
auto &var=result.add_variable();
1101+
mathematical_function_typet::variablet var;
11011102
var.type()=sort();
1103+
domain.push_back(var);
11021104

11031105
if(next_token()!=CLOSE)
11041106
{
11051107
error() << "expected ')' at end of parameter" << eom;
1106-
return result;
1108+
return nil_typet();
11071109
}
11081110
}
11091111

11101112
next_token(); // eat the ')'
11111113

1112-
result.codomain()=sort();
1114+
typet codomain = sort();
11131115

1114-
return result;
1116+
return mathematical_function_typet(domain, codomain);
11151117
}
11161118

11171119
void smt2_parsert::command(const std::string &c)

src/util/std_types.h

+8-5
Original file line numberDiff line numberDiff line change
@@ -1686,11 +1686,6 @@ inline complex_typet &to_complex_type(typet &type)
16861686
class mathematical_function_typet:public typet
16871687
{
16881688
public:
1689-
mathematical_function_typet():typet(ID_mathematical_function)
1690-
{
1691-
subtypes().resize(2);
1692-
}
1693-
16941689
// the domain of the function is composed of zero, one, or
16951690
// many variables
16961691
class variablet:public irept
@@ -1720,6 +1715,14 @@ class mathematical_function_typet:public typet
17201715

17211716
using domaint=std::vector<variablet>;
17221717

1718+
mathematical_function_typet(const domaint &_domain, const typet &_codomain)
1719+
: typet(ID_mathematical_function)
1720+
{
1721+
subtypes().resize(2);
1722+
domain() = _domain;
1723+
codomain() = _codomain;
1724+
}
1725+
17231726
domaint &domain()
17241727
{
17251728
return (domaint &)subtypes()[0].subtypes();

0 commit comments

Comments
 (0)