1 /* 2 * Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 */ 17 18 #ifndef PGERROR_H_ 19 #define PGERROR_H_ 20 21 /** \file 22 * \brief Error handling and reporting. 23 */ 24 25 #include "universal.h" 26 27 #ifndef IN_FLANG2 28 BEGIN_DECL_WITH_C_LINKAGE 29 #endif 30 31 /** \brief Severity of an error message. 32 */ 33 typedef enum error_severity { 34 ERR_unused = 0, 35 ERR_Informational = 1, 36 ERR_Warning = 2, 37 ERR_Severe = 3, 38 ERR_Fatal = 4, 39 ERR_SEVERITY_SIZE // must be last! 40 } error_severity; 41 42 #ifdef IN_FLANG2 43 #include "errmsgdf.h" 44 #endif 45 46 /** \brief Error code type 47 */ 48 typedef enum error_code error_code_t; 49 50 #ifdef IN_FLANG2 51 #include "error.h" 52 #endif 53 54 #ifdef FE90 55 void errWithSrc(error_code_t ecode, enum error_severity sev, int eline, 56 const char *op1, const char *op2, int col, int deduceCol, 57 bool uniqDeduc, const char *deduceVal); 58 char * getDeduceStr(char * ptoken); 59 #endif 60 61 /** \brief Assert that cond is true, and emit an internal compiler error 62 * otherwise. 63 * 64 * Note that unlike the C standard <assert.h> assert() macro, this version is 65 * active in both debug and release builds, and expands to a statement, 66 * not an expression. 67 */ 68 #define assert(cond, txt, val, sev) \ 69 if (cond) \ 70 ; \ 71 else \ 72 interr((txt), (val), (sev)) 73 74 /** \brief If DEBUG!=0 and cond is false, emit an internal compiler error. 75 * 76 * Like the C standard <assert.h> assert macro, this version expands to an 77 * expression and is active only in debug builds. Severity of an error 78 * is implicitly maximal. 79 * 80 * \param cond is the condition to be checked 81 * \param txt is an additional info string, which may be NULL. 82 */ 83 #if DEBUG 84 #define DEBUG_ASSERT(cond, txt) \ 85 ((cond) ? (void)0 : dassert_err(__FILE__, __LINE__, #cond, (txt))) 86 void dassert_err(const char *, int line, const char *exp, const char *txt); 87 #else 88 #define DEBUG_ASSERT(cond, txt) ((void)0) 89 #endif 90 91 #if DEBUG 92 void asrt_failed(const char* file, int line); 93 #endif 94 95 #ifndef IN_FLANG2 96 END_DECL_WITH_C_LINKAGE 97 #endif 98 99 #endif /* PGERROR_H_ */ 100