Skip to content

Commit f165ca9

Browse files
committed
Fix operator parsing
1 parent a67c62b commit f165ca9

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <cassert>
2+
3+
class t1{
4+
public:
5+
t1 (int n) :value(n) {}
6+
public:
7+
int value;
8+
int operator[](int n) { return n*value; }
9+
};
10+
11+
int operator+(t1 left, int right) {return left.value+right;}
12+
13+
int main()
14+
{
15+
t1 t(10);
16+
int t_1 = t + 5;
17+
int t_2 = t[5];
18+
assert(t_1 == 15);
19+
assert(t_2 == 50);
20+
return 0;
21+
}
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_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
@@ -3578,7 +3578,7 @@ bool Parser::rOperatorName(irept &name)
35783578
case '<':
35793579
case '>':
35803580
case ',':
3581-
operator_id=irep_idt(std::string(static_cast<char>(t), 1));
3581+
operator_id=irep_idt(std::string(1, static_cast<char>(t)));
35823582
break;
35833583

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

0 commit comments

Comments
 (0)