@@ -1855,7 +1855,8 @@ class ScalarExprLowering {
1855
1855
// Helper for changing the semantics in a given context. Preserves the current
1856
1856
// semantics which is resumed when the "push" goes out of scope.
1857
1857
#define PushSemantics (PushVal ) \
1858
- [[maybe_unused]] PushSemant pushSemanticsLocalVariable97201 (PushVal, semant);
1858
+ [[maybe_unused]] auto pushSemanticsLocalVariable97201 = \
1859
+ Fortran::common::ScopedSet (semant, PushVal);
1859
1860
1860
1861
namespace {
1861
1862
class ArrayExprLowering {
@@ -2074,7 +2075,7 @@ class ArrayExprLowering {
2074
2075
}
2075
2076
2076
2077
// A procedure reference to a Fortran elemental intrinsic procedure.
2077
- CC genIntrinsicProcRef (
2078
+ CC genElementalIntrinsicProcRef (
2078
2079
const Fortran::evaluate::ProcedureRef &procRef,
2079
2080
llvm::Optional<mlir::Type> retTy,
2080
2081
const Fortran::evaluate::SpecificIntrinsic &intrinsic) {
@@ -2129,8 +2130,9 @@ class ArrayExprLowering {
2129
2130
}
2130
2131
2131
2132
// A procedure reference to a user-defined elemental procedure.
2132
- CC genUDProcRef (const Fortran::evaluate::ProcedureRef &procRef,
2133
- llvm::Optional<mlir::Type> retTy) {
2133
+ CC genElementalUserDefinedProcRef (
2134
+ const Fortran::evaluate::ProcedureRef &procRef,
2135
+ llvm::Optional<mlir::Type> retTy) {
2134
2136
using PassBy = Fortran::lower::CallerInterface::PassEntityBy;
2135
2137
2136
2138
Fortran::lower::CallerInterface caller (procRef, converter);
@@ -2162,7 +2164,7 @@ class ArrayExprLowering {
2162
2164
return lambda (iters);
2163
2165
};
2164
2166
} break ;
2165
- case PassBy::ValueAttribute : {
2167
+ case PassBy::BaseAddressValueAttribute : {
2166
2168
// VALUE attribute or pass-by-reference to a copy semantics. (byval*)
2167
2169
PushSemantics (ConstituentSemantics::ByValueArg);
2168
2170
auto lambda = genarr (*expr);
@@ -2177,8 +2179,11 @@ class ArrayExprLowering {
2177
2179
return lambda (iters);
2178
2180
};
2179
2181
} break ;
2182
+ case PassBy::CharBoxValueAttribute:
2183
+ TODO (loc, " CHARACTER, VALUE" );
2184
+ break ;
2180
2185
case PassBy::BoxChar:
2181
- TODO (loc, " character " );
2186
+ TODO (loc, " CHARACTER " );
2182
2187
break ;
2183
2188
case PassBy::AddressAndLength:
2184
2189
TODO (loc, " address and length argument" );
@@ -2188,18 +2193,18 @@ class ArrayExprLowering {
2188
2193
// See C15100 and C15101
2189
2194
fir::emitFatalError (loc, " cannot be POINTER, ALLOCATABLE" );
2190
2195
default :
2191
- llvm_unreachable (" pass by value not handled here" );
2196
+ llvm_unreachable (" pass by ? not handled here" );
2192
2197
break ;
2193
2198
}
2194
2199
}
2195
2200
2196
2201
if (caller.getIfIndirectCallSymbol ())
2197
- TODO (loc, " indirect call" );
2202
+ fir::emitFatalError (loc, " cannot be indirect call" );
2198
2203
auto funcSym = builder.getSymbolRefAttr (caller.getMangledName ());
2199
2204
auto resTys = caller.getFuncOp ().getType ().getResults ();
2200
2205
if (caller.getFuncOp ().getType ().getResults () !=
2201
2206
caller.genFunctionType ().getResults ())
2202
- TODO (loc, " type adaption " );
2207
+ fir::emitFatalError (loc, " type mismatch on declared function " );
2203
2208
return [=](IterSpace iters) -> ExtValue {
2204
2209
llvm::SmallVector<mlir::Value> args;
2205
2210
for (const auto &cc : operands)
@@ -2217,14 +2222,14 @@ class ArrayExprLowering {
2217
2222
if (const auto *intrin = procRef.proc ().GetSpecificIntrinsic ()) {
2218
2223
// Elemental intrinsic call.
2219
2224
// The intrinsic procedure is called once per element of the array.
2220
- return genIntrinsicProcRef (procRef, retTy, *intrin);
2225
+ return genElementalIntrinsicProcRef (procRef, retTy, *intrin);
2221
2226
}
2222
2227
if (ScalarExprLowering::isStatementFunctionCall (procRef))
2223
2228
fir::emitFatalError (loc, " statement function cannot be elemental" );
2224
2229
2225
2230
// Elemental call.
2226
2231
// The procedure is called once per element of the array argument(s).
2227
- return genUDProcRef (procRef, retTy);
2232
+ return genElementalUserDefinedProcRef (procRef, retTy);
2228
2233
}
2229
2234
2230
2235
// Transformational call.
@@ -2696,14 +2701,12 @@ class ArrayExprLowering {
2696
2701
return [=](IterSpace iters) -> ExtValue {
2697
2702
auto arrFetch = builder.create <fir::ArrayFetchOp>(loc, eleTy, arrLd,
2698
2703
iters.iterVec ());
2699
- auto exv =
2700
- arrayElementToExtendedValue (builder, loc, extMemref, arrFetch);
2701
- auto base = fir::getBase (exv);
2704
+ auto base = arrFetch.getResult ();
2702
2705
auto temp = builder.createTemporary (
2703
2706
loc, base.getType (),
2704
2707
llvm::ArrayRef<mlir::NamedAttribute>{getAdaptToByRefAttr ()});
2705
2708
builder.create <fir::StoreOp>(loc, base, temp);
2706
- return temp;
2709
+ return arrayElementToExtendedValue (builder, loc, extMemref, temp) ;
2707
2710
};
2708
2711
return [=](IterSpace iters) -> ExtValue {
2709
2712
auto arrFetch =
@@ -2968,17 +2971,6 @@ class ArrayExprLowering {
2968
2971
}
2969
2972
2970
2973
private:
2971
- struct PushSemant {
2972
- PushSemant (ConstituentSemantics newVal, ConstituentSemantics &oldVal)
2973
- : ref{oldVal} {
2974
- saved = oldVal;
2975
- oldVal = newVal;
2976
- }
2977
- ~PushSemant () { ref = saved; }
2978
- ConstituentSemantics saved;
2979
- ConstituentSemantics &ref;
2980
- };
2981
-
2982
2974
explicit ArrayExprLowering (Fortran::lower::AbstractConverter &converter,
2983
2975
Fortran::lower::StatementContext &stmtCtx,
2984
2976
Fortran::lower::SymMap &symMap,
0 commit comments