[llvm] [flang-rt][device] Silence warning missing return statement at end of non-void function (PR #156077)

Valentin Clement バレンタイン クレメン via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 29 11:52:34 PDT 2025


https://github.com/clementval updated https://github.com/llvm/llvm-project/pull/156077

>From fb8f12596cacf556e8db873886f83c610632b7d7 Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Fri, 29 Aug 2025 11:24:18 -0700
Subject: [PATCH 1/2] [flang-rt][device] Silence warning missing return
 statement at end of non-void function

---
 flang-rt/lib/runtime/io-stmt.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/flang-rt/lib/runtime/io-stmt.cpp b/flang-rt/lib/runtime/io-stmt.cpp
index 28149090eb169..e6f4f1b1e745d 100644
--- a/flang-rt/lib/runtime/io-stmt.cpp
+++ b/flang-rt/lib/runtime/io-stmt.cpp
@@ -984,6 +984,7 @@ ChildIoStatementState<DIR>::nonTbpDefinedIoTable() const {
   return child_.parent().nonTbpDefinedIoTable();
 #else
   ReportUnsupportedChildIo();
+  llvm_unreachable("unsupported child io");
 #endif
 }
 
@@ -994,6 +995,7 @@ void ChildIoStatementState<DIR>::set_nonTbpDefinedIoTable(
   child_.parent().set_nonTbpDefinedIoTable(table);
 #else
   ReportUnsupportedChildIo();
+  llvm_unreachable("unsupported child io");
 #endif
 }
 
@@ -1003,6 +1005,7 @@ ConnectionState &ChildIoStatementState<DIR>::GetConnectionState() {
   return child_.parent().GetConnectionState();
 #else
   ReportUnsupportedChildIo();
+  llvm_unreachable("unsupported child io");
 #endif
 }
 
@@ -1012,6 +1015,7 @@ ExternalFileUnit *ChildIoStatementState<DIR>::GetExternalFileUnit() const {
   return child_.parent().GetExternalFileUnit();
 #else
   ReportUnsupportedChildIo();
+  llvm_unreachable("unsupported child io");
 #endif
 }
 
@@ -1029,6 +1033,7 @@ bool ChildIoStatementState<DIR>::Emit(
   return child_.parent().Emit(data, bytes, elementBytes);
 #else
   ReportUnsupportedChildIo();
+  llvm_unreachable("unsupported child io");
 #endif
 }
 
@@ -1038,6 +1043,7 @@ std::size_t ChildIoStatementState<DIR>::GetNextInputBytes(const char *&p) {
   return child_.parent().GetNextInputBytes(p);
 #else
   ReportUnsupportedChildIo();
+  llvm_unreachable("unsupported child io");
 #endif
 }
 
@@ -1047,6 +1053,7 @@ void ChildIoStatementState<DIR>::HandleAbsolutePosition(std::int64_t n) {
   return child_.parent().HandleAbsolutePosition(n);
 #else
   ReportUnsupportedChildIo();
+  llvm_unreachable("unsupported child io");
 #endif
 }
 
@@ -1056,6 +1063,7 @@ void ChildIoStatementState<DIR>::HandleRelativePosition(std::int64_t n) {
   return child_.parent().HandleRelativePosition(n);
 #else
   ReportUnsupportedChildIo();
+  llvm_unreachable("unsupported child io");
 #endif
 }
 
@@ -1086,6 +1094,7 @@ bool ChildFormattedIoStatementState<DIR, CHAR>::AdvanceRecord(int n) {
   return this->child().parent().AdvanceRecord(n);
 #else
   this->ReportUnsupportedChildIo();
+  llvm_unreachable("unsupported child io");
 #endif
 }
 
@@ -1102,6 +1111,7 @@ ChildListIoStatementState<DIR>::ChildListIoStatementState(
   }
 #else
   this->ReportUnsupportedChildIo();
+  llvm_unreachable("unsupported child io");
 #endif
 }
 
@@ -1116,6 +1126,7 @@ bool ChildListIoStatementState<DIR>::AdvanceRecord(int n) {
   }
 #else
   this->ReportUnsupportedChildIo();
+  llvm_unreachable("unsupported child io");
 #endif
 }
 
@@ -1136,6 +1147,7 @@ bool ChildUnformattedIoStatementState<DIR>::Receive(
   return this->child().parent().Receive(data, bytes, elementBytes);
 #else
   this->ReportUnsupportedChildIo();
+  llvm_unreachable("unsupported child io");
 #endif
 }
 

>From 213d53b0904d0ada7cdea2b17cc58606e4f5b36d Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Fri, 29 Aug 2025 11:52:22 -0700
Subject: [PATCH 2/2] declare ReportUnsupportedChildIo as not returning

---
 flang-rt/include/flang-rt/runtime/io-stmt.h |  2 +-
 flang-rt/lib/runtime/io-stmt.cpp            | 12 ------------
 2 files changed, 1 insertion(+), 13 deletions(-)

