Skip to content

Commit 15c9376

Browse files
authored
[flang] Fix characterization of result of function returning procedur… (#66248)
…e pointer The procedure characterization package correctly characterizes the result of a reference to a function that returns a procedure pointer. In the event of a result that is a pointer to a function that itself is a procedure pointer, the code in pointer assignment semantics checking was mistakenly using that result's procedure characteristics as the characteristics of the original function reference. This is just wrong; delete it.
1 parent 1609a87 commit 15c9376

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

flang/include/flang/Common/enum-class.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// enum class className { enum1, enum2, ... , enumN };
1313
// as well as the introspective utilities
1414
// static constexpr std::size_t className_enumSize{N};
15-
// static inline const std::string_view EnumToString(className);
15+
// static inline std::string_view EnumToString(className);
1616

1717
#ifndef FORTRAN_COMMON_ENUM_CLASS_H_
1818
#define FORTRAN_COMMON_ENUM_CLASS_H_

flang/lib/Semantics/pointer-assignment.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "definable.h"
1111
#include "flang/Common/idioms.h"
1212
#include "flang/Common/restorer.h"
13+
#include "flang/Common/template.h"
1314
#include "flang/Evaluate/characteristics.h"
1415
#include "flang/Evaluate/expression.h"
1516
#include "flang/Evaluate/fold.h"
@@ -397,16 +398,8 @@ bool PointerAssignmentChecker::Check(const evaluate::ProcedureDesignator &d) {
397398
}
398399

399400
bool PointerAssignmentChecker::Check(const evaluate::ProcedureRef &ref) {
400-
if (auto chars{Procedure::Characterize(ref, foldingContext_)}) {
401-
if (chars->functionResult) {
402-
if (const auto *proc{chars->functionResult->IsProcedurePointer()}) {
403-
return Check(ref.proc().GetName(), true, proc);
404-
}
405-
}
406-
return Check(ref.proc().GetName(), true, &*chars);
407-
} else {
408-
return Check(ref.proc().GetName(), true, nullptr);
409-
}
401+
auto chars{Procedure::Characterize(ref, foldingContext_)};
402+
return Check(ref.proc().GetName(), true, common::GetPtrFromOptional(chars));
410403
}
411404

412405
// The target can be unlimited polymorphic if the pointer is, or if it is

0 commit comments

Comments
 (0)