73 changes: 0 additions & 73 deletions flang-rt/test/CMakeLists.txt

This file was deleted.

38 changes: 0 additions & 38 deletions flang-rt/test/FortranRuntime/no-cpp-dep.c

This file was deleted.

22 changes: 0 additions & 22 deletions flang-rt/test/NonGtestUnit/lit.cfg.py

This file was deleted.

23 changes: 0 additions & 23 deletions flang-rt/test/NonGtestUnit/lit.site.cfg.py.in

This file was deleted.

58 changes: 0 additions & 58 deletions flang-rt/test/Unit/lit.cfg.py

This file was deleted.

22 changes: 0 additions & 22 deletions flang-rt/test/Unit/lit.site.cfg.py.in

This file was deleted.

173 changes: 0 additions & 173 deletions flang-rt/test/lit.cfg.py

This file was deleted.

31 changes: 0 additions & 31 deletions flang-rt/test/lit.site.cfg.py.in

This file was deleted.

81 changes: 0 additions & 81 deletions flang-rt/unittests/CMakeLists.txt

This file was deleted.

21 changes: 0 additions & 21 deletions flang-rt/unittests/FortranEvaluate/CMakeLists.txt

This file was deleted.

128 changes: 0 additions & 128 deletions flang-rt/unittests/FortranEvaluate/testing.cpp

This file was deleted.

37 changes: 0 additions & 37 deletions flang-rt/unittests/FortranEvaluate/testing.h

This file was deleted.

8 changes: 2 additions & 6 deletions flang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ if (FLANG_STANDALONE_BUILD)
if (FLANG_GTEST_AVAIL)
add_custom_target(check-all DEPENDS check-flang FlangUnitTests)
else()
add_custom_target(check-all DEPENDS check-flang)
add_custom_target(check-all DEPENDS check-flang )
endif()
if (LLVM_BUILD_DOCS)
add_custom_target(doxygen ALL)
Expand Down Expand Up @@ -421,11 +421,6 @@ if (FLANG_INCLUDE_TESTS)
add_compile_definitions(FLANG_INCLUDE_TESTS=1)
endif()

# Add Flang subdirectories.
# NOTE: The runtime subdirectory is no longer added here.
# Sources for the runtime are added in Flang-rt.
# TODO: Move the runtime sources to the flang-rt top level directory.

