Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5b09e11

Browse files
committed
CPP: Repair macro case.
1 parent d6f27f0 commit 5b09e11

3 files changed

Lines changed: 2 additions & 2 deletions

File tree

cpp/ql/src/Likely Bugs/Likely Typos/ExprHasNoEffect.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ where // EQExprs are covered by CompareWhereAssignMeant.ql
9999
not peivc.(FunctionCall).getTarget().hasName("operator==") and
100100
not accessInInitOfForStmt(peivc) and
101101
not peivc.isCompilerGenerated() and
102+
not exists(Macro m | peivc = m.getAnInvocation().getAnExpandedElement()) and
102103
not peivc.isFromTemplateInstantiation(_) and
103104
parent = peivc.getParent() and
104105
not parent.isInMacroExpansion() and

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
| macros.c:6:9:6:13 | param | This expression has no effect. | macros.c:6:9:6:13 | param | |
21
| preproc.c:89:2:89:4 | call to fn4 | This expression has no effect (because $@ has no external side effects). | preproc.c:33:5:33:7 | fn4 | fn4 |
32
| preproc.c:94:2:94:4 | call to fn9 | This expression has no effect (because $@ has no external side effects). | preproc.c:78:5:78:7 | fn9 | fn9 |
43
| template.cpp:19:3:19:3 | call to operator++ | This expression has no effect (because $@ has no external side effects). | template.cpp:9:10:9:19 | operator++ | operator++ |

cpp/ql/test/query-tests/Likely Bugs/Likely Typos/ExprHasNoEffect/macros.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33

44
void test2(int param)
55
{
6-
UNUSED(param); // GOOD [FALSE POSITIVE]
6+
UNUSED(param); // GOOD
77
}

0 commit comments

Comments
 (0)