Skip to content

Commit 40f0b39

Browse files
committed
EXP39-C add .expected.qcc file
RULE-21-4 `setjmp` and `longjmp` can be macros or functions
1 parent 77c2966 commit 40f0b39

File tree

3 files changed

+93
-32
lines changed

3 files changed

+93
-32
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
edges
2+
| test.c:49:8:49:9 | s3 | test.c:50:8:50:9 | s1 |
3+
| test.c:60:16:60:18 | E1A | test.c:61:16:61:17 | e1 |
4+
| test.c:60:16:60:18 | E1A | test.c:65:10:65:12 | & ... |
5+
| test.c:68:22:68:22 | v | test.c:68:41:68:41 | v |
6+
| test.c:72:13:72:15 | & ... | test.c:68:22:68:22 | v |
7+
| test.c:74:13:74:15 | & ... | test.c:68:22:68:22 | v |
8+
| test.c:97:32:97:37 | call to malloc | test.c:98:40:98:41 | s2 |
9+
| test.c:97:32:97:37 | call to malloc | test.c:98:40:98:41 | s2 |
10+
| test.c:98:32:98:38 | call to realloc | test.c:99:3:99:4 | s3 |
11+
| test.c:98:32:98:38 | call to realloc | test.c:100:10:100:11 | s3 |
12+
| test.c:98:40:98:41 | s2 | test.c:98:32:98:38 | call to realloc |
13+
nodes
14+
| file:///opt/qcc/qnx-sdp/target/qnx7/usr/include/stdlib.h:98:42:98:47 | __func | semmle.label | __func |
15+
| file:///opt/qcc/qnx-sdp/target/qnx7/usr/include/stdlib.h:98:50:98:53 | 0 | semmle.label | 0 |
16+
| test.c:6:19:6:20 | & ... | semmle.label | & ... |
17+
| test.c:11:10:11:11 | & ... | semmle.label | & ... |
18+
| test.c:13:17:13:19 | & ... | semmle.label | & ... |
19+
| test.c:15:17:15:19 | & ... | semmle.label | & ... |
20+
| test.c:19:18:19:20 | & ... | semmle.label | & ... |
21+
| test.c:20:20:20:22 | & ... | semmle.label | & ... |
22+
| test.c:22:11:22:13 | & ... | semmle.label | & ... |
23+
| test.c:27:17:27:19 | & ... | semmle.label | & ... |
24+
| test.c:28:10:28:12 | & ... | semmle.label | & ... |
25+
| test.c:29:13:29:15 | & ... | semmle.label | & ... |
26+
| test.c:30:19:30:21 | & ... | semmle.label | & ... |
27+
| test.c:31:16:31:18 | & ... | semmle.label | & ... |
28+
| test.c:47:8:47:9 | s2 | semmle.label | s2 |
29+
| test.c:49:8:49:9 | s3 | semmle.label | s3 |
30+
| test.c:49:8:49:9 | s3 | semmle.label | s3 |
31+
| test.c:50:8:50:9 | s1 | semmle.label | s1 |
32+
| test.c:60:16:60:18 | E1A | semmle.label | E1A |
33+
| test.c:60:16:60:18 | E1A | semmle.label | E1A |
34+
| test.c:61:16:61:17 | e1 | semmle.label | e1 |
35+
| test.c:65:10:65:12 | & ... | semmle.label | & ... |
36+
| test.c:68:22:68:22 | v | semmle.label | v |
37+
| test.c:68:41:68:41 | v | semmle.label | v |
38+
| test.c:72:13:72:15 | & ... | semmle.label | & ... |
39+
| test.c:72:13:72:15 | & ... | semmle.label | & ... |
40+
| test.c:74:13:74:15 | & ... | semmle.label | & ... |
41+
| test.c:74:13:74:15 | & ... | semmle.label | & ... |
42+
| test.c:97:32:97:37 | call to malloc | semmle.label | call to malloc |
43+
| test.c:97:32:97:37 | call to malloc | semmle.label | call to malloc |
44+
| test.c:98:32:98:38 | call to realloc | semmle.label | call to realloc |
45+
| test.c:98:32:98:38 | call to realloc | semmle.label | call to realloc |
46+
| test.c:98:32:98:38 | call to realloc | semmle.label | call to realloc |
47+
| test.c:98:40:98:41 | s2 | semmle.label | s2 |
48+
| test.c:98:40:98:41 | s2 | semmle.label | s2 |
49+
| test.c:99:3:99:4 | s3 | semmle.label | s3 |
50+
| test.c:100:10:100:11 | s3 | semmle.label | s3 |
51+
subpaths
52+
#select
53+
| test.c:6:19:6:20 | & ... | test.c:6:19:6:20 | & ... | test.c:6:19:6:20 | & ... | Cast from float to int results in an incompatible pointer base type. |
54+
| test.c:11:10:11:11 | & ... | test.c:11:10:11:11 | & ... | test.c:11:10:11:11 | & ... | Cast from short[2] to int results in an incompatible pointer base type. |
55+
| test.c:13:17:13:19 | & ... | test.c:13:17:13:19 | & ... | test.c:13:17:13:19 | & ... | Cast from short[2] to short[4] results in an incompatible pointer base type. |
56+
| test.c:19:18:19:20 | & ... | test.c:19:18:19:20 | & ... | test.c:19:18:19:20 | & ... | Cast from char to signed char results in an incompatible pointer base type. |
57+
| test.c:30:19:30:21 | & ... | test.c:30:19:30:21 | & ... | test.c:30:19:30:21 | & ... | Cast from int to unsigned int results in an incompatible pointer base type. |
58+
| test.c:47:8:47:9 | s2 | test.c:47:8:47:9 | s2 | test.c:47:8:47:9 | s2 | Cast from struct <unnamed> to struct <unnamed> results in an incompatible pointer base type. |
59+
| test.c:49:8:49:9 | s3 | test.c:49:8:49:9 | s3 | test.c:49:8:49:9 | s3 | Cast from S1 to struct <unnamed> results in an incompatible pointer base type. |
60+
| test.c:50:8:50:9 | s1 | test.c:50:8:50:9 | s1 | test.c:50:8:50:9 | s1 | Cast from struct <unnamed> to S1 results in an incompatible pointer base type. |
61+
| test.c:68:41:68:41 | v | test.c:72:13:72:15 | & ... | test.c:68:41:68:41 | v | Cast from float to int results in an incompatible pointer base type. |
62+
| test.c:99:3:99:4 | s3 | test.c:98:40:98:41 | s2 | test.c:99:3:99:4 | s3 | Cast from S2 to S3 results in an incompatible pointer base type. |

