Skip to content

Commit

Permalink
[flang] Add comments and tests for issue 574 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanPerier committed Aug 21, 2019
1 parent ccb0b48 commit 1bb0e9e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions flang/lib/semantics/expression.cc
Expand Up @@ -1885,6 +1885,8 @@ static void FixMisparsedFunctionReference(
Symbol &symbol{origSymbol->GetUltimate()};
if (symbol.has<semantics::ObjectEntityDetails>() ||
symbol.has<semantics::AssocEntityDetails>()) {
// Note that expression in AssocEntityDetails cannot be a procedure
// pointer as per C1105 so this cannot be a function reference.
if constexpr (common::HasMember<common::Indirection<parser::Designator>,
uType>) {
CheckFuncRefToArrayElementRefHasSubscripts(context, funcRef);
Expand Down
6 changes: 5 additions & 1 deletion flang/lib/semantics/resolve-names.cc
Expand Up @@ -5065,7 +5065,11 @@ void ResolveNamesVisitor::HandleProcedureName(
if (IsProcedure(*symbol) || symbol->has<DerivedTypeDetails>() ||
symbol->has<ObjectEntityDetails>() ||
symbol->has<AssocEntityDetails>()) {
// these are all valid as procedure-designators
// Symbols with DerivedTypeDetails, ObjectEntityDetails and
// AssocEntityDetails are accepted here as procedure-designators because
// this means the related FunctionReference are mis-parsed structure
// constructors or array references that will be fixed later when
// analyzing expressions.
} else if (symbol->test(Symbol::Flag::Implicit)) {
Say(name,
"Use of '%s' as a procedure conflicts with its implicit definition"_err_en_US);
Expand Down
15 changes: 15 additions & 0 deletions flang/test/semantics/resolve39.f90
Expand Up @@ -28,3 +28,18 @@ subroutine s2
associate (a => z'1')
end associate
end

subroutine s3
! Test that associated entities are not preventing to fix
! mis-parsed function references into array references
real :: a(10)
associate (b => a(2:10:2))
! Check no complains about "Use of 'b' as a procedure"
print *, b(1) ! OK
end associate
associate (c => a(2:10:2))
! Check the function reference has been fixed to an array reference
!ERROR: Reference to array 'c' with empty subscript list
print *, c()
end associate
end

0 comments on commit 1bb0e9e

Please sign in to comment.