Skip to content

Commit 0f832d3

Browse files
committed
Fix for issue: 646
1 parent 02dfac9 commit 0f832d3

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#include <cstdint>
2+
3+
// @brief func1
4+
// @return exit code
5+
int32_t func1(void) noexcept { // COMPLIANT
6+
int32_t x; // CAUTION: uninitialized!!
7+
int32_t ret;
8+
ret = func2(x);
9+
return ret;
10+
}
11+
12+
// @brief func2
13+
// @param arg parameter
14+
// @return exit code
15+
int32_t func2(const int32_t arg) // COMPLIANT
16+
{
17+
int32_t ret;
18+
ret = arg * arg;
19+
return ret;
20+
}
21+
22+
namespace mains {
23+
static int32_t var;
24+
25+
// @brief namespace_func
26+
static void namespace_func(void) noexcept { // COMPLIANT
27+
mains::var = -1;
28+
return;
29+
}
30+
} // namespace
31+
32+
// @brief main
33+
// @return exit code
34+
int32_t main(void) {
35+
int32_t ret {0};
36+
try {
37+
ret = func1();
38+
mains::var += ret;
39+
}
40+
catch(...) {
41+
mains::namespace_func();
42+
}
43+
return ret;
44+
}

cpp/common/src/codingstandards/cpp/EncapsulatingFunctions.qll

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ abstract class EncapsulatingFunction extends Function { }
1414
class MainFunction extends MainLikeFunction {
1515
MainFunction() {
1616
hasGlobalName("main") and
17-
getType() instanceof IntType
17+
(
18+
getType() instanceof IntType or
19+
getType() instanceof Int32_t
20+
)
1821
}
1922
}
2023

0 commit comments

Comments
 (0)