Skip to content

Commit eb5616d

Browse files
committed
Distinguish stream operators from binary shifts
1 parent 44a57ac commit eb5616d

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `A13-2-2` - `BinaryOperatorAndBitwiseOperatorReturnAPrvalue.ql`:
2+
- Remove findings related to stream operators.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
| test.cpp:16:9:16:17 | operator- | User-defined bitwise or arithmetic operator operator-(const A &, int) -> const A does not return a prvalue. |
22
| test.cpp:20:4:20:12 | operator\| | User-defined bitwise or arithmetic operator operator\|(const A &, const A &) -> A * does not return a prvalue. |
3-
| test.cpp:29:6:29:14 | operator+ | User-defined bitwise or arithmetic operator NS_C::operator+(const C &, const C &) -> int & does not return a prvalue. |
3+
| test.cpp:24:9:24:18 | operator<< | User-defined bitwise or arithmetic operator operator<<(const A &, const A &) -> const A does not return a prvalue. |
4+
| test.cpp:34:6:34:14 | operator+ | User-defined bitwise or arithmetic operator NS_C::operator+(const C &, const C &) -> int & does not return a prvalue. |

cpp/autosar/test/rules/A13-2-2/test.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ A *operator|(A const &a1, A const &a2) noexcept { // NON_COMPLIANT
2121
return new A();
2222
}
2323

24+
const A operator<<(A const &, A const &) noexcept // NON_COMPLIANT
25+
{
26+
return A{};
27+
}
28+
2429
class C {
2530
C &operator=(const C &rhs);
2631
};
@@ -31,3 +36,10 @@ int &operator+(const C &lhs, const C &rhs) { // NON_COMPLIANT
3136
return slocal;
3237
}
3338
} // namespace NS_C
39+
40+
#include <iostream>
41+
struct Test {};
42+
std::ostream &operator<<(std::ostream &os, const Test &) { // COMPLIANT
43+
os << "test";
44+
return os;
45+
}

0 commit comments

Comments
 (0)