add_subdirectory(include)
add_subdirectory(lib)
add_subdirectory(cmake/modules)
Expand All @@ -435,6 +430,7 @@ option(FLANG_BUILD_TOOLS
if (FLANG_BUILD_TOOLS)
add_subdirectory(tools)
endif()
add_subdirectory(runtime)

if (LLVM_INCLUDE_EXAMPLES)
add_subdirectory(examples)
Expand Down
5 changes: 1 addition & 4 deletions flang/cmake/modules/AddFlang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ macro(add_flang_subdirectory name)
endmacro()

function(add_flang_library name)
set(options SHARED STATIC INSTALL_WITH_TOOLCHAIN PIC)
set(options SHARED STATIC INSTALL_WITH_TOOLCHAIN)
set(multiValueArgs ADDITIONAL_HEADERS CLANG_LIBS)
cmake_parse_arguments(ARG
"${options}"
Expand Down Expand Up @@ -65,9 +65,6 @@ function(add_flang_library name)
endif()

llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
if (ARG_PIC)
set_target_properties(${name} PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()

clang_target_link_libraries(${name} PRIVATE ${ARG_CLANG_LIBS})

Expand Down
2 changes: 0 additions & 2 deletions flang/cmake/modules/FlangConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ find_package(LLVM ${LLVM_VERSION} EXACT REQUIRED CONFIG
set(FLANG_EXPORTED_TARGETS "@FLANG_EXPORTS@")
set(FLANG_CMAKE_DIR "@FLANG_CONFIG_CMAKE_DIR@")
set(FLANG_INCLUDE_DIRS "@FLANG_CONFIG_INCLUDE_DIRS@")
set(FLANG_SOURCE_DIR "@FLANG_SOURCE_DIR@")
set(FLANG_BINARY_DIR "@FLANG_BINARY_DIR@")

# Provide all our library targets to users.
@FLANG_CONFIG_INCLUDE_EXPORTS@
20 changes: 4 additions & 16 deletions flang/lib/Decimal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,7 @@ endif()
# avoid an unwanted dependency on libstdc++.so.
add_definitions(-U_GLIBCXX_ASSERTIONS)

# Build FortranDecimal when the build target is Flang or LLVM.
if (CMAKE_SOURCE_DIR STREQUAL FLANG_SOURCE_DIR OR CMAKE_SOURCE_DIR STREQUAL LLVM_MAIN_SRC_DIR)
add_flang_library(FortranDecimal
binary-to-decimal.cpp
decimal-to-binary.cpp
)
# Build FortranDecimalRT for FlangRT when the build target is Runtimes.
# Standalone builds of FlangRT is not supported.
elseif (CMAKE_SOURCE_DIR STREQUAL Runtimes_SOURCE_DIR)
add_flang_library(FortranDecimalRT STATIC INSTALL_WITH_TOOLCHAIN PIC
binary-to-decimal.cpp
decimal-to-binary.cpp
)
else()
message(FATAL_ERROR "CMAKE_SOURCE_DIR of target points to neither Flang or Flang-rt, no library added for FortranDecimal.")
endif()
add_flang_library(FortranDecimal INSTALL_WITH_TOOLCHAIN
binary-to-decimal.cpp
decimal-to-binary.cpp
)
15 changes: 5 additions & 10 deletions flang/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@
#
#===------------------------------------------------------------------------===#

# TODO: Maybe this file should still be added by flang/CMakeLists.txt and
# when FLANG_STANDALONE_BUILD=On and a new variable FLANG_BUILD_RUNTIME=On
# we should invoke an ExternalProject_Add(flang-rt ...) from here?

if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
cmake_minimum_required(VERSION 3.20.0)

project(FortranRuntime C CXX)
project(FlangRuntime C CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
Expand Down Expand Up @@ -86,6 +82,8 @@ append(${NO_LTO_FLAGS} CMAKE_CXX_FLAGS)
add_definitions(-U_GLIBCXX_ASSERTIONS)
add_definitions(-U_LIBCPP_ENABLE_ASSERTIONS)

add_subdirectory(FortranMain)

set(sources
ISO_Fortran_binding.cpp
allocatable.cpp
Expand Down Expand Up @@ -270,13 +268,10 @@ if (NOT FLANG_EXPERIMENTAL_OMP_OFFLOAD_BUILD STREQUAL "off")
endif()
endif()

add_compile_options(-fPIC)

add_flang_library(FortranRuntime STATIC
add_flang_library(FortranRuntime
${sources}
LINK_LIBS
FortranDecimalRT
FortranDecimal

INSTALL_WITH_TOOLCHAIN
PIC
)
7 changes: 1 addition & 6 deletions flang/runtime/sum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,10 @@ CppTypeFor<TypeCategory::Real, 10> RTNAME(SumReal10)(const Descriptor &x,
}
#endif
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
#if HAS_FLOAT128
using AccumType = __float128;
#else // if LDBL_MANT_DIG == 113
using AccumType = long double;
#endif
CppTypeFor<TypeCategory::Real, 16> RTNAME(SumReal16)(const Descriptor &x,
const char *source, int line, int dim, const Descriptor *mask) {
return GetTotalReduction<TypeCategory::Real, 16>(
x, source, line, dim, mask, RealSumAccumulator<AccumType>{x}, "SUM");
x, source, line, dim, mask, RealSumAccumulator<long double>{x}, "SUM");
}
#endif

Expand Down
3 changes: 3 additions & 0 deletions flang/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ set(FLANG_TEST_DEPENDS
llvm-objdump
llvm-readobj
split-file
FortranRuntime
Fortran_main
FortranDecimal
)
if (LLVM_ENABLE_PLUGINS AND NOT WIN32)
list(APPEND FLANG_TEST_DEPENDS Bye)
Expand Down
12 changes: 8 additions & 4 deletions flang/test/Driver/linker-flags.f90
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,29 @@
! GNU-LABEL: "{{.*}}ld{{(\.exe)?}}"
! GNU-SAME: "[[object_file]]"
! GNU-SAME: -lFortran_main
! GNU-SAME: -lflang-rt
! GNU-SAME: -lFortranRuntime
! GNU-SAME: -lFortranDecimal
! GNU-SAME: -lm

! DARWIN-LABEL: "{{.*}}ld{{(\.exe)?}}"
! DARWIN-SAME: "[[object_file]]"
! DARWIN-SAME: -lFortran_main
! DARWIN-SAME: -lflang-rt
! DARWIN-SAME: -lFortranRuntime
! DARWIN-SAME: -lFortranDecimal

! MINGW-LABEL: "{{.*}}ld{{(\.exe)?}}"
! MINGW-SAME: "[[object_file]]"
! MINGW-SAME: -lFortran_main
! MINGW-SAME: -lflang-rt
! MINGW-SAME: -lFortranRuntime
! MINGW-SAME: -lFortranDecimal

! NOTE: This also matches lld-link (when CLANG_DEFAULT_LINKER=lld) and
! any .exe suffix that is added when resolving to the full path of
! (lld-)link.exe on Windows platforms. The suffix may not be added
! when the executable is not found or on non-Windows platforms.
! MSVC-LABEL: link
! MSVC-SAME: Fortran_main.lib
! MSVC-SAME: flang-rt.lib
! MSVC-SAME: FortranRuntime.lib
! MSVC-SAME: FortranDecimal.lib
! MSVC-SAME: /subsystem:console
! MSVC-SAME: "[[object_file]]"
5 changes: 4 additions & 1 deletion flang/test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,19 @@
# the C++ runtime libraries. For this we need a C compiler. If for some reason
# we don't have one, we can just disable the test.
if config.cc:
libruntime = os.path.join(config.flang_lib_dir, "libflang-rt.a")
libruntime = os.path.join(config.flang_lib_dir, "libFortranRuntime.a")
libdecimal = os.path.join(config.flang_lib_dir, "libFortranDecimal.a")
include = os.path.join(config.flang_src_dir, "include")

if (
os.path.isfile(libruntime)
and os.path.isfile(libdecimal)
and os.path.isdir(include)
):
config.available_features.add("c-compiler")
tools.append(ToolSubst("%cc", command=config.cc, unresolved="fatal"))
tools.append(ToolSubst("%libruntime", command=libruntime, unresolved="fatal"))
tools.append(ToolSubst("%libdecimal", command=libdecimal, unresolved="fatal"))
tools.append(ToolSubst("%include", command=include, unresolved="fatal"))

# Add all the tools and their substitutions (if applicable). Use the search paths provided for
Expand Down
8 changes: 8 additions & 0 deletions flang/tools/flang-driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ set( LLVM_LINK_COMPONENTS
add_flang_tool(flang-new
driver.cpp
fc1_main.cpp

DEPENDS
# These libraries are used in the linker invocation generated by the driver
# (i.e. when constructing the linker job). Without them the driver would be
# unable to generate executables.
FortranRuntime
FortranDecimal
Fortran_main
)

target_link_libraries(flang-new
Expand Down
11 changes: 4 additions & 7 deletions flang/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,11 @@ function(add_flang_unittest_offload_properties target)
# FIXME: replace 'native' in --offload-arch option with the list
# of targets that Fortran Runtime was built for.
# Common code must be moved from flang/runtime/CMakeLists.txt.
# TODO: Revisit this because of Flang-rt. runtime is no longer an added subdirectory of flang. So we temporarily duplicated the option definition to here. This is not a permanent solution.
set(FLANG_EXPERIMENTAL_OMP_OFFLOAD_BUILD "off" CACHE STRING
"Compile Fortran runtime as OpenMP target offload sources (experimental). Valid options are 'off', 'host_device', 'nohost'")

if (NOT FLANG_EXPERIMENTAL_OMP_OFFLOAD_BUILD STREQUAL "off")
set_target_properties(${target}
PROPERTIES LINK_OPTIONS
"-fopenmp;--offload-arch=native"
)
PROPERTIES LINK_OPTIONS
"-fopenmp;--offload-arch=native"
)
endif()
endfunction()

Expand Down Expand Up @@ -78,4 +74,5 @@ add_subdirectory(Optimizer)
add_subdirectory(Common)
add_subdirectory(Decimal)
add_subdirectory(Evaluate)
add_subdirectory(Runtime)
add_subdirectory(Frontend)
15 changes: 15 additions & 0 deletions flang/unittests/Evaluate/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ add_flang_nongtest_unittest(intrinsics
FortranDecimal
FortranSemantics
FortranParser
FortranRuntime
)

add_flang_nongtest_unittest(logical
Expand All @@ -67,6 +68,20 @@ add_flang_nongtest_unittest(real
)
llvm_update_compile_flags(real.test)

add_flang_nongtest_unittest(reshape
FortranEvaluateTesting
FortranSemantics
FortranEvaluate
FortranRuntime
)

add_flang_nongtest_unittest(ISO-Fortran-binding
FortranEvaluateTesting
FortranEvaluate
FortranSemantics
FortranRuntime
)

add_flang_nongtest_unittest(folding
FortranCommon
FortranEvaluateTesting
Expand Down
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions flang/unittests/Optimizer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ add_flang_unittest(FlangOptimizerTests
Builder/DoLoopHelperTest.cpp
Builder/FIRBuilderTest.cpp
Builder/HLFIRToolsTest.cpp
Builder/Runtime/AllocatableTest.cpp
Builder/Runtime/AssignTest.cpp
Builder/Runtime/CommandTest.cpp
Builder/Runtime/CharacterTest.cpp
Builder/Runtime/DerivedTest.cpp
Builder/Runtime/NumericTest.cpp
Builder/Runtime/RaggedTest.cpp
Builder/Runtime/ReductionTest.cpp
Builder/Runtime/StopTest.cpp
Builder/Runtime/TransformationalTest.cpp
FIRContextTest.cpp
FIRTypesTest.cpp
FortranVariableTest.cpp
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//

#include "flang/../../runtime/buffer.h"
#include "../../runtime/buffer.h"
#include "CrashHandlerFixture.h"
#include "gtest/gtest.h"
#include <algorithm>
Expand All @@ -30,31 +30,30 @@ class Store : public FileFrame<Store, tinyBufferSize> {
void set_expect(FileOffset to) { expect_ = to; }

std::size_t Read(FileOffset at, char *to, std::size_t minBytes,
std::size_t maxBytes, IoErrorHandler &handler) {
std::size_t maxBytes, IoErrorHandler &handler) {
if (enforceSequence_ && at != expect_) {
handler.SignalError("Read(%d,%d,%d) not at expected %d",
static_cast<int>(at), static_cast<int>(minBytes),
static_cast<int>(maxBytes),
static_cast<int>(expect_));
static_cast<int>(at), static_cast<int>(minBytes),
static_cast<int>(maxBytes), static_cast<int>(expect_));
} else if (at < 0 || at + minBytes > bytes_) {
handler.SignalError("Read(%d,%d,%d) is out of bounds",
static_cast<int>(at), static_cast<int>(minBytes),
static_cast<int>(maxBytes));
static_cast<int>(at), static_cast<int>(minBytes),
static_cast<int>(maxBytes));
}
auto result{std::min<std::size_t>(maxBytes, bytes_ - at)};
std::memcpy(to, &data_[at], result);
expect_ = at + result;
return result;
}
std::size_t Write(FileOffset at, const char *from, std::size_t bytes,
IoErrorHandler &handler) {
IoErrorHandler &handler) {
if (enforceSequence_ && at != expect_) {
handler.SignalError("Write(%d,%d) not at expected %d",
static_cast<int>(at), static_cast<int>(bytes),
static_cast<int>(expect_));
static_cast<int>(at), static_cast<int>(bytes),
static_cast<int>(expect_));
} else if (at < 0 || at + bytes > bytes_) {
handler.SignalError("Write(%d,%d) is out of bounds", static_cast<int>(at),
static_cast<int>(bytes));
static_cast<int>(bytes));
}
std::memcpy(&data_[at], from, bytes);
expect_ = at + bytes;
Expand All @@ -71,8 +70,8 @@ class Store : public FileFrame<Store, tinyBufferSize> {
inline int ChunkSize(int j, int most) {
// 31, 1, 29, 3, 27, ...
j %= tinyBufferSize;
auto chunk{static_cast<int>(((j % 2) ? j : (tinyBufferSize - 1 - j)) %
tinyBufferSize)};
auto chunk{static_cast<int>(
((j % 2) ? j : (tinyBufferSize - 1 - j)) % tinyBufferSize)};
return std::min(chunk, most);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_flang_rt_unittest(FortranRuntimeTests
add_flang_unittest(FlangRuntimeTests
Allocatable.cpp
ArrayConstructor.cpp
BufferTest.cpp
Expand Down Expand Up @@ -29,7 +29,7 @@ add_flang_rt_unittest(FortranRuntimeTests
Transformational.cpp
)

target_link_libraries(FortranRuntimeTests
target_link_libraries(FlangRuntimeTests
PRIVATE
flang-rt
FortranRuntime
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
#include "flang/../../runtime/terminator.h"
#include "../../runtime/terminator.h"
#include <cstdarg>
#include <cstdlib>

// Replaces Fortran runtime's crash handler so we can verify the crash message
[[noreturn]] static void CatchCrash(const char *sourceFile, int sourceLine,
const char *message, va_list &ap) {
[[noreturn]] static void CatchCrash(
const char *sourceFile, int sourceLine, const char *message, va_list &ap) {
char buffer[1000];
std::vsnprintf(buffer, sizeof buffer, message, ap);
va_end(ap);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//

#include "CrashHandlerFixture.h"
#include "flang/../../runtime/io-error.h"
#include "../../runtime/io-error.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/io-api.h"

Expand Down Expand Up @@ -36,15 +36,15 @@ TEST(InputTest, TestListInputAlphabet) {
// Use _two_ input buffers and _three_ output buffers. Note the `3*` in the
// _inputBuffers_.
SetCharacter(inputBuffers[j++], maxInputBufferLength,
"3*'abcdefghijklmnopqrstuvwxyzABC");
SetCharacter(inputBuffers[j++], maxInputBufferLength,
"DEFGHIJKLMNOPQRSTUVWXYZ'");
"3*'abcdefghijklmnopqrstuvwxyzABC");
SetCharacter(
inputBuffers[j++], maxInputBufferLength, "DEFGHIJKLMNOPQRSTUVWXYZ'");

StaticDescriptor<1> staticDescriptor;
Descriptor &whole{staticDescriptor.descriptor()};
SubscriptValue extent[]{numInputBuffers};
whole.Establish(TypeCode{CFI_type_char}, maxInputBufferLength, &inputBuffers,
1, extent, CFI_attribute_pointer);
1, extent, CFI_attribute_pointer);
whole.Check();
auto *cookie{IONAME(BeginInternalArrayListInput)(whole)};

Expand Down Expand Up @@ -79,7 +79,7 @@ TEST(InputTest, TestListInputIntegerList) {
Descriptor &whole{staticDescriptor.descriptor()};
SubscriptValue extent[]{numBuffers};
whole.Establish(TypeCode{CFI_type_char}, maxBufferLength, &buffer, 1, extent,
CFI_attribute_pointer);
CFI_attribute_pointer);
whole.Check();
auto *cookie{IONAME(BeginInternalArrayListInput)(whole)};

Expand All @@ -88,10 +88,10 @@ TEST(InputTest, TestListInputIntegerList) {
// Negative numbers will be overwritten by _expectedOutput_, and positive
// numbers will not be as their indices are "Null values" of the Fortran 2018
// standard 13.10.3.2 in the format strings _buffer_
std::int64_t actualOutput[listInputLength]{-1, -2, -3, -4, 5,
-6, 7, -8, 9, 10};
const std::int64_t expectedOutput[listInputLength]{1, 2, 3, 3, 5,
6, 7, 8, 9, 10};
std::int64_t actualOutput[listInputLength]{
-1, -2, -3, -4, 5, -6, 7, -8, 9, 10};
const std::int64_t expectedOutput[listInputLength]{
1, 2, 3, 3, 5, 6, 7, 8, 9, 10};
for (j = 0; j < listInputLength; ++j) {
IONAME(InputInteger)(cookie, actualOutput[j]);
}
Expand All @@ -116,7 +116,7 @@ TEST(InputTest, TestListInputInvalidFormatWithSingleSuccess) {
Descriptor &whole{staticDescriptor.descriptor()};
SubscriptValue extent[]{numBuffers};
whole.Establish(TypeCode{CFI_type_char}, formatBuffer.size(),
formatBuffer.data(), 1, extent, CFI_attribute_pointer);
formatBuffer.data(), 1, extent, CFI_attribute_pointer);
whole.Check();

auto *cookie{IONAME(BeginInternalArrayListInput)(whole)};
Expand All @@ -127,7 +127,7 @@ TEST(InputTest, TestListInputInvalidFormatWithSingleSuccess) {

// Perform failing InputInteger
ASSERT_DEATH(IONAME(InputInteger)(cookie, dummy),
"Bad character 'g' in INTEGER input field");
"Bad character 'g' in INTEGER input field");
}

// Same test as _TestListInputInvalidFormatWithSingleSuccess_, however no
Expand All @@ -140,15 +140,15 @@ TEST(InputTest, TestListInputInvalidFormat) {
Descriptor &whole{staticDescriptor.descriptor()};
SubscriptValue extent[]{numBuffers};
whole.Establish(TypeCode{CFI_type_char}, formatBuffer.size(),
formatBuffer.data(), 1, extent, CFI_attribute_pointer);
formatBuffer.data(), 1, extent, CFI_attribute_pointer);
whole.Check();

auto *cookie{IONAME(BeginInternalArrayListInput)(whole)};
std::int64_t dummy;

// Perform failing InputInteger
ASSERT_DEATH(IONAME(InputInteger)(cookie, dummy),
"Bad character 'g' in INTEGER input field");
"Bad character 'g' in INTEGER input field");
}

using ParamTy = std::tuple<std::string, std::vector<int>>;
Expand All @@ -163,7 +163,7 @@ TEST_P(SimpleListInputTest, TestListInput) {
Descriptor &whole{staticDescriptor.descriptor()};
SubscriptValue extent[]{numBuffers};
whole.Establish(TypeCode{CFI_type_char}, formatBuffer.size(),
formatBuffer.data(), 1, extent, CFI_attribute_pointer);
formatBuffer.data(), 1, extent, CFI_attribute_pointer);
whole.Check();
auto *cookie{IONAME(BeginInternalArrayListInput)(whole)};

Expand All @@ -185,10 +185,9 @@ TEST_P(SimpleListInputTest, TestListInput) {
}
}

INSTANTIATE_TEST_SUITE_P(
SimpleListInputTestInstantiation, SimpleListInputTest,
INSTANTIATE_TEST_SUITE_P(SimpleListInputTestInstantiation, SimpleListInputTest,
testing::Values(std::make_tuple("", std::vector<int>{}),
std::make_tuple("0", std::vector<int>{}),
std::make_tuple("1", std::vector<int>{1}),
std::make_tuple("1, 2", std::vector<int>{1, 2}),
std::make_tuple("3*2", std::vector<int>{2, 2, 2})));
std::make_tuple("0", std::vector<int>{}),
std::make_tuple("1", std::vector<int>{1}),
std::make_tuple("1, 2", std::vector<int>{1, 2}),
std::make_tuple("3*2", std::vector<int>{2, 2, 2})));
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
//
//===----------------------------------------------------------------------===//

#include "flang/../../runtime/namelist.h"
#include "../../runtime/namelist.h"
#include "CrashHandlerFixture.h"
#include "tools.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/io-api.h"
#include "tools.h"
#include <algorithm>
#include <cinttypes>
#include <complex>
Expand All @@ -27,7 +27,7 @@ struct NamelistTests : CrashHandlerFixture {};

static void ClearDescriptorStorage(const Descriptor &descriptor) {
std::memset(descriptor.raw().base_addr, 0,
descriptor.Elements() * descriptor.ElementBytes());
descriptor.Elements() * descriptor.ElementBytes());
}

TEST(NamelistTests, BasicSanity) {
Expand All @@ -38,20 +38,17 @@ TEST(NamelistTests, BasicSanity) {
Descriptor &internalDesc{statDescs[0].descriptor()};
SubscriptValue extent[]{numLines};
internalDesc.Establish(TypeCode{CFI_type_char}, /*elementBytes=*/lineLength,
&buffer, 1, extent, CFI_attribute_pointer);
&buffer, 1, extent, CFI_attribute_pointer);
// Set up data arrays
std::vector<int> ints;
for (int j{0}; j < 20; ++j) {
ints.push_back(j % 2 == 0 ? (1 << j) : -(1 << j));
}
std::vector<double> reals{0.0,
-0.0,
std::numeric_limits<double>::infinity(),
-std::numeric_limits<double>::infinity(),
std::numeric_limits<double>::quiet_NaN(),
std::numeric_limits<double>::max(),
std::numeric_limits<double>::lowest(),
std::numeric_limits<double>::epsilon()};
std::vector<double> reals{0.0, -0.0, std::numeric_limits<double>::infinity(),
-std::numeric_limits<double>::infinity(),
std::numeric_limits<double>::quiet_NaN(),
std::numeric_limits<double>::max(), std::numeric_limits<double>::lowest(),
std::numeric_limits<double>::epsilon()};
std::vector<std::uint8_t> logicals;
logicals.push_back(false);
logicals.push_back(true);
Expand Down Expand Up @@ -79,14 +76,12 @@ TEST(NamelistTests, BasicSanity) {
// Create a NAMELIST group
static constexpr int items{5};
const NamelistGroup::Item itemArray[items]{{"ints", *intDesc},
{"reals", *realDesc},
{"logicals", *logicalDesc},
{"complexes", *complexDesc},
{"characters", *characterDesc}};
{"reals", *realDesc}, {"logicals", *logicalDesc},
{"complexes", *complexDesc}, {"characters", *characterDesc}};
const NamelistGroup group{"group1", items, itemArray};
// Do an internal NAMELIST write and check results
auto outCookie1{IONAME(BeginInternalArrayListOutput)(internalDesc, nullptr, 0,
__FILE__, __LINE__)};
auto outCookie1{IONAME(BeginInternalArrayListOutput)(
internalDesc, nullptr, 0, __FILE__, __LINE__)};
ASSERT_TRUE(IONAME(SetDelim)(outCookie1, "APOSTROPHE", 10));
ASSERT_TRUE(IONAME(OutputNamelist)(outCookie1, group));
auto outStatus1{IONAME(EndIoStatement)(outCookie1)};
Expand Down Expand Up @@ -114,14 +109,14 @@ TEST(NamelistTests, BasicSanity) {
ClearDescriptorStorage(*logicalDesc);
ClearDescriptorStorage(*complexDesc);
ClearDescriptorStorage(*characterDesc);
auto inCookie{IONAME(BeginInternalArrayListInput)(internalDesc, nullptr, 0,
__FILE__, __LINE__)};
auto inCookie{IONAME(BeginInternalArrayListInput)(
internalDesc, nullptr, 0, __FILE__, __LINE__)};
ASSERT_TRUE(IONAME(InputNamelist)(inCookie, group));
auto inStatus{IONAME(EndIoStatement)(inCookie)};
ASSERT_EQ(inStatus, 0) << "Failed namelist input sanity, status "
<< static_cast<int>(inStatus);
auto outCookie2{IONAME(BeginInternalArrayListOutput)(internalDesc, nullptr, 0,
__FILE__, __LINE__)};
auto outCookie2{IONAME(BeginInternalArrayListOutput)(
internalDesc, nullptr, 0, __FILE__, __LINE__)};
ASSERT_TRUE(IONAME(SetDelim)(outCookie2, "APOSTROPHE", 10));
ASSERT_TRUE(IONAME(OutputNamelist)(outCookie2, group));
auto outStatus2{IONAME(EndIoStatement)(outCookie2)};
Expand All @@ -144,19 +139,18 @@ TEST(NamelistTests, Subscripts) {
StaticDescriptor<1, true> statDesc;
Descriptor &internalDesc{statDesc.descriptor()};
internalDesc.Establish(TypeCode{CFI_type_char},
/*elementBytes=*/std::strlen(t1), t1, 0, nullptr,
CFI_attribute_pointer);
auto inCookie{IONAME(BeginInternalArrayListInput)(internalDesc, nullptr, 0,
__FILE__, __LINE__)};
/*elementBytes=*/std::strlen(t1), t1, 0, nullptr, CFI_attribute_pointer);
auto inCookie{IONAME(BeginInternalArrayListInput)(
internalDesc, nullptr, 0, __FILE__, __LINE__)};
ASSERT_TRUE(IONAME(InputNamelist)(inCookie, group));
auto inStatus{IONAME(EndIoStatement)(inCookie)};
ASSERT_EQ(inStatus, 0) << "Failed namelist input subscripts, status "
<< static_cast<int>(inStatus);
char out[40];
internalDesc.Establish(TypeCode{CFI_type_char}, /*elementBytes=*/sizeof out,
out, 0, nullptr, CFI_attribute_pointer);
auto outCookie{IONAME(BeginInternalArrayListOutput)(internalDesc, nullptr, 0,
__FILE__, __LINE__)};
out, 0, nullptr, CFI_attribute_pointer);
auto outCookie{IONAME(BeginInternalArrayListOutput)(
internalDesc, nullptr, 0, __FILE__, __LINE__)};
ASSERT_TRUE(IONAME(OutputNamelist)(outCookie, group));
auto outStatus{IONAME(EndIoStatement)(outCookie)};
ASSERT_EQ(outStatus, 0)
Expand All @@ -183,8 +177,8 @@ TEST(NamelistTests, ShortArrayInput) {
Descriptor &internalDesc{statDesc.descriptor()};
SubscriptValue shape{2};
internalDesc.Establish(1, 12, t1, 1, &shape, CFI_attribute_pointer);
auto inCookie{IONAME(BeginInternalArrayListInput)(internalDesc, nullptr, 0,
__FILE__, __LINE__)};
auto inCookie{IONAME(BeginInternalArrayListInput)(
internalDesc, nullptr, 0, __FILE__, __LINE__)};
ASSERT_TRUE(IONAME(InputNamelist)(inCookie, group));
auto inStatus{IONAME(EndIoStatement)(inCookie)};
ASSERT_EQ(inStatus, 0) << "Failed namelist input subscripts, status "
Expand All @@ -204,18 +198,17 @@ TEST(NamelistTests, ScalarSubstring) {
StaticDescriptor<1, true> statDesc;
Descriptor &internalDesc{statDesc.descriptor()};
internalDesc.Establish(TypeCode{CFI_type_char},
/*elementBytes=*/std::strlen(t1), t1, 0, nullptr,
CFI_attribute_pointer);
auto inCookie{IONAME(BeginInternalArrayListInput)(internalDesc, nullptr, 0,
__FILE__, __LINE__)};
/*elementBytes=*/std::strlen(t1), t1, 0, nullptr, CFI_attribute_pointer);
auto inCookie{IONAME(BeginInternalArrayListInput)(
internalDesc, nullptr, 0, __FILE__, __LINE__)};
ASSERT_TRUE(IONAME(InputNamelist)(inCookie, group));
ASSERT_EQ(IONAME(EndIoStatement)(inCookie), IostatOk)
<< "namelist scalar substring input";
char out[32];
internalDesc.Establish(TypeCode{CFI_type_char}, /*elementBytes=*/sizeof out,
out, 0, nullptr, CFI_attribute_pointer);
auto outCookie{IONAME(BeginInternalArrayListOutput)(internalDesc, nullptr, 0,
__FILE__, __LINE__)};
out, 0, nullptr, CFI_attribute_pointer);
auto outCookie{IONAME(BeginInternalArrayListOutput)(
internalDesc, nullptr, 0, __FILE__, __LINE__)};
ASSERT_TRUE(IONAME(SetDelim)(outCookie, "apostrophe", 10));
ASSERT_TRUE(IONAME(OutputNamelist)(outCookie, group));
ASSERT_EQ(IONAME(EndIoStatement)(outCookie), IostatOk) << "namelist output";
Expand All @@ -225,27 +218,26 @@ TEST(NamelistTests, ScalarSubstring) {
}

TEST(NamelistTests, ArraySubstring) {
OwningPtr<Descriptor> scDesc{MakeArray<TypeCategory::Character, 1>(
std::vector<int>{2}, std::vector<std::string>{"abcdefgh", "ijklmnop"},
8)};
OwningPtr<Descriptor> scDesc{
MakeArray<TypeCategory::Character, 1>(std::vector<int>{2},
std::vector<std::string>{"abcdefgh", "ijklmnop"}, 8)};
const NamelistGroup::Item items[]{{"a", *scDesc}};
const NamelistGroup group{"justa", 1, items};
static char t1[]{"&justa A(:)(2:+5)='BCDE' 'JKLM'/"};
StaticDescriptor<1, true> statDesc;
Descriptor &internalDesc{statDesc.descriptor()};
internalDesc.Establish(TypeCode{CFI_type_char},
/*elementBytes=*/std::strlen(t1), t1, 0, nullptr,
CFI_attribute_pointer);
auto inCookie{IONAME(BeginInternalArrayListInput)(internalDesc, nullptr, 0,
__FILE__, __LINE__)};
/*elementBytes=*/std::strlen(t1), t1, 0, nullptr, CFI_attribute_pointer);
auto inCookie{IONAME(BeginInternalArrayListInput)(
internalDesc, nullptr, 0, __FILE__, __LINE__)};
ASSERT_TRUE(IONAME(InputNamelist)(inCookie, group));
ASSERT_EQ(IONAME(EndIoStatement)(inCookie), IostatOk)
<< "namelist scalar substring input";
char out[40];
internalDesc.Establish(TypeCode{CFI_type_char}, /*elementBytes=*/sizeof out,
out, 0, nullptr, CFI_attribute_pointer);
auto outCookie{IONAME(BeginInternalArrayListOutput)(internalDesc, nullptr, 0,
__FILE__, __LINE__)};
out, 0, nullptr, CFI_attribute_pointer);
auto outCookie{IONAME(BeginInternalArrayListOutput)(
internalDesc, nullptr, 0, __FILE__, __LINE__)};
ASSERT_TRUE(IONAME(SetDelim)(outCookie, "apostrophe", 10));
ASSERT_TRUE(IONAME(OutputNamelist)(outCookie, group));
ASSERT_EQ(IONAME(EndIoStatement)(outCookie), IostatOk) << "namelist output";
Expand All @@ -264,18 +256,17 @@ TEST(NamelistTests, Skip) {
StaticDescriptor<1, true> statDesc;
Descriptor &internalDesc{statDesc.descriptor()};
internalDesc.Establish(TypeCode{CFI_type_char},
/*elementBytes=*/std::strlen(t1), t1, 0, nullptr,
CFI_attribute_pointer);
auto inCookie{IONAME(BeginInternalArrayListInput)(internalDesc, nullptr, 0,
__FILE__, __LINE__)};
/*elementBytes=*/std::strlen(t1), t1, 0, nullptr, CFI_attribute_pointer);
auto inCookie{IONAME(BeginInternalArrayListInput)(
internalDesc, nullptr, 0, __FILE__, __LINE__)};
ASSERT_TRUE(IONAME(InputNamelist)(inCookie, group));
ASSERT_EQ(IONAME(EndIoStatement)(inCookie), IostatOk)
<< "namelist input with skipping";
char out[20];
internalDesc.Establish(TypeCode{CFI_type_char}, /*elementBytes=*/sizeof out,
out, 0, nullptr, CFI_attribute_pointer);
auto outCookie{IONAME(BeginInternalArrayListOutput)(internalDesc, nullptr, 0,
__FILE__, __LINE__)};
out, 0, nullptr, CFI_attribute_pointer);
auto outCookie{IONAME(BeginInternalArrayListOutput)(
internalDesc, nullptr, 0, __FILE__, __LINE__)};
ASSERT_TRUE(IONAME(OutputNamelist)(outCookie, group));
ASSERT_EQ(IONAME(EndIoStatement)(outCookie), IostatOk) << "namelist output";
std::string got{out, sizeof out};
Expand All @@ -294,19 +285,18 @@ TEST(NamelistTests, Comma) {
StaticDescriptor<1, true> statDesc;
Descriptor &internalDesc{statDesc.descriptor()};
internalDesc.Establish(TypeCode{CFI_type_char},
/*elementBytes=*/std::strlen(t1), t1, 0, nullptr,
CFI_attribute_pointer);
auto inCookie{IONAME(BeginInternalArrayListInput)(internalDesc, nullptr, 0,
__FILE__, __LINE__)};
/*elementBytes=*/std::strlen(t1), t1, 0, nullptr, CFI_attribute_pointer);
auto inCookie{IONAME(BeginInternalArrayListInput)(
internalDesc, nullptr, 0, __FILE__, __LINE__)};
ASSERT_TRUE(IONAME(SetDecimal)(inCookie, "COMMA", 5));
ASSERT_TRUE(IONAME(InputNamelist)(inCookie, group));
ASSERT_EQ(IONAME(EndIoStatement)(inCookie), IostatOk)
<< "namelist input with skipping";
char out[30];
internalDesc.Establish(TypeCode{CFI_type_char}, /*elementBytes=*/sizeof out,
out, 0, nullptr, CFI_attribute_pointer);
auto outCookie{IONAME(BeginInternalArrayListOutput)(internalDesc, nullptr, 0,
__FILE__, __LINE__)};
out, 0, nullptr, CFI_attribute_pointer);
auto outCookie{IONAME(BeginInternalArrayListOutput)(
internalDesc, nullptr, 0, __FILE__, __LINE__)};
ASSERT_TRUE(IONAME(SetDecimal)(outCookie, "COMMA", 5));
ASSERT_TRUE(IONAME(OutputNamelist)(outCookie, group));
ASSERT_EQ(IONAME(EndIoStatement)(outCookie), IostatOk) << "namelist output";
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
//
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
#include "flang/../../runtime/terminator.h"
#include "tools.h"
#include "../../runtime/terminator.h"
#include "flang/Runtime/io-api.h"
#include "flang/Runtime/transformational.h"
#include "tools.h"
#include <gtest/gtest.h>

using namespace Fortran::runtime;
Expand All @@ -26,7 +26,7 @@ using Fortran::common::TypeCategory;
//------------------------------------------------------------------------------
struct TestTerminator : CrashHandlerFixture {};

#define TEST_CRASH_HANDLER_MESSAGE \
#define TEST_CRASH_HANDLER_MESSAGE \
"Intentionally crashing runtime for unit test"

TEST(TestTerminator, CrashTest) {
Expand All @@ -39,13 +39,13 @@ TEST(TestTerminator, CrashTest) {
TEST(TestTerminator, CheckFailedLocationTest) {
static Fortran::runtime::Terminator t;
ASSERT_DEATH(t.CheckFailed("predicate", "someFileName", 789),
"RUNTIME_CHECK\\(predicate\\) failed at someFileName\\(789\\)");
"RUNTIME_CHECK\\(predicate\\) failed at someFileName\\(789\\)");
}

TEST(TestTerminator, CheckFailedTest) {
static Fortran::runtime::Terminator t;
ASSERT_DEATH(t.CheckFailed("predicate"),
"RUNTIME_CHECK\\(predicate\\) failed at \\(null\\)\\(0\\)");
"RUNTIME_CHECK\\(predicate\\) failed at \\(null\\)\\(0\\)");
}

//------------------------------------------------------------------------------
Expand All @@ -57,21 +57,20 @@ TEST(TestIOCrash, FormatDescriptorWriteMismatchTest) {
static constexpr int bufferSize{4};
static char buffer[bufferSize];
static const char *format{"(A4)"};
auto *cookie{IONAME(BeginInternalFormattedOutput)(buffer, bufferSize, format,
std::strlen(format))};
ASSERT_DEATH(
IONAME(OutputLogical)(cookie, true),
auto *cookie{IONAME(BeginInternalFormattedOutput)(
buffer, bufferSize, format, std::strlen(format))};
ASSERT_DEATH(IONAME(OutputLogical)(cookie, true),
"Data edit descriptor 'A' may not be used with a LOGICAL data item");
}

TEST(TestIOCrash, InvalidFormatCharacterTest) {
static constexpr int bufferSize{1};
static char buffer[bufferSize];
static const char *format{"(C1)"};
auto *cookie{IONAME(BeginInternalFormattedOutput)(buffer, bufferSize, format,
std::strlen(format))};
auto *cookie{IONAME(BeginInternalFormattedOutput)(
buffer, bufferSize, format, std::strlen(format))};
ASSERT_DEATH(IONAME(OutputInteger64)(cookie, 0xfeedface),
"Unknown 'C' edit descriptor in FORMAT");
"Unknown 'C' edit descriptor in FORMAT");
}

//------------------------------------------------------------------------------
Expand All @@ -84,80 +83,80 @@ TEST(TestIOCrash, OverwriteBufferAsciiTest) {
static constexpr int bufferSize{4};
static char buffer[bufferSize];
static const char *format{"(A4)"};
auto *cookie{IONAME(BeginInternalFormattedOutput)(buffer, bufferSize, format,
std::strlen(format))};
auto *cookie{IONAME(BeginInternalFormattedOutput)(
buffer, bufferSize, format, std::strlen(format))};
IONAME(OutputAscii)(cookie, "four", bufferSize);
ASSERT_DEATH(IONAME(OutputAscii)(cookie, "Too many characters!", 20),
"Internal write overran available records");
"Internal write overran available records");
}

TEST(TestIOCrash, OverwriteBufferCharacterTest) {
static constexpr int bufferSize{1};
static char buffer[bufferSize];
static const char *format{"(A1)"};
auto *cookie{IONAME(BeginInternalFormattedOutput)(buffer, bufferSize, format,
std::strlen(format))};
auto *cookie{IONAME(BeginInternalFormattedOutput)(
buffer, bufferSize, format, std::strlen(format))};
IONAME(OutputCharacter)(cookie, "a", 1);
ASSERT_DEATH(IONAME(OutputCharacter)(cookie, "a", 1),
"Internal write overran available records");
"Internal write overran available records");
}

TEST(TestIOCrash, OverwriteBufferLogicalTest) {
static constexpr int bufferSize{1};
static char buffer[bufferSize];
static const char *format{"(L1)"};
auto *cookie{IONAME(BeginInternalFormattedOutput)(buffer, bufferSize, format,
std::strlen(format))};
auto *cookie{IONAME(BeginInternalFormattedOutput)(
buffer, bufferSize, format, std::strlen(format))};
IONAME(OutputLogical)(cookie, true);
ASSERT_DEATH(IONAME(OutputLogical)(cookie, true),
"Internal write overran available records");
"Internal write overran available records");
}

TEST(TestIOCrash, OverwriteBufferRealTest) {
static constexpr int bufferSize{1};
static char buffer[bufferSize];
static const char *format{"(F1)"};
auto *cookie{IONAME(BeginInternalFormattedOutput)(buffer, bufferSize, format,
std::strlen(format))};
auto *cookie{IONAME(BeginInternalFormattedOutput)(
buffer, bufferSize, format, std::strlen(format))};
IONAME(OutputReal32)(cookie, 1.);
EXPECT_DEATH(IONAME(OutputReal32)(cookie, 1.),
"Internal write overran available records");
"Internal write overran available records");

std::memset(buffer, '\0', bufferSize);
cookie = IONAME(BeginInternalFormattedOutput)(buffer, bufferSize, format,
std::strlen(format));
cookie = IONAME(BeginInternalFormattedOutput)(
buffer, bufferSize, format, std::strlen(format));
IONAME(OutputReal64)(cookie, 1.);
EXPECT_DEATH(IONAME(OutputReal64)(cookie, 1.),
"Internal write overran available records");
"Internal write overran available records");
}

TEST(TestIOCrash, OverwriteBufferComplexTest) {
static constexpr int bufferSize{8};
static char buffer[bufferSize];
static const char *format{"(Z1,Z1)"};
auto *cookie{IONAME(BeginInternalFormattedOutput)(buffer, bufferSize, format,
std::strlen(format))};
auto *cookie{IONAME(BeginInternalFormattedOutput)(
buffer, bufferSize, format, std::strlen(format))};
IONAME(OutputComplex32)(cookie, 1., 1.);
EXPECT_DEATH(IONAME(OutputComplex32)(cookie, 1., 1.),
"Internal write overran available records");
"Internal write overran available records");

std::memset(buffer, '\0', bufferSize);
cookie = IONAME(BeginInternalFormattedOutput)(buffer, bufferSize, format,
std::strlen(format));
cookie = IONAME(BeginInternalFormattedOutput)(
buffer, bufferSize, format, std::strlen(format));
IONAME(OutputComplex64)(cookie, 1., 1.);
EXPECT_DEATH(IONAME(OutputComplex64)(cookie, 1., 1.),
"Internal write overran available records");
"Internal write overran available records");
}

TEST(TestIOCrash, OverwriteBufferIntegerTest) {
static constexpr int bufferSize{1};
static char buffer[bufferSize];
static const char *format{"(I1)"};
auto *cookie{IONAME(BeginInternalFormattedOutput)(buffer, bufferSize, format,
std::strlen(format))};
auto *cookie{IONAME(BeginInternalFormattedOutput)(
buffer, bufferSize, format, std::strlen(format))};
IONAME(OutputInteger64)(cookie, 0xdeadbeef);
ASSERT_DEATH(IONAME(OutputInteger64)(cookie, 0xdeadbeef),
"Internal write overran available records");
"Internal write overran available records");
}

