Skip to content

Commit e6eaf5e

Browse files
authored
Merge pull request github#18510 from jketema/noreturn
C++: Support more "noreturn" attributes in DefaultOptions
2 parents 133e269 + ff0d495 commit e6eaf5e

File tree

4 files changed

+39
-4
lines changed

4 files changed

+39
-4
lines changed

cpp/ql/lib/DefaultOptions.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ class Options extends string {
5454
*
5555
* By default, this holds for `exit`, `_exit`, `_Exit`, `abort`,
5656
* `__assert_fail`, `longjmp`, `__builtin_unreachable` and any
57-
* function with a `noreturn` or `__noreturn__` attribute or
58-
* `noreturn` specifier.
57+
* function with a `noreturn`, `__noreturn__`, or `_Noreturn`
58+
* attribute or `noreturn` specifier.
5959
*/
6060
predicate exits(Function f) {
61-
f.getAnAttribute().hasName(["noreturn", "__noreturn__"])
61+
f.getAnAttribute().hasName(["noreturn", "__noreturn__", "_Noreturn"])
6262
or
6363
f.getASpecifier().hasName("noreturn")
6464
or
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* `DefaultOptions::exits` now holds for C23 functions with the `_Noreturn` or `___Noreturn__` attribute.

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)