/* Definitions for -*- C++ -*- parsing and type checking. Copyright (C) 1987-2023 Free Software Foundation, Inc. Contributed by Michael Tiemann (tiemann@cygnus.com) This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see . */ #ifndef GCC_CP_TREE_H #define GCC_CP_TREE_H #include "tm.h" #include "hard-reg-set.h" #include "function.h" #include "tristate.h" #include "contracts.h" /* In order for the format checking to accept the C++ front end diagnostic framework extensions, you must include this file before diagnostic-core.h, not after. We override the definition of GCC_DIAG_STYLE in c-common.h. */ #undef GCC_DIAG_STYLE #define GCC_DIAG_STYLE __gcc_cxxdiag__ #if defined(GCC_DIAGNOSTIC_CORE_H) || defined (GCC_C_COMMON_H) #error \ In order for the format checking to accept the C++ front end diagnostic \ framework extensions, you must include this file before diagnostic-core.h and \ c-common.h, not after. #endif #include "c-family/c-common.h" #include "diagnostic.h" /* A tree node, together with a location, so that we can track locations (and ranges) during parsing. The location is redundant for node kinds that have locations, but not all node kinds do (e.g. constants, and references to params, locals, etc), so we stash a copy here. */ extern location_t cp_expr_location (const_tree); class cp_expr { public: cp_expr () : m_value (NULL), m_loc (UNKNOWN_LOCATION), m_decimal (false) {} cp_expr (tree value) : m_value (value), m_loc (cp_expr_location (m_value)), m_decimal (false) {} cp_expr (tree value, location_t loc): m_value (value), m_loc (loc), m_decimal (false) { protected_set_expr_location (value, loc); } cp_expr (tree value, location_t loc, bool decimal): m_value (value), m_loc (loc), m_decimal (decimal) { protected_set_expr_location (value, loc); } /* Implicit conversions to tree. */ operator tree () const { return m_value; } tree & operator* () { return m_value; } tree operator* () const { return m_value; } tree & operator-> () { return m_value; } tree operator-> () const { return m_value; } tree get_value () const { return m_value; } location_t get_location () const { return m_loc; } location_t get_start () const { source_range src_range = get_range_from_loc (line_table, m_loc); return src_range.m_start; } location_t get_finish () const { source_range src_range = get_range_from_loc (line_table, m_loc); return src_range.m_finish; } void set_location (location_t loc) { protected_set_expr_location (m_value, loc); m_loc = loc; } void set_range (location_t start, location_t finish) { set_location (make_location (m_loc, start, finish)); } cp_expr& maybe_add_location_wrapper () { m_value = maybe_wrap_with_location (m_value, m_loc); return *this; } bool decimal_p () const { return m_decimal; } private: tree m_value; location_t m_loc; bool m_decimal : 1; }; inline bool operator == (const cp_expr &lhs, tree rhs) { return lhs.get_value () == rhs; }