1/*
2This test makes sure that flang's runtime does not depend on the C++ runtime
3library. It tries to link this simple file against libflang_rt.runtime.a with
4a C compiler.
5
6UNSUPPORTED: system-windows
7UNSUPPORTED: offload-cuda
8
9RUN: %if system-aix %{ export OBJECT_MODE=64 %}
10RUN: %cc -std=c99 %s -I%include -L"%libdir" -lflang_rt.runtime -lm \
11RUN: %if system-aix %{-lpthread %}
12RUN: rm a.out
13*/
14
15#include "flang/Runtime/entry-names.h"
16#include <stdint.h>
17
18/*
19Manually add declarations for the runtime functions that we want to make sure
20we're testing. We can't include any headers directly since they likely contain
21C++ code that would explode here.
22*/
23struct EnvironmentDefaultList;
24struct Descriptor;
25
26double RTNAME(CpuTime)();
27
28void RTNAME(ProgramStart)(
29 int, const char *[], const char *[], const struct EnvironmentDefaultList *);
30int32_t RTNAME(ArgumentCount)();
31int32_t RTNAME(GetCommandArgument)(int32_t, const struct Descriptor *,
32 const struct Descriptor *, const struct Descriptor *);
33int32_t RTNAME(GetEnvVariable)();
34int64_t RTNAME(SystemClockCount)(int kind);
35
36int main() {
37 double x = RTNAME(CpuTime)();
38 RTNAME(ProgramStart)(0, 0, 0, 0);
39 int32_t c = RTNAME(ArgumentCount)();
40 int32_t v = RTNAME(GetCommandArgument)(0, 0, 0, 0);
41 int32_t e = RTNAME(GetEnvVariable)("FOO", 0, 0);
42 int64_t t = RTNAME(SystemClockCount)(8);
43 return x + c + v + e;
44}
45

source code of flang-rt/test/Runtime/no-cpp-dep.c