aboutsummaryrefslogtreecommitdiff
path: root/libcpp/include
diff options
context:
space:
mode:
Diffstat (limited to 'libcpp/include')
-rw-r--r--libcpp/include/cpplib.h20
-rw-r--r--libcpp/include/line-map.h19
-rw-r--r--libcpp/include/rich-location.h13
3 files changed, 42 insertions, 10 deletions
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
index 7c147ae..bbd88e5 100644
--- a/libcpp/include/cpplib.h
+++ b/libcpp/include/cpplib.h
@@ -620,6 +620,9 @@ struct cpp_options
/* True if -finput-charset= option has been used explicitly. */
bool cpp_input_charset_explicit;
+ /* True if -Wkeyword-macro. */
+ bool cpp_warn_keyword_macro;
+
/* -Wleading-whitespace= value. */
unsigned char cpp_warn_leading_whitespace;
@@ -757,7 +760,8 @@ enum cpp_warning_reason {
CPP_W_HEADER_GUARD,
CPP_W_PRAGMA_ONCE_OUTSIDE_HEADER,
CPP_W_LEADING_WHITESPACE,
- CPP_W_TRAILING_WHITESPACE
+ CPP_W_TRAILING_WHITESPACE,
+ CPP_W_KEYWORD_MACRO
};
/* Callback for header lookup for HEADER, which is the name of a
@@ -1250,6 +1254,17 @@ inline bool cpp_fun_like_macro_p (cpp_hashnode *node)
return cpp_user_macro_p (node) && node->value.macro->fun_like;
}
+/* Return true for nodes marked for -Wkeyword-macro diagnostics. */
+inline bool cpp_keyword_p (cpp_hashnode *node)
+{
+ /* As keywords are marked identifiers which don't start with underscore
+ or start with underscore followed by capital letter (except for
+ _Pragma). */
+ return ((node->flags & NODE_WARN)
+ && (NODE_NAME (node)[0] != '_'
+ || (NODE_NAME (node)[1] != '_' && NODE_NAME (node)[1] != 'P')));
+}
+
extern const unsigned char *cpp_macro_definition (cpp_reader *, cpp_hashnode *);
extern const unsigned char *cpp_macro_definition (cpp_reader *, cpp_hashnode *,
const cpp_macro *);
@@ -1610,7 +1625,8 @@ struct cpp_decoded_char
This is a tabstop value, along with a callback for getting the
widths of characters. Normally this callback is cpp_wcwidth, but we
support other schemes for escaping non-ASCII unicode as a series of
- ASCII chars when printing the user's source code in diagnostic-show-locus.cc
+ ASCII chars when printing the user's source code in
+ gcc/diagnostics/source-printing.cc
For example, consider:
- the Unicode character U+03C0 "GREEK SMALL LETTER PI" (UTF-8: 0xCF 0x80)
diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h
index 75cc1ad..21a59af 100644
--- a/libcpp/include/line-map.h
+++ b/libcpp/include/line-map.h
@@ -1111,6 +1111,10 @@ extern location_t linemap_module_loc
extern void linemap_module_reparent
(line_maps *, location_t loc, location_t new_parent);
+/* TRUE iff the location comes from a module import. */
+extern bool linemap_location_from_module_p
+ (const line_maps *, location_t);
+
/* Restore the linemap state such that the map at LWM-1 continues.
Return start location of the new map. */
extern location_t linemap_module_restore
@@ -1280,7 +1284,7 @@ linemap_location_before_p (const line_maps *set,
return linemap_compare_locations (set, loc_a, loc_b) >= 0;
}
-typedef struct
+struct expanded_location
{
/* The name of the source file involved. */
const char *file;
@@ -1294,7 +1298,18 @@ typedef struct
/* In a system header?. */
bool sysp;
-} expanded_location;
+};
+
+extern bool
+operator== (const expanded_location &a,
+ const expanded_location &b);
+inline bool
+operator!= (const expanded_location &a,
+ const expanded_location &b)
+{
+ return !(a == b);
+}
+
/* This is enum is used by the function linemap_resolve_location
below. The meaning of the values is explained in the comment of
diff --git a/libcpp/include/rich-location.h b/libcpp/include/rich-location.h
index fe9868d..c74e80e 100644
--- a/libcpp/include/rich-location.h
+++ b/libcpp/include/rich-location.h
@@ -25,7 +25,7 @@ along with this program; see the file COPYING3. If not see
#include "label-text.h"
class range_label;
-class label_effects;
+namespace diagnostics { class label_effects; }
/* A hint to diagnostic_show_locus on how to print a source range within a
rich_location.
@@ -213,7 +213,7 @@ semi_embedded_vec<T, NUM_EMBEDDED>::truncate (int len)
}
class fixit_hint;
-class diagnostic_path;
+namespace diagnostics { namespace paths { class path; }}
/* A "rich" source code location, for use when printing diagnostics.
A rich_location has one or more carets&ranges, where the carets
@@ -520,8 +520,8 @@ class rich_location
}
/* An optional path through the code. */
- const diagnostic_path *get_path () const { return m_path; }
- void set_path (const diagnostic_path *path) { m_path = path; }
+ const diagnostics::paths::path *get_path () const { return m_path; }
+ void set_path (const diagnostics::paths::path *path) { m_path = path; }
/* A flag for hinting that the diagnostic involves character encoding
issues, and thus that it will be helpful to the user if we show some
@@ -567,7 +567,7 @@ protected:
static const int MAX_STATIC_FIXIT_HINTS = 2;
semi_embedded_vec <fixit_hint *, MAX_STATIC_FIXIT_HINTS> m_fixit_hints;
- const diagnostic_path *m_path;
+ const diagnostics::paths::path *m_path;
};
/* Abstract base class for labelling a range within a rich_location
@@ -596,7 +596,8 @@ class range_label
virtual label_text get_text (unsigned range_idx) const = 0;
/* Get any special effects for the label (e.g. links to other labels). */
- virtual const label_effects *get_effects (unsigned /*range_idx*/) const
+ virtual const diagnostics::label_effects *
+ get_effects (unsigned /*range_idx*/) const
{
return nullptr;
}