Skip to content

Commit da5ce90

Browse files
committed
Fix operator parsing
1 parent 0d04f37 commit da5ce90

File tree

6 files changed

+40
-4
lines changed

6 files changed

+40
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
class t1
2+
{
3+
public:
4+
t1(int n) : value(n)
5+
{
6+
}
7+
8+
int value;
9+
int operator[](int n)
10+
{
11+
return n * value;
12+
}
13+
};
14+
15+
int operator+(t1 left, int right)
16+
{
17+
return left.value + right;
18+
}
19+
20+
int main()
21+
{
22+
t1 t(10);
23+
int t_1 = t + 5;
24+
int t_2 = t[5];
25+
__CPROVER_assert(t_1 == 15, "");
26+
__CPROVER_assert(t_2 == 50, "");
27+
return 0;
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.cpp
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$

regression/cpp/Unary_Function_Overload1/test.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
CORE
22
main.cpp
33

44
^EXIT=0$

regression/cpp/Unary_Function_Overload2/test.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
CORE
22
main.cpp
33

44
^EXIT=0$

regression/cpp/Unary_Function_Overload3/test.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
CORE
22
main.cpp
33

44
^EXIT=0$

src/cpp/parse.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3402,7 +3402,7 @@ bool Parser::rOperatorName(irept &name)
34023402
case '<':
34033403
case '>':
34043404
case ',':
3405-
operator_id=irep_idt(std::string(static_cast<char>(t), 1));
3405+
operator_id = std::string(1, static_cast<char>(t));
34063406
break;
34073407

34083408
case TOK_MULTASSIGN: operator_id="*="; break;

0 commit comments

Comments
 (0)