Skip to content

Commit

Permalink
C++: Add more noreturn attribute tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jketema committed Jan 16, 2025
1 parent 02ac61f commit f4f5f28
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
| test.c:8:5:8:14 | declaration | Function f2 should return a value of type int but does not return a value here |
| test.c:25:9:25:14 | ExprStmt | Function f4 should return a value of type int but does not return a value here |
| test.c:39:9:39:14 | ExprStmt | Function f6 should return a value of type int but does not return a value here |
| test.c:117:5:117:10 | ExprStmt | Function f19 should return a value of type int but does not return a value here |
| test.c:123:5:123:10 | ExprStmt | Function f21 should return a value of type int but does not return a value here |
| test.c:135:5:135:10 | ExprStmt | Function f25 should return a value of type int but does not return a value here |
| test.cpp:16:1:18:1 | { ... } | Function g2 should return a value of type MyValue but does not return a value here |
| test.cpp:52:1:52:1 | return ... | Function g7 should return a value of type MyValue but does not return a value here |
| test.cpp:74:1:76:1 | { ... } | Function g10 should return a value of type second but does not return a value here |
Expand Down
26 changes: 25 additions & 1 deletion cpp/ql/test/query-tests/jsf/4.13 Functions/AV Rule 114/test.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// semmle-extractor-options: -std=c11
// semmle-extractor-options: -std=c23
int f1(void) {
int x = 1;
return 2;
Expand Down Expand Up @@ -110,3 +110,27 @@ int f17() {
if (__builtin_expect(1, 0))
__builtin_unreachable(); // GOOD
}

[[_Noreturn]] void f18();

int f19() {
f18(); // GOOD
}

[[___Noreturn__]] void f20();

int f21() {
f20(); // GOOD
}

[[noreturn]] void f22();

int f23() {
f22(); // GOOD
}

[[___noreturn__]] void f24();

int f25() {
f24(); // GOOD
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,10 @@ int g22() {
int g23() {
Aborting().a(); // GOOD [FALSE POSITIVE]
}

[[__noreturn__]]
int g24();

int g25() {
g24(); // GOOD
}

0 comments on commit f4f5f28

Please sign in to comment.