Merge pull request #1563 from geoffw0/constexprif

CPP: Test cases for EmptyBlock.ql with 'if constexpr'
This commit is contained in:
Jonas Jensen
2019-08-08 20:57:28 +02:00
committed by GitHub
2 changed files with 30 additions and 3 deletions

View File

@@ -1,3 +1,3 @@
| empty_block.cpp:7:10:7:11 | { ... } | Empty block without comment |
| empty_block.cpp:10:10:11:3 | { ... } | Empty block without comment |
| empty_block.cpp:18:10:19:3 | { ... } | Empty block without comment |
| empty_block.cpp:9:10:9:11 | { ... } | Empty block without comment |
| empty_block.cpp:12:10:13:3 | { ... } | Empty block without comment |
| empty_block.cpp:20:10:21:3 | { ... } | Empty block without comment |

View File

@@ -1,3 +1,5 @@
// semmle-extractor-options: -std=c++17
// GOOD:
void f() {
}
@@ -54,4 +56,29 @@ int f(int x) {
// GOOD (has comment): [FALSE POSITIVE]
if (x) {} // comment
// GOOD
if (x) {
if constexpr(1) {
f();
}
}
// GOOD
if (x) {
if constexpr(0) {
f();
}
}
// GOOD
if (x) {
if constexpr(1) {
f();
} else {
f();
}
}
return 1;
}