/* Nonzero when tokenizing a deferred pragma. */
unsigned char in_deferred_pragma;
+ /* Count to token that is a header-name. */
+ unsigned char directive_file_token;
+
/* Nonzero if the deferred pragma being handled allows macro expansion. */
unsigned char pragma_allow_expansion;
};
cpp_hashnode *n_false; /* C++ keyword false */
cpp_hashnode *n__VA_ARGS__; /* C99 vararg macros */
cpp_hashnode *n__VA_OPT__; /* C++ vararg macros */
+
+ enum {M_EXPORT, M_MODULE, M_IMPORT, M__IMPORT, M_HWM};
+
+ /* C++20 modules, only set when module_directives is in effect.
+ incoming variants [0], outgoing ones [1] */
+ cpp_hashnode *n_modules[M_HWM][2];
};
typedef struct _cpp_line_note _cpp_line_note;
/* If non-zero, the lexer will use this location for the next token
instead of getting a location from the linemap. */
location_t forced_token_location;
+
+ /* Location identifying the main source file -- intended to be line
+ zero of said file. */
+ location_t main_loc;
};
/* Character classes. Based on the more primitive macros in safe-ctype.h.
#define UC (const uchar *) /* Intended use: UC"string" */
-/* Macros. */
+/* Accessors. */
-static inline int cpp_in_system_header (cpp_reader *);
-static inline int
-cpp_in_system_header (cpp_reader *pfile)
+inline int
+_cpp_in_system_header (cpp_reader *pfile)
{
return pfile->buffer ? pfile->buffer->sysp : 0;
}
#define CPP_PEDANTIC(PF) CPP_OPTION (PF, cpp_pedantic)
#define CPP_WTRADITIONAL(PF) CPP_OPTION (PF, cpp_warn_traditional)
-static inline int cpp_in_primary_file (cpp_reader *);
-static inline int
-cpp_in_primary_file (cpp_reader *pfile)
+/* Return true if we're in the main file (unless it's considered to be
+ an include file in its own right. */
+inline int
+_cpp_in_main_source_file (cpp_reader *pfile)
{
- return pfile->line_table->depth == 1;
+ return (!CPP_OPTION (pfile, main_search)
+ && pfile->buffer->file == pfile->main_file);
}
/* True if NODE is a macro for the purposes of ifdef, defined etc. */
}
/* In macro.c */
-extern void _cpp_notify_macro_use (cpp_reader *pfile, cpp_hashnode *node,
- location_t loc);
-inline void _cpp_maybe_notify_macro_use (cpp_reader *pfile, cpp_hashnode *node,
+extern bool _cpp_notify_macro_use (cpp_reader *pfile, cpp_hashnode *node,
+ location_t);
+inline bool _cpp_maybe_notify_macro_use (cpp_reader *pfile, cpp_hashnode *node,
location_t loc)
{
if (!(node->flags & NODE_USED))
- _cpp_notify_macro_use (pfile, node, loc);
+ return _cpp_notify_macro_use (pfile, node, loc);
+ return true;
}
extern cpp_macro *_cpp_new_macro (cpp_reader *, cpp_macro_kind, void *);
extern void _cpp_free_definition (cpp_hashnode *);