Skip to content

Commit c117acd

Browse files
committed
Fix operator parsing
1 parent c5de7ba commit c117acd

File tree

6 files changed

+39
-4
lines changed

6 files changed

+39
-4
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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) { return n * value; }
12+
};
13+
14+
int operator+(t1 left, int right)
15+
{
16+
return left.value + right;
17+
}
18+
19+
int main()
20+
{
21+
t1 t(10);
22+
int t_1 = t + 5;
23+
int t_2 = t[5];
24+
assert(t_1 == 15);
25+
assert(t_2 == 50);
26+
return 0;
27+
}
Lines changed: 8 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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)