[flang-commits] [flang] [flang] Implement legacy %VAL and %REF actual arguments (PR #70343)
via flang-commits
flang-commits at lists.llvm.org
Fri Oct 27 01:02:16 PDT 2023
================
@@ -3898,32 +3900,52 @@ void ArgumentAnalyzer::Analyze(const parser::Variable &x) {
}
}
fatalErrors_ = true;
+ return std::nullopt;
+}
+
+void ArgumentAnalyzer::Analyze(const parser::Variable &x) {
+ if (auto actual = AnalyzeVariable(x)) {
+ actuals_.emplace_back(std::move(actual));
+ }
}
void ArgumentAnalyzer::Analyze(
const parser::ActualArgSpec &arg, bool isSubroutine) {
// TODO: C1534: Don't allow a "restricted" specific intrinsic to be passed.
std::optional<ActualArgument> actual;
- common::visit(common::visitors{
- [&](const common::Indirection<parser::Expr> &x) {
- actual = AnalyzeExpr(x.value());
- SetArgSourceLocation(actual, x.value().source);
- },
- [&](const parser::AltReturnSpec &label) {
- if (!isSubroutine) {
- context_.Say(
- "alternate return specification may not appear on"
- " function reference"_err_en_US);
- }
- actual = ActualArgument(label.v);
- },
- [&](const parser::ActualArg::PercentRef &) {
- context_.Say("%REF() intrinsic for arguments"_todo_en_US);
- },
- [&](const parser::ActualArg::PercentVal &) {
- context_.Say("%VAL() intrinsic for arguments"_todo_en_US);
- },
- },
+ common::visit(
+ common::visitors{
+ [&](const common::Indirection<parser::Expr> &x) {
+ actual = AnalyzeExpr(x.value());
+ },
+ [&](const parser::AltReturnSpec &label) {
+ if (!isSubroutine) {
+ context_.Say("alternate return specification may not appear on"
+ " function reference"_err_en_US);
+ }
+ actual = ActualArgument(label.v);
+ },
+ [&](const parser::ActualArg::PercentRef &percentRef) {
+ actual = AnalyzeVariable(percentRef.v);
+ if (actual.has_value()) {
+ actual->set_isPercentRef();
+ }
+ },
+ [&](const parser::ActualArg::PercentVal &percentVal) {
+ actual = AnalyzeExpr(percentVal.v);
+ if (actual.has_value()) {
+ actual->set_isPercentVal();
+ std::optional<DynamicType> type{actual->GetType()};
+ if (!type ||
+ !(common::IsNumericTypeCategory(type->category()) ||
----------------
jeanPerier wrote:
Thanks for the pointer, [the one I found ](https://github.com/llvm/llvm-project/blob/1914bcfd3fb4d37b154e9cfeddcec3c04766d1b7/flang/include/flang/Evaluate/type.h#L382) operates on template arguments, so I added an equivalent for DynamicType.
https://github.com/llvm/llvm-project/pull/70343
More information about the flang-commits
mailing list