diff options
Diffstat (limited to 'libcpp/include')
-rw-r--r-- | libcpp/include/cpplib.h | 25 | ||||
-rw-r--r-- | libcpp/include/line-map.h | 69 |
2 files changed, 68 insertions, 26 deletions
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h index 940c79f..810203d 100644 --- a/libcpp/include/cpplib.h +++ b/libcpp/include/cpplib.h @@ -319,15 +319,16 @@ enum cpp_main_search CMS_system, /* Search the system INCLUDE path. */ }; -/* The possible bidirectional control characters checking levels, from least - restrictive to most. */ +/* The possible bidirectional control characters checking levels. */ enum cpp_bidirectional_level { /* No checking. */ - bidirectional_none, + bidirectional_none = 0, /* Only detect unpaired uses of bidirectional control characters. */ - bidirectional_unpaired, + bidirectional_unpaired = 1, /* Detect any use of bidirectional control characters. */ - bidirectional_any + bidirectional_any = 2, + /* Also warn about UCNs. */ + bidirectional_ucn = 4 }; /* This structure is nested inside struct cpp_reader, and @@ -512,12 +513,18 @@ struct cpp_options /* Nonzero for the '#elifdef' and '#elifndef' directives. */ unsigned char elifdef; + /* Nonzero for the '#warning' directive. */ + unsigned char warning_directive; + /* Nonzero means tokenize C++20 module directives. */ unsigned char module_directives; /* Nonzero for C++23 size_t literals. */ unsigned char size_t_literals; + /* Nonzero for C++23 delimited escape sequences. */ + unsigned char delimited_escape_seqs; + /* Holds the name of the target (execution) character set. */ const char *narrow_charset; @@ -546,6 +553,9 @@ struct cpp_options /* True if warn about differences between C++98 and C++11. */ bool cpp_warn_cxx11_compat; + /* True if warn about differences between C++17 and C++20. */ + bool cpp_warn_cxx20_compat; + /* Nonzero if bidirectional control characters checking is on. See enum cpp_bidirectional_level. */ unsigned char cpp_warn_bidirectional; @@ -580,8 +590,8 @@ struct cpp_options ints and target wide characters, respectively. */ size_t precision, char_precision, int_precision, wchar_precision; - /* True means chars (wide chars) are unsigned. */ - bool unsigned_char, unsigned_wchar; + /* True means chars (wide chars, UTF-8 chars) are unsigned. */ + bool unsigned_char, unsigned_wchar, unsigned_utf8char; /* True if the most significant byte in a word has the lowest address in memory. */ @@ -654,6 +664,7 @@ enum cpp_warning_reason { CPP_W_C90_C99_COMPAT, CPP_W_C11_C2X_COMPAT, CPP_W_CXX11_COMPAT, + CPP_W_CXX20_COMPAT, CPP_W_EXPANSION_TO_DEFINED, CPP_W_BIDIRECTIONAL }; diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h index 3f39eb4..9bdd5b9 100644 --- a/libcpp/include/line-map.h +++ b/libcpp/include/line-map.h @@ -22,6 +22,8 @@ along with this program; see the file COPYING3. If not see #ifndef LIBCPP_LINE_MAP_H #define LIBCPP_LINE_MAP_H +#include <utility> + #ifndef GTY #define GTY(x) /* nothing */ #endif @@ -792,6 +794,9 @@ public: /* If true, prints an include trace a la -H. */ bool trace_includes; + /* True if we've seen a #line or # 44 "file" directive. */ + bool seen_line_directive; + /* Highest location_t "given out". */ location_t highest_location; @@ -815,9 +820,6 @@ public: built-in tokens. */ location_t builtin_location; - /* True if we've seen a #line or # 44 "file" directive. */ - bool seen_line_directive; - /* The default value of range_bits in ordinary line maps. */ unsigned int default_range_bits; @@ -1816,16 +1818,16 @@ protected: int m_column_override; bool m_have_expanded_location; + bool m_seen_impossible_fixit; + bool m_fixits_cannot_be_auto_applied; + bool m_escape_on_output; + expanded_location m_expanded_location; static const int MAX_STATIC_FIXIT_HINTS = 2; semi_embedded_vec <fixit_hint *, MAX_STATIC_FIXIT_HINTS> m_fixit_hints; - bool m_seen_impossible_fixit; - bool m_fixits_cannot_be_auto_applied; - const diagnostic_path *m_path; - bool m_escape_on_output; }; /* A struct for the result of range_label::get_text: a NUL-terminated buffer @@ -1836,15 +1838,37 @@ class label_text { public: label_text () - : m_buffer (NULL), m_caller_owned (false) + : m_buffer (NULL), m_owned (false) {} - void maybe_free () + ~label_text () { - if (m_caller_owned) + if (m_owned) free (m_buffer); } + /* Move ctor. */ + label_text (label_text &&other) + : m_buffer (other.m_buffer), m_owned (other.m_owned) + { + other.release (); + } + + /* Move assignment. */ + label_text & operator= (label_text &&other) + { + if (m_owned) + free (m_buffer); + m_buffer = other.m_buffer; + m_owned = other.m_owned; + other.release (); + return *this; + } + + /* Delete the copy ctor and copy-assignment operator. */ + label_text (const label_text &) = delete; + label_text & operator= (const label_text &) = delete; + /* Create a label_text instance that borrows BUFFER from a longer-lived owner. */ static label_text borrow (const char *buffer) @@ -1858,21 +1882,28 @@ public: return label_text (buffer, true); } - /* Take ownership of the buffer, copying if necessary. */ - char *take_or_copy () + void release () { - if (m_caller_owned) - return m_buffer; - else - return xstrdup (m_buffer); + m_buffer = NULL; + m_owned = false; } - char *m_buffer; - bool m_caller_owned; + const char *get () const + { + return m_buffer; + } + + bool is_owner () const + { + return m_owned; + } private: + char *m_buffer; + bool m_owned; + label_text (char *buffer, bool owned) - : m_buffer (buffer), m_caller_owned (owned) + : m_buffer (buffer), m_owned (owned) {} }; |