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