-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[FLANG] Solving issue with adjustr intrinsic in where construct #146851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 5 commits
8768516
ed8f048
ae2f94c
4f86344
9cb61ce
306af24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -445,8 +445,16 @@ struct AssociateOpConversion | |
| !mlir::isa<fir::BaseBoxType>(assocType)) || | ||
| ((mlir::isa<fir::BoxCharType>(sourceVar.getType()) && | ||
| !mlir::isa<fir::BoxCharType>(assocType)))) { | ||
| sourceVar = | ||
| fir::BoxAddrOp::create(builder, loc, assocType, sourceVar); | ||
| sourceVar = builder.create<fir::BoxAddrOp>(loc, assocType, sourceVar); | ||
| } else if (mlir::isa<fir::ReferenceType>(sourceVar.getType()) && | ||
| mlir::isa<fir::BoxCharType>(assocType)) { | ||
| mlir::Value lenVal = associate.getTypeparams()[0]; | ||
| auto refTy = mlir::cast<fir::ReferenceType>(sourceVar.getType()); | ||
| auto charTy = mlir::dyn_cast<fir::CharacterType>(refTy.getEleTy()); | ||
|
||
| auto boxCharType = | ||
| fir::BoxCharType::get(builder.getContext(), charTy.getFKind()); | ||
| sourceVar = builder.create<fir::EmboxCharOp>(loc, boxCharType, | ||
| sourceVar, lenVal); | ||
| } else { | ||
| sourceVar = builder.createConvert(loc, assocType, sourceVar); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| ! RUN: %flang_fc1 -emit-fir -o - %s | FileCheck %s | ||
|
|
||
| ! Checking no reference to boxchar conversion is in the emitted fir. | ||
| ! CHECK-NOT: (!fir.ref<!fir.char<1,4>>) -> !fir.boxchar<1> | ||
|
||
| ! CHECK: %[[Const4:.*]] = arith.constant 4 : index | ||
| ! CHECK: fir.emboxchar | ||
|
|
||
| program main | ||
| logical ,dimension(1):: mask = .true. | ||
| character(len=2),dimension(1):: d1 = "a " | ||
| character(len=4),dimension(1):: d4 | ||
| where (mask) | ||
| d4 = adjustr(d1 // d1) | ||
| end where | ||
| write(6,*) "d4 =", d4 | ||
| end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: please assert that
getTypeparams()returns a vector of length one.