[flang-commits] [flang] [flang][NFC] Address reported "possible missing return" (PR #86523)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Mon Mar 25 09:07:44 PDT 2024
https://github.com/klausler created https://github.com/llvm/llvm-project/pull/86523
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.
>From e9749f96616b31ddb3031a6bb2aad29ac530599f Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Mon, 25 Mar 2024 09:04:16 -0700
Subject: [PATCH] [flang][NFC] Address reported "possible missing return"
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.
---
flang/lib/Semantics/tools.cpp | 2 ++
1 file changed, 2 insertions(+)
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");
}
}
More information about the flang-commits
mailing list