Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flang][NFC] Address reported "possible missing return" #86523

Merged
merged 1 commit into from
Mar 26, 2024

Conversation

klausler
Copy link
Contributor

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 #86391.

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 llvm#86391.
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Mar 25, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Mar 25, 2024

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

Changes

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 #86391.


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

1 Files Affected:

  • (modified) flang/lib/Semantics/tools.cpp (+2)
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");
   }
 }
 

Copy link

✅ With the latest revision this PR passed the Python code formatter.

Copy link

✅ With the latest revision this PR passed the C/C++ code formatter.

@klausler klausler merged commit f92f775 into llvm:main Mar 26, 2024
6 of 7 checks passed
@klausler klausler deleted the bug86391 branch March 26, 2024 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:semantics flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

flang/lib/Semantics/tools.cpp:1290: Possible missing return ?
3 participants