Author: Peter Steinfeld Date: 2020-12-03T12:08:55-08:00 New Revision: f24c642178a5a31aa1c44585537c08fdfc3fdfd5
URL: https://github.com/llvm/llvm-project/commit/f24c642178a5a31aa1c44585537c08fdfc3fdfd5 DIFF: https://github.com/llvm/llvm-project/commit/f24c642178a5a31aa1c44585537c08fdfc3fdfd5.diff LOG: [flang] Fix bogus message on interface procedure argument names We were keeping the state of parsed equivalence sets in the class DeclarationVisitor. A problem happened when analyzing the the specification part of a declaration that contained an EQUIVALENCE statement followed by an interface block. The same DeclarationVisitor object that was created for the outer declaration was being used to analyze the specification part of a procedure body in the interface block. When analyzing the specification part of the procedure in the interface block, the names in the outer declaration's EQUIVALENCE statement were erroneously compared with the names in the arguments of the interface procedure. This resulted in a bogus error message. I fixed this by not checking equivalence sets when we're in an interface block. I also added a test that will produce an error message without this change. Differential Revision: https://reviews.llvm.org/D92501 Added: Modified: flang/lib/Semantics/resolve-names.cpp flang/test/Semantics/equivalence01.f90 Removed: ################################################################################ diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp index ad5fc734c776..78ce019ec4b8 100644 --- a/flang/lib/Semantics/resolve-names.cpp +++ b/flang/lib/Semantics/resolve-names.cpp @@ -6194,7 +6194,11 @@ void ResolveNamesVisitor::FinishSpecificationPart( // TODO: what about instantiations in BLOCK? CheckSaveStmts(); CheckCommonBlocks(); - CheckEquivalenceSets(); + if (!inInterfaceBlock()) { + // TODO: warn for the case where the EQUIVALENCE statement is in a + // procedure declaration in an interface block + CheckEquivalenceSets(); + } } // Analyze the bodies of statement functions now that the symbols in this diff --git a/flang/test/Semantics/equivalence01.f90 b/flang/test/Semantics/equivalence01.f90 index 404be570d657..234c42744ee9 100644 --- a/flang/test/Semantics/equivalence01.f90 +++ b/flang/test/Semantics/equivalence01.f90 @@ -1,4 +1,4 @@ -! RUN: %S/test_errors.sh %s %t %f18 +!RUN: %S/test_errors.sh %s %t %f18 subroutine s1 integer i, j real r(2) @@ -182,3 +182,18 @@ module s15 !ERROR: 'a(3_8)' and 'a(1_8)' cannot have the same first storage unit equivalence(b(2),a(1)) end module + +subroutine s16 + + integer var, dupName + + ! There should be no error message for the following + equivalence (dupName, var) + + interface + subroutine interfaceSub (dupName) + integer dupName + end subroutine interfaceSub + end interface + +end subroutine s16 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits