[flang-commits] [flang] [flang][NFC] Address reported "possible missing return" (PR #86523)

via flang-commits flang-commits at lists.llvm.org
Mon Mar 25 09:08:17 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

<details>
<summary>Changes</summary>

A function uses "if constexpr" to consider all possible types in a variant, but looks as if it can fall out without returning an expression.  Add a final "else" with a crash to make things more clear and to protect against unlikely future extensions of the type.

Fixes https://github.com/llvm/llvm-project/issues/86391.

---
Full diff: https://github.com/llvm/llvm-project/pull/86523.diff


1 Files Affected:

- (modified) flang/lib/Semantics/tools.cpp (+2) 


``````````diff
diff --git a/flang/lib/Semantics/tools.cpp b/flang/lib/Semantics/tools.cpp
index 0484baae93cd59..abdd83ac415684 100644
--- a/flang/lib/Semantics/tools.cpp
+++ b/flang/lib/Semantics/tools.cpp
@@ -1275,6 +1275,8 @@ static bool StopAtComponentPre(const Symbol &component) {
     return !IsPointer(component);
   } else if constexpr (componentKind == ComponentKind::PotentialAndPointer) {
     return true;
+  } else {
+    DIE("unexpected ComponentKind");
   }
 }
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/86523


More information about the flang-commits mailing list