diff --git a/flang-rt/include/flang-rt/runtime/io-stmt.h b/flang-rt/include/flang-rt/runtime/io-stmt.h
index 3d1ca5091e923..594299a8d3cc9 100644
--- a/flang-rt/include/flang-rt/runtime/io-stmt.h
+++ b/flang-rt/include/flang-rt/runtime/io-stmt.h
@@ -401,7 +401,7 @@ class IoStatementBase : public IoErrorHandler {
 
   RT_API_ATTRS void BadInquiryKeywordHashCrash(InquiryKeywordHash);
 
-  RT_API_ATTRS void ReportUnsupportedChildIo() const {
+  RT_API_ATTRS [[noreturn]] void ReportUnsupportedChildIo() const {
     Crash("not yet implemented: child IO");
   }
 
diff --git a/flang-rt/lib/runtime/io-stmt.cpp b/flang-rt/lib/runtime/io-stmt.cpp
index e6f4f1b1e745d..28149090eb169 100644
--- a/flang-rt/lib/runtime/io-stmt.cpp
+++ b/flang-rt/lib/runtime/io-stmt.cpp
@@ -984,7 +984,6 @@ ChildIoStatementState<DIR>::nonTbpDefinedIoTable() const {
   return child_.parent().nonTbpDefinedIoTable();
 #else
   ReportUnsupportedChildIo();
-  llvm_unreachable("unsupported child io");
 #endif
 }
 
@@ -995,7 +994,6 @@ void ChildIoStatementState<DIR>::set_nonTbpDefinedIoTable(
   child_.parent().set_nonTbpDefinedIoTable(table);
 #else
   ReportUnsupportedChildIo();
-  llvm_unreachable("unsupported child io");
 #endif
 }
 
@@ -1005,7 +1003,6 @@ ConnectionState &ChildIoStatementState<DIR>::GetConnectionState() {
   return child_.parent().GetConnectionState();
 #else
   ReportUnsupportedChildIo();
-  llvm_unreachable("unsupported child io");
 #endif
 }
 
@@ -1015,7 +1012,6 @@ ExternalFileUnit *ChildIoStatementState<DIR>::GetExternalFileUnit() const {
   return child_.parent().GetExternalFileUnit();
 #else
   ReportUnsupportedChildIo();
-  llvm_unreachable("unsupported child io");
 #endif
 }
 
@@ -1033,7 +1029,6 @@ bool ChildIoStatementState<DIR>::Emit(
   return child_.parent().Emit(data, bytes, elementBytes);
 #else
   ReportUnsupportedChildIo();
-  llvm_unreachable("unsupported child io");
 #endif
 }
 
@@ -1043,7 +1038,6 @@ std::size_t ChildIoStatementState<DIR>::GetNextInputBytes(const char *&p) {
   return child_.parent().GetNextInputBytes(p);
 #else
   ReportUnsupportedChildIo();
-  llvm_unreachable("unsupported child io");
 #endif
 }
 
@@ -1053,7 +1047,6 @@ void ChildIoStatementState<DIR>::HandleAbsolutePosition(std::int64_t n) {
   return child_.parent().HandleAbsolutePosition(n);
 #else
   ReportUnsupportedChildIo();
-  llvm_unreachable("unsupported child io");
 #endif
 }
 
@@ -1063,7 +1056,6 @@ void ChildIoStatementState<DIR>::HandleRelativePosition(std::int64_t n) {
   return child_.parent().HandleRelativePosition(n);
 #else
   ReportUnsupportedChildIo();
-  llvm_unreachable("unsupported child io");
 #endif
 }
 
@@ -1094,7 +1086,6 @@ bool ChildFormattedIoStatementState<DIR, CHAR>::AdvanceRecord(int n) {
   return this->child().parent().AdvanceRecord(n);
 #else
   this->ReportUnsupportedChildIo();
-  llvm_unreachable("unsupported child io");
 #endif
 }
 
@@ -1111,7 +1102,6 @@ ChildListIoStatementState<DIR>::ChildListIoStatementState(
   }
 #else
   this->ReportUnsupportedChildIo();
-  llvm_unreachable("unsupported child io");
 #endif
 }
 
@@ -1126,7 +1116,6 @@ bool ChildListIoStatementState<DIR>::AdvanceRecord(int n) {
   }
 #else
   this->ReportUnsupportedChildIo();
-  llvm_unreachable("unsupported child io");
 #endif
 }
 
@@ -1147,7 +1136,6 @@ bool ChildUnformattedIoStatementState<DIR>::Receive(
   return this->child().parent().Receive(data, bytes, elementBytes);
 #else
   this->ReportUnsupportedChildIo();
-  llvm_unreachable("unsupported child io");
 #endif
 }
 



More information about the llvm-commits mailing list