Skip to content

Commit

Permalink
Fix operator parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
tautschnig committed Jun 7, 2018
1 parent 0d04f37 commit da5ce90
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 4 deletions.
28 changes: 28 additions & 0 deletions regression/cpp/Function_Overloading3/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
class t1
{
public:
t1(int n) : value(n)
{
}

int value;
int operator[](int n)
{
return n * value;
}
};

int operator+(t1 left, int right)
{
return left.value + right;
}

int main()
{
t1 t(10);
int t_1 = t + 5;
int t_2 = t[5];
__CPROVER_assert(t_1 == 15, "");
__CPROVER_assert(t_2 == 50, "");
return 0;
}
8 changes: 8 additions & 0 deletions regression/cpp/Function_Overloading3/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.cpp

^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
^CONVERSION ERROR$
2 changes: 1 addition & 1 deletion regression/cpp/Unary_Function_Overload1/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
KNOWNBUG
CORE
main.cpp

^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/cpp/Unary_Function_Overload2/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
KNOWNBUG
CORE
main.cpp

^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/cpp/Unary_Function_Overload3/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
KNOWNBUG
CORE
main.cpp

^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3402,7 +3402,7 @@ bool Parser::rOperatorName(irept &name)
case '<':
case '>':
case ',':
operator_id=irep_idt(std::string(static_cast<char>(t), 1));
operator_id = std::string(1, static_cast<char>(t));
break;

case TOK_MULTASSIGN: operator_id="*="; break;
Expand Down

0 comments on commit da5ce90

Please sign in to comment.