Skip to content

Commit f4f5f28

Browse files
committed
C++: Add more noreturn attribute tests
1 parent 02ac61f commit f4f5f28

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

cpp/ql/test/query-tests/jsf/4.13 Functions/AV Rule 114/AV Rule 114.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
| test.c:8:5:8:14 | declaration | Function f2 should return a value of type int but does not return a value here |
44
| test.c:25:9:25:14 | ExprStmt | Function f4 should return a value of type int but does not return a value here |
55
| test.c:39:9:39:14 | ExprStmt | Function f6 should return a value of type int but does not return a value here |
6+
| test.c:117:5:117:10 | ExprStmt | Function f19 should return a value of type int but does not return a value here |
7+
| test.c:123:5:123:10 | ExprStmt | Function f21 should return a value of type int but does not return a value here |
8+
| test.c:135:5:135:10 | ExprStmt | Function f25 should return a value of type int but does not return a value here |
69
| test.cpp:16:1:18:1 | { ... } | Function g2 should return a value of type MyValue but does not return a value here |
710
| test.cpp:52:1:52:1 | return ... | Function g7 should return a value of type MyValue but does not return a value here |
811
| test.cpp:74:1:76:1 | { ... } | Function g10 should return a value of type second but does not return a value here |

cpp/ql/test/query-tests/jsf/4.13 Functions/AV Rule 114/test.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// semmle-extractor-options: -std=c11
1+
// semmle-extractor-options: -std=c23
22
int f1(void) {
33
int x = 1;
44
return 2;
@@ -110,3 +110,27 @@ int f17() {
110110
if (__builtin_expect(1, 0))
111111
__builtin_unreachable(); // GOOD
112112
}
113+
114+
[[_Noreturn]] void f18();
115+
116+
int f19() {
117+
f18(); // GOOD
118+
}
119+
120+
[[___Noreturn__]] void f20();
121+
122+
int f21() {
123+
f20(); // GOOD
124+
}
125+
126+
[[noreturn]] void f22();
127+
128+
int f23() {
129+
f22(); // GOOD
130+
}
131+
132+
[[___noreturn__]] void f24();
133+
134+
int f25() {
135+
f24(); // GOOD
136+
}

cpp/ql/test/query-tests/jsf/4.13 Functions/AV Rule 114/test.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,10 @@ int g22() {
188188
int g23() {
189189
Aborting().a(); // GOOD [FALSE POSITIVE]
190190
}
191+
192+
[[__noreturn__]]
193+
int g24();
194+
195+
int g25() {
196+
g24(); // GOOD
197+
}

0 commit comments

Comments
 (0)