Skip to content

Commit d86a1bc

Browse files
committed
Fix operator parsing
1 parent c5de7ba commit d86a1bc

File tree

6 files changed

+42
-4
lines changed

6 files changed

+42
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include <cassert>
2+
3+
class t1
4+
{
5+
public:
6+
t1(int n) : value(n)
7+
{
8+
}
9+
10+
int value;
11+
int operator[](int n)
12+
{
13+
return n * value;
14+
}
15+
};
16+
17+
int operator+(t1 left, int right)
18+
{
19+
return left.value + right;
20+
}
21+
22+
int main()
23+
{
24+
t1 t(10);
25+
int t_1 = t + 5;
26+
int t_2 = t[5];
27+
assert(t_1 == 15);
28+
assert(t_2 == 50);
29+
return 0;
30+
}
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)