|
11 | 11 | //
|
12 | 12 | //===----------------------------------------------------------------------===//
|
13 | 13 | #include "CrashHandlerFixture.h"
|
| 14 | +#include "tools.h" |
14 | 15 | #include "../../runtime/terminator.h"
|
15 | 16 | #include "flang/Runtime/io-api.h"
|
| 17 | +#include "flang/Runtime/transformational.h" |
16 | 18 | #include <gtest/gtest.h>
|
17 | 19 |
|
18 | 20 | using namespace Fortran::runtime;
|
19 | 21 | using namespace Fortran::runtime::io;
|
| 22 | +using Fortran::common::TypeCategory; |
20 | 23 |
|
21 | 24 | //------------------------------------------------------------------------------
|
22 | 25 | /// Test crashes through direct calls to terminator methods
|
@@ -155,3 +158,23 @@ TEST(TestIOCrash, OverwriteBufferIntegerTest) {
|
155 | 158 | ASSERT_DEATH(IONAME(OutputInteger64)(cookie, 0xdeadbeef),
|
156 | 159 | "Internal write overran available records");
|
157 | 160 | }
|
| 161 | + |
| 162 | +//------------------------------------------------------------------------------ |
| 163 | +/// Test conformity issue reports in transformational intrinsics |
| 164 | +//------------------------------------------------------------------------------ |
| 165 | +struct TestIntrinsicCrash : CrashHandlerFixture {}; |
| 166 | + |
| 167 | +TEST(TestIntrinsicCrash, ConformityErrors) { |
| 168 | + // ARRAY(2,3) and MASK(2,4) should trigger a runtime error. |
| 169 | + auto array{MakeArray<TypeCategory::Integer, 4>( |
| 170 | + std::vector<int>{2, 3}, std::vector<std::int32_t>{1, 2, 3, 4, 5, 6})}; |
| 171 | + auto mask{MakeArray<TypeCategory::Logical, 1>(std::vector<int>{2, 4}, |
| 172 | + std::vector<std::uint8_t>{ |
| 173 | + false, true, true, false, false, true, true, true})}; |
| 174 | + StaticDescriptor<1, true> statDesc; |
| 175 | + Descriptor &result{statDesc.descriptor()}; |
| 176 | + |
| 177 | + ASSERT_DEATH(RTNAME(Pack)(result, *array, *mask, nullptr, __FILE__, __LINE__), |
| 178 | + "Incompatible array arguments to PACK: dimension 2 of ARRAY= has extent " |
| 179 | + "3 but MASK= has extent 4"); |
| 180 | +} |
0 commit comments