//------------------------------------------------------------------------------
Expand All @@ -169,15 +168,13 @@ TEST(TestIntrinsicCrash, ConformityErrors) {
// ARRAY(2,3) and MASK(2,4) should trigger a runtime error.
auto array{MakeArray<TypeCategory::Integer, 4>(
std::vector<int>{2, 3}, std::vector<std::int32_t>{1, 2, 3, 4, 5, 6})};
auto mask{MakeArray<TypeCategory::Logical, 1>(
std::vector<int>{2, 4},
std::vector<std::uint8_t>{false, true, true, false, false, true, true,
true})};
auto mask{MakeArray<TypeCategory::Logical, 1>(std::vector<int>{2, 4},
std::vector<std::uint8_t>{
false, true, true, false, false, true, true, true})};
StaticDescriptor<1, true> statDesc;
Descriptor &result{statDesc.descriptor()};

ASSERT_DEATH(
RTNAME(Pack)(result, *array, *mask, nullptr, __FILE__, __LINE__),
ASSERT_DEATH(RTNAME(Pack)(result, *array, *mask, nullptr, __FILE__, __LINE__),
"Incompatible array arguments to PACK: dimension 2 of ARRAY= has extent "
"3 but MASK= has extent 4");
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/stop.h"
#include "CrashHandlerFixture.h"
#include "flang/../../runtime/environment.h"
#include "../../runtime/environment.h"
#include <cstdlib>
#include <gtest/gtest.h>

Expand All @@ -21,69 +21,67 @@ struct TestProgramEnd : CrashHandlerFixture {};

TEST(TestProgramEnd, StopTest) {
EXPECT_EXIT(RTNAME(StopStatement)(), testing::ExitedWithCode(EXIT_SUCCESS),
"Fortran STOP");
"Fortran STOP");
}

TEST(TestProgramEnd, StopTestNoStopMessage) {
putenv(const_cast<char *>("NO_STOP_MESSAGE=1"));
Fortran::runtime::executionEnvironment.Configure(0, nullptr, nullptr,
nullptr);
EXPECT_EXIT(RTNAME(StopStatement)(), testing::ExitedWithCode(EXIT_SUCCESS),
"");
Fortran::runtime::executionEnvironment.Configure(
0, nullptr, nullptr, nullptr);
EXPECT_EXIT(
RTNAME(StopStatement)(), testing::ExitedWithCode(EXIT_SUCCESS), "");
}

TEST(TestProgramEnd, StopMessageTest) {
static const char *message{"bye bye"};
EXPECT_EXIT(RTNAME(StopStatementText)(message, std::strlen(message),
/*isErrorStop=*/false, /*quiet=*/false),
testing::ExitedWithCode(EXIT_SUCCESS), "Fortran STOP: bye bye");
/*isErrorStop=*/false, /*quiet=*/false),
testing::ExitedWithCode(EXIT_SUCCESS), "Fortran STOP: bye bye");

