Skip to content

Commit 3071732

Browse files
committed
added RULE-17-4
1 parent 88febcb commit 3071732

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* @id c/misra/non-void-function-return-condition
3+
* @name RULE-17-4: All exit paths from a function with non-void return type shall have an explicit return statement
4+
* @description Not returning with an expression from a non-void function can lead to undefined
5+
* behaviour.
6+
* @kind problem
7+
* @precision very-high
8+
* @problem.severity error
9+
* @tags external/misra/id/rule-17-4
10+
* correctness
11+
* maintainability
12+
* readability
13+
* external/misra/obligation/mandatory
14+
*/
15+
16+
import cpp
17+
import codingstandards.c.misra
18+
import codingstandards.cpp.rules.nonvoidfunctiondoesnotreturn.NonVoidFunctionDoesNotReturn
19+
20+
class NonVoidFunctionReturnConditionQuery extends NonVoidFunctionDoesNotReturnSharedQuery {
21+
NonVoidFunctionReturnConditionQuery() {
22+
this = Statements5Package::nonVoidFunctionReturnConditionQuery()
23+
}
24+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
c/common/test/rules/nonvoidfunctiondoesnotreturn/NonVoidFunctionDoesNotReturn.ql

rule_packages/c/Statements5.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"precision": "very-high",
5555
"severity": "error",
5656
"short_name": "NonVoidFunctionReturnCondition",
57+
"shared_implementation_short_name": "NonVoidFunctionDoesNotReturn",
5758
"tags": [
5859
"correctness",
5960
"maintainability",

0 commit comments

Comments
 (0)