Skip to content

[flang] Fix crash in fuzzer-generated error test. #122199

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
merged 1 commit into from
Jan 14, 2025

Conversation

klausler
Copy link
Contributor

@klausler klausler commented Jan 9, 2025

Fixes #121973.

@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Jan 9, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 9, 2025

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

Changes

Fixes #121973.


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

2 Files Affected:

  • (modified) flang/lib/Semantics/resolve-names.cpp (+3)
  • (added) flang/test/Semantics/bug121973.f90 (+9)
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 724f1b28078356..09355675ff5d55 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -8213,6 +8213,9 @@ bool DeclarationVisitor::CheckForHostAssociatedImplicit(
 }
 
 bool DeclarationVisitor::IsUplevelReference(const Symbol &symbol) {
+  if (symbol.owner().IsTopLevel()) {
+    return false;
+  }
   const Scope &symbolUnit{GetProgramUnitContaining(symbol)};
   if (symbolUnit == GetProgramUnitContaining(currScope())) {
     return false;
diff --git a/flang/test/Semantics/bug121973.f90 b/flang/test/Semantics/bug121973.f90
new file mode 100644
index 00000000000000..0ae04c808e416b
--- /dev/null
+++ b/flang/test/Semantics/bug121973.f90
@@ -0,0 +1,9 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1
+subroutine s()
+  real(8) :: a
+  !ERROR: COMPLEX(KIND=128) is not a supported type
+  complex(128) :: x
+  a(i)=a + ((i)+1) + 3.14
+  !ERROR: 'a' has not been declared as an array or pointer-valued function
+  a()=z(a * a + n-1 - x) + i((/0,0,0,0,0,0,0,0,0,0/)) + 8
+end

@klausler klausler merged commit 6f55c80 into llvm:main Jan 14, 2025
11 checks passed
@klausler klausler deleted the bug121973 branch January 14, 2025 18:41
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] fatal internal error: CHECK(!start.IsTopLevel()) failed at /root/llvm-project/flang/lib/Semantics/tools.cpp(61)
3 participants