• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "magic-numbers.h"
15 #include "flang/ISO_Fortran_binding.h"
16 namespace Fortran::runtime {
17 
18 class Descriptor;
19 class Terminator;
20 
21 // The value of STAT= is zero when no error condition has arisen.
22 
23 enum Stat {
24   StatOk = 0, // required to be zero by Fortran
25 
26   // Interoperable STAT= codes
27   StatBaseNull = CFI_ERROR_BASE_ADDR_NULL,
28   StatBaseNotNull = CFI_ERROR_BASE_ADDR_NOT_NULL,
29   StatInvalidElemLen = CFI_INVALID_ELEM_LEN,
30   StatInvalidRank = CFI_INVALID_RANK,
31   StatInvalidType = CFI_INVALID_TYPE,
32   StatInvalidAttribute = CFI_INVALID_ATTRIBUTE,
33   StatInvalidExtent = CFI_INVALID_EXTENT,
34   StatInvalidDescriptor = CFI_INVALID_DESCRIPTOR,
35   StatMemAllocation = CFI_ERROR_MEM_ALLOCATION,
36   StatOutOfBounds = CFI_ERROR_OUT_OF_BOUNDS,
37 
38   // Standard STAT= values
39   StatFailedImage = FORTRAN_RUNTIME_STAT_FAILED_IMAGE,
40   StatLocked = FORTRAN_RUNTIME_STAT_LOCKED,
41   StatLockedOtherImage = FORTRAN_RUNTIME_STAT_LOCKED_OTHER_IMAGE,
42   StatStoppedImage = FORTRAN_RUNTIME_STAT_STOPPED_IMAGE,
43   StatUnlocked = FORTRAN_RUNTIME_STAT_UNLOCKED,
44   StatUnlockedFailedImage = FORTRAN_RUNTIME_STAT_UNLOCKED_FAILED_IMAGE,
45 
46   // Additional "processor-defined" STAT= values
47 };
48 
49 const char *StatErrorString(int);
50 int ToErrmsg(Descriptor *errmsg, int stat); // returns stat
51 int ReturnError(
52     Terminator &, int stat, Descriptor *errmsg = nullptr, bool hasStat = false);
53 } // namespace Fortran::runtime
54 #endif // FORTRAN_RUNTIME_STAT_H
55