EXPECT_EXIT(RTNAME(StopStatementText)(message, std::strlen(message),
/*isErrorStop=*/false, /*quiet=*/true),
testing::ExitedWithCode(EXIT_SUCCESS), "");
/*isErrorStop=*/false, /*quiet=*/true),
testing::ExitedWithCode(EXIT_SUCCESS), "");

EXPECT_EXIT(RTNAME(StopStatementText)(message, std::strlen(message),
/*isErrorStop=*/true, /*quiet=*/false),
testing::ExitedWithCode(EXIT_FAILURE),
"Fortran ERROR STOP: bye bye");
/*isErrorStop=*/true, /*quiet=*/false),
testing::ExitedWithCode(EXIT_FAILURE), "Fortran ERROR STOP: bye bye");

EXPECT_EXIT(RTNAME(StopStatementText)(message, std::strlen(message),
/*isErrorStop=*/true, /*quiet=*/true),
testing::ExitedWithCode(EXIT_FAILURE), "");
/*isErrorStop=*/true, /*quiet=*/true),
testing::ExitedWithCode(EXIT_FAILURE), "");
}

TEST(TestProgramEnd, NoStopMessageTest) {
putenv(const_cast<char *>("NO_STOP_MESSAGE=1"));
Fortran::runtime::executionEnvironment.Configure(0, nullptr, nullptr,
nullptr);
Fortran::runtime::executionEnvironment.Configure(
0, nullptr, nullptr, nullptr);
static const char *message{"bye bye"};
EXPECT_EXIT(RTNAME(StopStatementText)(message, std::strlen(message),
/*isErrorStop=*/false, /*quiet=*/false),
testing::ExitedWithCode(EXIT_SUCCESS), "bye bye");
/*isErrorStop=*/false, /*quiet=*/false),
testing::ExitedWithCode(EXIT_SUCCESS), "bye bye");

