1//===- RaggedTest.cpp -- Ragged array runtime function 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/Ragged.h"
10#include "RuntimeCallTestBase.h"
11#include "gtest/gtest.h"
12
13TEST_F(RuntimeCallTest, genRaggedArrayAllocateTest) {
14 auto loc = firBuilder->getUnknownLoc();
15 mlir::TupleType headerTy =
16 fir::factory::getRaggedArrayHeaderType(*firBuilder);
17 mlir::Value header = firBuilder->create<fir::UndefOp>(loc, headerTy);
18 mlir::Value eleSize = firBuilder->createIntegerConstant(loc, i32Ty, 1);
19 mlir::Value extent = firBuilder->createIntegerConstant(loc, i32Ty, 1);
20 // Use a dummy header just to test the correctness of the generated call.
21 fir::runtime::genRaggedArrayAllocate(
22 loc, *firBuilder, header, false, eleSize, {extent});
23 checkCallOpFromResultBox(
24 eleSize, "_FortranARaggedArrayAllocate", 5, /*addLocArgs=*/false);
25}
26
27TEST_F(RuntimeCallTest, genRaggedArrayDeallocateTest) {
28 auto loc = firBuilder->getUnknownLoc();
29 mlir::TupleType headerTy =
30 fir::factory::getRaggedArrayHeaderType(*firBuilder);
31 // Use a dummy header just to test the correctness of the generated call.
32 mlir::Value header = firBuilder->create<fir::UndefOp>(loc, headerTy);
33 fir::runtime::genRaggedArrayDeallocate(loc, *firBuilder, header);
34 checkCallOpFromResultBox(
35 header, "_FortranARaggedArrayDeallocate", 1, /*addLocArgs=*/false);
36}
37

source code of flang/unittests/Optimizer/Builder/Runtime/RaggedTest.cpp