[clang] [Analysis] Avoid some warnings about exit from noreturn function (PR #144408)
Serge Pavlov via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 18 10:54:47 PDT 2025
================
@@ -0,0 +1,107 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify
+
+[[noreturn]] extern void noret();
+[[noreturn]] extern void noret2();
+extern void ordinary();
+
+typedef void (*func_type)(void);
+
+// Constant initialization.
+
+void (* const const_fptr)() = noret;
+[[noreturn]] void test_global_const() {
+ const_fptr();
+}
+
+const func_type const_fptr_cast = (func_type)noret2;
+[[noreturn]] void test_global_cast() {
+ const_fptr_cast();
+}
+
+void (* const const_fptr_list)() = {noret};
+[[noreturn]] void test_global_list() {
+ const_fptr_list();
+}
+
+const func_type const_fptr_fcast = func_type(noret2);
+[[noreturn]] void test_global_fcast() {
+ const_fptr_fcast();
+}
+
+[[noreturn]] void test_local_const() {
+ void (* const fptr)() = noret;
+ fptr();
+}
+
+// Global variable assignment.
+void (*global_fptr)() = noret;
+
+[[noreturn]] void test_global_noassign() {
+ global_fptr();
+} // expected-warning {{function declared 'noreturn' should not return}}
+
+[[noreturn]] void test_global_assign() {
+ global_fptr = noret;
+ global_fptr();
----------------
spavloff wrote:
You are right, multithreaded environment was not supported in the previous implementation.
https://github.com/llvm/llvm-project/pull/144408
More information about the cfe-commits
mailing list