Skip to content

Commit 605b56f

Browse files
authored
Merge pull request github#1563 from geoffw0/constexprif
CPP: Test cases for EmptyBlock.ql with 'if constexpr'
2 parents 8823cdf + bbe7691 commit 605b56f

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
| empty_block.cpp:7:10:7:11 | { ... } | Empty block without comment |
2-
| empty_block.cpp:10:10:11:3 | { ... } | Empty block without comment |
3-
| empty_block.cpp:18:10:19:3 | { ... } | Empty block without comment |
1+
| empty_block.cpp:9:10:9:11 | { ... } | Empty block without comment |
2+
| empty_block.cpp:12:10:13:3 | { ... } | Empty block without comment |
3+
| empty_block.cpp:20:10:21:3 | { ... } | Empty block without comment |

cpp/ql/test/query-tests/Best Practices/Likely Errors/EmptyBlock/empty_block.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// semmle-extractor-options: -std=c++17
2+
13
// GOOD:
24
void f() {
35
}
@@ -54,4 +56,29 @@ int f(int x) {
5456

5557
// GOOD (has comment): [FALSE POSITIVE]
5658
if (x) {} // comment
59+
60+
// GOOD
61+
if (x) {
62+
if constexpr(1) {
63+
f();
64+
}
65+
}
66+
67+
// GOOD
68+
if (x) {
69+
if constexpr(0) {
70+
f();
71+
}
72+
}
73+
74+
// GOOD
75+
if (x) {
76+
if constexpr(1) {
77+
f();
78+
} else {
79+
f();
80+
}
81+
}
82+
83+
return 1;
5784
}

0 commit comments

Comments
 (0)