diff options
Diffstat (limited to 'libcpp/include/cpplib.h')
-rw-r--r-- | libcpp/include/cpplib.h | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h index 75efdcd..5190ff7 100644 --- a/libcpp/include/cpplib.h +++ b/libcpp/include/cpplib.h @@ -435,6 +435,10 @@ struct cpp_options Presumably the usage is protected by the appropriate #ifdef. */ unsigned char warn_variadic_macros; + /* Non-zero means suppress diagnostics for NODE_WARN #define or #undef. + Used for cpp_define/cpp_undef. */ + unsigned char suppress_builtin_macro_warnings; + /* Nonzero means warn about builtin macros that are redefined or explicitly undefined. */ unsigned char warn_builtin_macro_redefined; @@ -620,6 +624,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 +764,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 +1258,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 *); @@ -1511,6 +1530,21 @@ extern cpp_comment_table *cpp_get_comments (cpp_reader *); extern cpp_hashnode *cpp_lookup (cpp_reader *, const unsigned char *, unsigned int); +/* Set NODE_WARN flag for NAME, such that there will be diagnostics + for #define or #undef of NAME. */ + +inline void +cpp_warn (cpp_reader *pfile, const char *name, unsigned int len) +{ + cpp_lookup (pfile, (const unsigned char *) name, len)->flags |= NODE_WARN; +} + +inline void +cpp_warn (cpp_reader *pfile, const char *name) +{ + cpp_warn (pfile, name, strlen (name)); +} + typedef int (*cpp_cb) (cpp_reader *, cpp_hashnode *, void *); extern void cpp_forall_identifiers (cpp_reader *, cpp_cb, void *); |