-
Notifications
You must be signed in to change notification settings - Fork 15k
[flang] Fixed a crash with undeclared variable in implicit-do loop #149513
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When REAL types are constant folded, the underneath implementation uses arrays of integers. Ensure that these arrays are properly aligned. This matters when building flang with clang. In some cases, the resulting code for flang compiler ended up using SSE2 aligned load instructions for REAL(16) constant folding on x86_64, and these instructions require that the values are loaded from the aligned addresses.
|
@llvm/pr-subscribers-flang-semantics Author: Eugene Epshteyn (eugeneepshteyn) ChangesFixed a crash in the following example: The error message was already generated, but the compiler crashed before it could display it. Full diff: https://github.com/llvm/llvm-project/pull/149513.diff 3 Files Affected:
diff --git a/flang/lib/Semantics/check-do-forall.cpp b/flang/lib/Semantics/check-do-forall.cpp
index cc1d4bf58745a..e258df86a4b1c 100644
--- a/flang/lib/Semantics/check-do-forall.cpp
+++ b/flang/lib/Semantics/check-do-forall.cpp
@@ -1180,7 +1180,9 @@ void DoForallChecker::Leave(const parser::IoControlSpec &ioControlSpec) {
void DoForallChecker::Leave(const parser::OutputImpliedDo &outputImpliedDo) {
const auto &control{std::get<parser::IoImpliedDoControl>(outputImpliedDo.t)};
const parser::Name &name{control.name.thing.thing};
- context_.CheckIndexVarRedefine(name.source, *name.symbol);
+ if (name.symbol) {
+ context_.CheckIndexVarRedefine(name.source, *name.symbol);
+ }
}
void DoForallChecker::Leave(const parser::StatVariable &statVariable) {
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index b3268605e7c0c..deafdbd269c78 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -8700,7 +8700,7 @@ const parser::Name *DeclarationVisitor::ResolveName(const parser::Name &name) {
return &name;
}
if (isImplicitNoneType() && !deferImplicitTyping_) {
- Say(name, "No explicit type declared for '%s'"_err_en_US);
+ Say(name, "No explicit type declared for '%s'"_err_en_US, name.source);
return nullptr;
}
// Create the symbol, then ensure that it is accessible
diff --git a/flang/test/Semantics/resolve40.f90 b/flang/test/Semantics/resolve40.f90
index a91507aa62282..81bb5f989ec48 100644
--- a/flang/test/Semantics/resolve40.f90
+++ b/flang/test/Semantics/resolve40.f90
@@ -96,3 +96,10 @@ subroutine s12(x)
!BECAUSE: 'x' is an INTENT(IN) dummy argument
read(*,nml=nl)
end
+
+subroutine s13()
+ implicit none
+ !ERROR: No explicit type declared for 'i'
+ !ERROR: No explicit type declared for 'i'
+ print *, (i, i = 1, 2)
+end
|
klausler
reviewed
Jul 18, 2025
klausler
approved these changes
Jul 18, 2025
This was referenced Jul 23, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixed a crash in the following example:
The error message was already generated, but the compiler crashed before it could display it.