EXPECT_EXIT(RTNAME(StopStatementText)(message, std::strlen(message),
/*isErrorStop=*/false, /*quiet=*/true),
testing::ExitedWithCode(EXIT_SUCCESS), "");
/*isErrorStop=*/false, /*quiet=*/true),
testing::ExitedWithCode(EXIT_SUCCESS), "");

EXPECT_EXIT(RTNAME(StopStatementText)(message, std::strlen(message),
/*isErrorStop=*/true, /*quiet=*/false),
testing::ExitedWithCode(EXIT_FAILURE),
"Fortran ERROR STOP: bye bye");
/*isErrorStop=*/true, /*quiet=*/false),
testing::ExitedWithCode(EXIT_FAILURE), "Fortran ERROR STOP: bye bye");

EXPECT_EXIT(RTNAME(StopStatementText)(message, std::strlen(message),
/*isErrorStop=*/true, /*quiet=*/true),
testing::ExitedWithCode(EXIT_FAILURE), "");
/*isErrorStop=*/true, /*quiet=*/true),
testing::ExitedWithCode(EXIT_FAILURE), "");
}

TEST(TestProgramEnd, FailImageTest) {
EXPECT_EXIT(RTNAME(FailImageStatement)(),
testing::ExitedWithCode(EXIT_FAILURE), "");
EXPECT_EXIT(
RTNAME(FailImageStatement)(), testing::ExitedWithCode(EXIT_FAILURE), "");
}

