1//===-- runtime/stat.h ------------------------------------------*- C++ -*-===//
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// Defines the values returned by the runtime for STAT= specifiers
10// on executable statements.
11
12#ifndef FORTRAN_RUNTIME_STAT_H_
13#define FORTRAN_RUNTIME_STAT_H_
14#include "flang/Common/api-attrs.h"
15#include "flang/ISO_Fortran_binding_wrapper.h"
16#include "flang/Runtime/magic-numbers.h"
17namespace Fortran::runtime {
18
19class Descriptor;
20class Terminator;
21
22// The value of STAT= is zero when no error condition has arisen.
23
24enum Stat {
25 StatOk = 0, // required to be zero by Fortran
26
27 // Interoperable STAT= codes
28 StatBaseNull = CFI_ERROR_BASE_ADDR_NULL,
29 StatBaseNotNull = CFI_ERROR_BASE_ADDR_NOT_NULL,
30 StatInvalidElemLen = CFI_INVALID_ELEM_LEN,
31 StatInvalidRank = CFI_INVALID_RANK,
32 StatInvalidType = CFI_INVALID_TYPE,
33 StatInvalidAttribute = CFI_INVALID_ATTRIBUTE,
34 StatInvalidExtent = CFI_INVALID_EXTENT,
35 StatInvalidDescriptor = CFI_INVALID_DESCRIPTOR,
36 StatMemAllocation = CFI_ERROR_MEM_ALLOCATION,
37 StatOutOfBounds = CFI_ERROR_OUT_OF_BOUNDS,
38
39 // Standard STAT= values
40 StatFailedImage = FORTRAN_RUNTIME_STAT_FAILED_IMAGE,
41 StatLocked = FORTRAN_RUNTIME_STAT_LOCKED,
42 StatLockedOtherImage = FORTRAN_RUNTIME_STAT_LOCKED_OTHER_IMAGE,
43 StatMissingEnvVariable = FORTRAN_RUNTIME_STAT_MISSING_ENV_VAR,
44 StatStoppedImage = FORTRAN_RUNTIME_STAT_STOPPED_IMAGE,
45 StatUnlocked = FORTRAN_RUNTIME_STAT_UNLOCKED,
46 StatUnlockedFailedImage = FORTRAN_RUNTIME_STAT_UNLOCKED_FAILED_IMAGE,
47
48 // Additional "processor-defined" STAT= values
49 StatInvalidArgumentNumber = FORTRAN_RUNTIME_STAT_INVALID_ARG_NUMBER,
50 StatMissingArgument = FORTRAN_RUNTIME_STAT_MISSING_ARG,
51 StatValueTooShort = FORTRAN_RUNTIME_STAT_VALUE_TOO_SHORT,
52 StatMoveAllocSameAllocatable =
53 FORTRAN_RUNTIME_STAT_MOVE_ALLOC_SAME_ALLOCATABLE,
54 StatBadPointerDeallocation = FORTRAN_RUNTIME_STAT_BAD_POINTER_DEALLOCATION,
55};
56
57RT_API_ATTRS const char *StatErrorString(int);
58RT_API_ATTRS int ToErrmsg(const Descriptor *errmsg, int stat); // returns stat
59RT_API_ATTRS int ReturnError(Terminator &, int stat,
60 const Descriptor *errmsg = nullptr, bool hasStat = false);
61} // namespace Fortran::runtime
62#endif // FORTRAN_RUNTIME_STAT_H
63

source code of flang/runtime/stat.h