- Notifications
You must be signed in to change notification settings - Fork70
Consider "main()" with typedef'd int return type as MainFunction#647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
10 commits Select commitHold shift + click to select a range
0f832d3 Fix for issue: 646
rak3-sh8c28f1e Added tests and generalized fix
rak3-sh9f88e85 Added change note for #646
rak3-shaed7701 Delete cpp/autosar/test/rules/M0-1-10/test_main_variant.cpp
rak3-sh26f2b31 Merge branch 'main' into rp/m0-1-10-646
rak3-shd0807db Corrected formatting
rak3-sh9022a70 Merge branch 'main' into rp/m0-1-10-646
rak3-sh0b02dc4 Merge branch 'main' into rp/m0-1-10-646
rak3-sh0c20066 Add a non-compliant case.
rak3-sh6a1b283 Modify comment to follow standard convention.
rak3-shFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
2 changes: 2 additions & 0 deletionschange_notes/2024-07-23-fix-fp-646-M0-1-10.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| - `M0-1-10` - `EncapsulatingFunctions.qll`: | ||
| - Fixes #646. Consider typedef'd `int` return types for `main()` function as MainFunction. |
1 change: 1 addition & 0 deletionscpp/autosar/test/rules/M0-1-10.1/UnusedFunction.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| | test.cpp:23:14:23:26 | uncalled_func | Function uncalled_func is never called. | |
1 change: 1 addition & 0 deletionscpp/autosar/test/rules/M0-1-10.1/UnusedFunction.qlref
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| rules/M0-1-10/UnusedFunction.ql |
39 changes: 39 additions & 0 deletionscpp/autosar/test/rules/M0-1-10.1/test.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| #include <cstdint> | ||
lcartey marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| namespace mains { | ||
| static std::int32_t var; | ||
| // @brief namespace_func | ||
| static void | ||
| namespace_func(void) noexcept { // COMPLIANT: Called from "main" below. | ||
| mains::var = -1; | ||
| return; | ||
| } | ||
| } // namespace mains | ||
| std::int32_t func2() // COMPLIANT: Called from func1 | ||
| { | ||
| return mains::var + 20; | ||
| } | ||
| std::int32_t func1() { // COMPLIANT: Called from main | ||
| return mains::var + func2(); // func2 called here. | ||
| } | ||
| std::int32_t uncalled_func() // NON_COMPLIANT: Not called. | ||
| { | ||
| return mains::var + func1(); // func1 called here. | ||
| } | ||
| // @brief main | ||
| // @return exit code | ||
| std::int32_t main(void) { | ||
| std::int32_t ret{0}; | ||
| try { | ||
| ret = func1(); // func1 called here. | ||
| mains::var += ret; | ||
| } catch (...) { | ||
| mains::namespace_func(); // namespace_func called here. | ||
| } | ||
| return ret; | ||
| } | ||
2 changes: 1 addition & 1 deletioncpp/common/src/codingstandards/cpp/EncapsulatingFunctions.qll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions...n/test/library/codingstandards/cpp/mainlikefunctions/typedefint/MainLikeFunction.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| | test.cpp:5:9:5:12 | main | |
5 changes: 5 additions & 0 deletionscpp/common/test/library/codingstandards/cpp/mainlikefunctions/typedefint/MainLikeFunction.ql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import cpp | ||
| import codingstandards.cpp.EncapsulatingFunctions | ||
| from MainFunction m | ||
| select m |
8 changes: 8 additions & 0 deletionscpp/common/test/library/codingstandards/cpp/mainlikefunctions/typedefint/test.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| typedef signed int int32_t; | ||
| // @brief main | ||
| // @return exit code | ||
| int32_t main(void) { | ||
| int32_t ret{0}; | ||
| return ret; | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.