c/misra/src/rules/RULE-21-4/StandardHeaderFileUsedSetjmph.ql

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,32 @@
1010
* external/misra/obligation/required
1111
*/
1212

13-
import cpp
14-
import codingstandards.c.misra
15-
16-
class SetJmp extends Macro {
17-
SetJmp() {
18-
this.hasName("setjmp") and
19-
this.getFile().getAbsolutePath().matches("%setjmp.h")
20-
}
21-
}
22-
23-
class LongJmp extends Function {
24-
LongJmp() {
25-
this.hasName("longjmp") and
26-
this.getFile().getAbsolutePath().matches("%setjmp.h")
27-
}
28-
}
29-
30-
from Locatable use, string name
31-
where
32-
not isExcluded(use, BannedPackage::standardHeaderFileUsedSetjmphQuery()) and
33-
(
34-
exists(SetJmp setjmp |
35-
use = setjmp.getAnInvocation() and
36-
name = "setjmp"
37-
)
38-
or
39-
exists(LongJmp longjmp |
40-
use = longjmp.getACallToThisFunction() and
41-
name = "longjmp"
42-
)
43-
)
44-
select use, "Use of " + name + "."
13+
import cpp
14+
import codingstandards.c.misra
15+
16+
class SetJmp extends Locatable {
17+
string name;
18+
19+
SetJmp() {
20+
this.getFile().getAbsolutePath().matches("%setjmp.h") and
21+
name = [this.(Macro).getName(), this.(Function).getName()] and
22+
name = ["setjmp", "longjmp"]
23+
}
24+
25+
Locatable getAnInvocation() {
26+
result = this.(Macro).getAnInvocation() or
27+
result = this.(Function).getACallToThisFunction()
28+
}
29+
30+
string getName() { result = name }
31+
}
32+
33+
from Locatable use, string name
34+
where
35+
not isExcluded(use, BannedPackage::standardHeaderFileUsedSetjmphQuery()) and
36+
exists(SetJmp jmp |
37+
use = jmp.getAnInvocation() and
38+
name = jmp.getName()
39+
)
40+
select use, "Use of " + name + "."
41+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| test.c:7:7:7:17 | setjmp(__env) | Use of setjmp. |
2+
| test.c:8:3:8:9 | call to longjmp | Use of longjmp. |

0 commit comments

Comments
 (0)