[flang-commits] [flang] fddadd2 - [flang] Address case of under-processed array symbol (#73169)

via flang-commits flang-commits at lists.llvm.org
Thu Nov 30 13:07:56 PST 2023


Author: Peter Klausler
Date: 2023-11-30T13:07:49-08:00
New Revision: fddadd293952ffddd2455f567373424bf8faa003

URL: https://github.com/llvm/llvm-project/commit/fddadd293952ffddd2455f567373424bf8faa003
DIFF: https://github.com/llvm/llvm-project/commit/fddadd293952ffddd2455f567373424bf8faa003.diff

LOG: [flang] Address case of under-processed array symbol (#73169)

Array element references are frequently parsed as function references
due to the ambiguous syntax of Fortran, and the parse tree is repaired
by semantics once the relevant symbol table entries are in hand. This
patch fixes a case in which the correction takes a path that leaves the
type of a symbol undetermined, leading to later spurious errors in
expression analysis.

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

Added: 
    flang/test/Semantics/symbol33.f90

Modified: 
    flang/lib/Semantics/resolve-names.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 0f69c1ccd285040..5e2a9be41b90ffd 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -7731,7 +7731,6 @@ void ResolveNamesVisitor::HandleProcedureName(
   } else if (CheckUseError(name)) {
     // error was reported
   } else {
-    auto &nonUltimateSymbol{*symbol};
     symbol = &Resolve(name, symbol)->GetUltimate();
     CheckEntryDummyUse(name.source, symbol);
     bool convertedToProcEntity{ConvertToProcEntity(*symbol)};
@@ -7756,9 +7755,7 @@ void ResolveNamesVisitor::HandleProcedureName(
       // is created for the current scope.
       // Operate on non ultimate symbol so that HostAssocDetails are also
       // created for symbols used associated in the host procedure.
-      if (IsUplevelReference(nonUltimateSymbol)) {
-        MakeHostAssocSymbol(name, nonUltimateSymbol);
-      }
+      ResolveName(name);
     } else if (symbol->test(Symbol::Flag::Implicit)) {
       Say(name,
           "Use of '%s' as a procedure conflicts with its implicit definition"_err_en_US);

diff  --git a/flang/test/Semantics/symbol33.f90 b/flang/test/Semantics/symbol33.f90
new file mode 100644
index 000000000000000..fbb5321b8854dfd
--- /dev/null
+++ b/flang/test/Semantics/symbol33.f90
@@ -0,0 +1,11 @@
+! RUN: %python %S/test_symbols.py %s %flang_fc1
+! Ensure that a misparsed function reference that turns out to be an
+! array element reference still applies implicit typing, &c.
+!DEF: /subr (Subroutine) Subprogram
+subroutine subr
+  !DEF: /subr/moo (Implicit) ObjectEntity INTEGER(4)
+  common //moo(1)
+  !DEF: /subr/a ObjectEntity REAL(4)
+  !REF: /subr/moo
+  real a(moo(1))
+end subroutine


        


More information about the flang-commits mailing list