| 1 |
//===- DerivedTest.cpp -- Derived type runtime builder unit tests ---------===// |
| 2 |
// |
| 3 |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 |
// See https://llvm.org/LICENSE.txt for license information. |
| 5 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 |
// |
| 7 |
//===----------------------------------------------------------------------===// |
| 8 |
|
| 9 |
#include "flang/Optimizer/Builder/Runtime/Derived.h" |
| 10 |
#include "RuntimeCallTestBase.h" |
| 11 |
#include "gtest/gtest.h" |
| 12 |
|
| 13 |
TEST_F(RuntimeCallTest, genDerivedTypeInitialize) { |
| 14 |
auto loc = firBuilder->getUnknownLoc(); |
| 15 |
mlir::Type seqTy = |
| 16 |
fir::SequenceType::get(fir::SequenceType::Shape(1, 10), i32Ty); |
| 17 |
mlir::Value box = firBuilder->create<fir::UndefOp>(loc, seqTy); |
| 18 |
fir::runtime::genDerivedTypeInitialize(*firBuilder, loc, box); |
| 19 |
checkCallOpFromResultBox(box, "_FortranAInitialize", 1); |
| 20 |
} |
| 21 |
|
| 22 |
TEST_F(RuntimeCallTest, genDerivedTypeDestroy) { |
| 23 |
auto loc = firBuilder->getUnknownLoc(); |
| 24 |
mlir::Type seqTy = |
| 25 |
fir::SequenceType::get(fir::SequenceType::Shape(1, 10), i32Ty); |
| 26 |
mlir::Value box = firBuilder->create<fir::UndefOp>(loc, seqTy); |
| 27 |
fir::runtime::genDerivedTypeDestroy(*firBuilder, loc, box); |
| 28 |
checkCallOpFromResultBox(box, "_FortranADestroy", 1, /*addLocArg=*/false); |
| 29 |
} |