Skip to content

Commit 759f939

Browse files
committed
C++: Add false positive.
1 parent c5612ae commit 759f939

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

cpp/ql/test/query-tests/Likely Bugs/Likely Typos/CompareWhereAssignMeant/CompareWhereAssignMeant.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@
66
| test.cpp:39:23:39:28 | ... == ... | This '==' operator has no effect. The assignment ('=') operator was probably intended. |
77
| test.cpp:42:23:42:28 | ... == ... | This '==' operator has no effect. The assignment ('=') operator was probably intended. |
88
| test.cpp:51:13:51:13 | call to operator== | This '==' operator has no effect. The assignment ('=') operator was probably intended. |
9+
| test.cpp:71:18:71:23 | ... == ... | This '==' operator has no effect. The assignment ('=') operator was probably intended. |
10+
| test.cpp:72:3:72:8 | ... == ... | This '==' operator has no effect. The assignment ('=') operator was probably intended. |
11+
| test.cpp:73:3:73:12 | ... == ... | This '==' operator has no effect. The assignment ('=') operator was probably intended. |

cpp/ql/test/query-tests/Likely Bugs/Likely Typos/CompareWhereAssignMeant/test.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,14 @@ template<typename T1, typename T2>
6161
auto sfinaeTrick(T1 x1, T2 x2) -> decltype(x1 == x2, bool()) { // GOOD
6262
return x1 == x2;
6363
}
64+
65+
void report_error(const char*);
66+
67+
#define DOES_NOT_THROW(E) do { try { E; } catch (...) { report_error(""); } } while(0)
68+
#define ID(X) (X)
69+
70+
void test_inside_macro_expansion(int x, int y) {
71+
DOES_NOT_THROW(x == y); // GOOD [FALSE POSITIVE]
72+
x == y; // BAD
73+
x == ID(y); // BAD
74+
}

0 commit comments

Comments
 (0)