TEST(TestProgramEnd, ExitTest) {
EXPECT_EXIT(RTNAME(Exit)(), testing::ExitedWithCode(EXIT_SUCCESS), "");
EXPECT_EXIT(RTNAME(Exit)(EXIT_FAILURE), testing::ExitedWithCode(EXIT_FAILURE),
"");
EXPECT_EXIT(
RTNAME(Exit)(EXIT_FAILURE), testing::ExitedWithCode(EXIT_FAILURE), "");
}

TEST(TestProgramEnd, AbortTest) { EXPECT_DEATH(RTNAME(Abort)(), ""); }
Expand All @@ -93,8 +91,8 @@ TEST(TestProgramEnd, CrashTest) {
static const std::string fileName{"file name"};
static const std::string headMessage{"fatal Fortran runtime error\\("};
static const std::string tailMessage{":343\\): "};
static const std::string fullMessage{headMessage + fileName + tailMessage +
crashMessage};
static const std::string fullMessage{
headMessage + fileName + tailMessage + crashMessage};
EXPECT_DEATH(
RTNAME(ReportFatalUserError)(crashMessage.c_str(), fileName.c_str(), 343),
fullMessage.c_str());
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion lld/COFF/MinGW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ AutoExporter::AutoExporter(
"libc++",
"libc++abi",
"libFortran_main",
"libflang-rt",
"libFortranRuntime",
"libFortranDecimal",
"libunwind",
"libmsvcrt",
"libucrtbase",
Expand Down
10 changes: 1 addition & 9 deletions llvm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,7 @@ endif()
# As we migrate runtimes to using the bootstrapping build, the set of default runtimes
# should grow as we remove those runtimes from LLVM_ENABLE_PROJECTS above.
set(LLVM_DEFAULT_RUNTIMES "libcxx;libcxxabi;libunwind")
if ("flang" IN_LIST LLVM_ENABLE_PROJECTS)
set(LLVM_DEFAULT_RUNTIMES "libcxx;libcxxabi;libunwind;flang-rt")
endif()
set(LLVM_SUPPORTED_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;llvm-libgcc;flang-rt")
set(LLVM_SUPPORTED_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;llvm-libgcc")
set(LLVM_ENABLE_RUNTIMES "" CACHE STRING
"Semicolon-separated list of runtimes to build, or \"all\" (${LLVM_DEFAULT_RUNTIMES}). Supported runtimes are ${LLVM_SUPPORTED_RUNTIMES}.")
if(LLVM_ENABLE_RUNTIMES STREQUAL "all")
Expand All @@ -181,11 +178,6 @@ if ("libc" IN_LIST LLVM_ENABLE_RUNTIMES)
endif()
endif()

if ("flang" IN_LIST LLVM_ENABLE_PROJECTS AND NOT "flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
message(STATUS "Enabling Flang-rt to be built with the Flang project.")
list(APPEND LLVM_ENABLE_RUNTIMES "flang-rt")
endif()

# LLVM_ENABLE_PROJECTS_USED is `ON` if the user has ever used the
# `LLVM_ENABLE_PROJECTS` CMake cache variable. This exists for
# several reasons:
Expand Down
3 changes: 0 additions & 3 deletions llvm/projects/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ foreach(entry ${entries})
if(IS_DIRECTORY ${entry} AND EXISTS ${entry}/CMakeLists.txt)
if((NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/compiler-rt) AND
(NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/dragonegg) AND
(NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/flang-rt) AND
(NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/libcxx) AND
(NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/libcxxabi) AND
(NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/libunwind) AND
Expand Down Expand Up @@ -38,8 +37,6 @@ if(${LLVM_BUILD_RUNTIME})
if(NOT LLVM_BUILD_EXTERNAL_COMPILER_RT)
add_llvm_external_project(compiler-rt)
endif()

add_llvm_external_project(flang-rt)
endif()

add_llvm_external_project(dragonegg)
Expand Down
14 changes: 3 additions & 11 deletions llvm/runtimes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -401,24 +401,17 @@ if(runtimes)
endforeach()
endif()
endif()
set(EXTRA_CMAKE_ARGS "")
if("flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
list(APPEND EXTRA_CMAKE_ARGS "-DLLVM_DIR=${LLVM_BINARY_DIR}/lib/cmake/llvm")
list(APPEND EXTRA_CMAKE_ARGS "-DFLANG_DIR=${LLVM_BINARY_DIR}/lib/cmake/flang")
list(APPEND EXTRA_CMAKE_ARGS "-DCLANG_DIR=${LLVM_BINARY_DIR}/lib/cmake/clang")
list(APPEND EXTRA_CMAKE_ARGS "-DMLIR_DIR=${LLVM_BINARY_DIR}/lib/cmake/mlir")
endif()
if(NOT LLVM_RUNTIME_TARGETS)
runtime_default_target(
DEPENDS ${builtins_dep} ${extra_deps}
CMAKE_ARGS ${libc_cmake_args} ${EXTRA_CMAKE_ARGS}
CMAKE_ARGS ${libc_cmake_args}
PREFIXES ${prefixes})
set(test_targets check-runtimes)
else()
if("default" IN_LIST LLVM_RUNTIME_TARGETS)
runtime_default_target(
DEPENDS ${builtins_dep} ${extra_deps}
CMAKE_ARGS ${libc_cmake_args} ${EXTRA_CMAKE_ARGS}
CMAKE_ARGS ${libc_cmake_args}
PREFIXES ${prefixes})
list(REMOVE_ITEM LLVM_RUNTIME_TARGETS "default")
else()
Expand Down Expand Up @@ -458,7 +451,7 @@ if(runtimes)

runtime_register_target(${name}
DEPENDS ${builtins_dep_name} ${libc_tools}
CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${name} ${libc_cmake_args} ${EXTRA_CMAKE_ARGS}
CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${name} ${libc_cmake_args}
EXTRA_ARGS TARGET_TRIPLE ${name})

add_dependencies(runtimes runtimes-${name})
Expand Down Expand Up @@ -488,7 +481,6 @@ if(runtimes)
CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${name}
-DLLVM_RUNTIMES_PREFIX=${name}/
-DLLVM_RUNTIMES_LIBDIR_SUBDIR=${multilib}
${EXTRA_CMAKE_ARGS}
BASE_NAME ${name}
EXTRA_ARGS TARGET_TRIPLE ${name})

Expand Down
2 changes: 1 addition & 1 deletion runtimes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ list(INSERT CMAKE_MODULE_PATH 0

# We order libraries to mirror roughly how they are layered, except that compiler-rt can depend
# on libc++, so we put it after.
set(LLVM_DEFAULT_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;flang-rt")
set(LLVM_DEFAULT_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp")
set(LLVM_SUPPORTED_RUNTIMES "${LLVM_DEFAULT_RUNTIMES};llvm-libgcc")
set(LLVM_ENABLE_RUNTIMES "" CACHE STRING
"Semicolon-separated list of runtimes to build, or \"all\" (${LLVM_DEFAULT_RUNTIMES}). Supported runtimes are ${LLVM_SUPPORTED_RUNTIMES}.")
Expand Down