preprocessed source. */
line_map_ordinary *last = LINEMAPS_LAST_ORDINARY_MAP (pfile->line_table);
if (!ORDINARY_MAP_STARTING_LINE_NUMBER (last)
+ && 0 == filename_cmp (to_file, ORDINARY_MAP_FILE_NAME (last))
&& SOURCE_LINE (last, pfile->line_table->highest_line) == 2)
{
ord_map = last;
{
skip = !_cpp_defined_macro_p (node);
_cpp_mark_macro_used (node);
- _cpp_maybe_notify_macro_use (pfile, node);
+ _cpp_maybe_notify_macro_use (pfile, node, pfile->directive_line);
if (pfile->cb.used)
pfile->cb.used (pfile, pfile->directive_line, node);
check_eol (pfile, false);
if (node)
{
- /* Do not treat conditional macros as being defined. This is due to
- the powerpc port using conditional macros for 'vector', 'bool',
- and 'pixel' to act as conditional keywords. This messes up tests
- like #ifndef bool. */
skip = _cpp_defined_macro_p (node);
_cpp_mark_macro_used (node);
- _cpp_maybe_notify_macro_use (pfile, node);
+ _cpp_maybe_notify_macro_use (pfile, node, pfile->directive_line);
if (pfile->cb.used)
pfile->cb.used (pfile, pfile->directive_line, node);
check_eol (pfile, false);
}
/* In macro.c */
-extern void _cpp_notify_macro_use (cpp_reader *pfile, cpp_hashnode *node);
-inline void _cpp_maybe_notify_macro_use (cpp_reader *pfile, cpp_hashnode *node)
+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,
+ location_t loc)
{
if (!(node->flags & NODE_USED))
- _cpp_notify_macro_use (pfile, node);
+ _cpp_notify_macro_use (pfile, node, loc);
}
extern cpp_macro *_cpp_new_macro (cpp_reader *, cpp_macro_kind, void *);
extern void _cpp_free_definition (cpp_hashnode *);
static cpp_macro *lex_expansion_token (cpp_reader *, cpp_macro *);
static bool warn_of_redefinition (cpp_reader *, cpp_hashnode *,
const cpp_macro *);
+static bool compare_macros (const cpp_macro *, const cpp_macro *);
+
static bool parse_params (cpp_reader *, unsigned *, bool *);
static void check_trad_stringification (cpp_reader *, const cpp_macro *,
const cpp_string *);
/* Laziness can only affect the expansion tokens of the macro,
not its fun-likeness or parameters. */
- _cpp_maybe_notify_macro_use (pfile, node);
+ _cpp_maybe_notify_macro_use (pfile, node, location);
if (pfile->cb.used)
pfile->cb.used (pfile, location, node);
macro1->lazy = 0;
}
+ return compare_macros (macro1, macro2);
+}
+
+/* Return TRUE if MACRO1 and MACRO2 differ. */
+
+static bool
+compare_macros (const cpp_macro *macro1, const cpp_macro *macro2)
+{
/* Redefinition of a macro is allowed if and only if the old and new
definitions are the same. (6.10.3 paragraph 2). */
{
cpp_macro *macro = (cpp_macro *) placement;
+ /* Zero init all the fields. This'll tell the compiler know all the
+ following inits are writing a virgin object. */
+ memset (macro, 0, offsetof (cpp_macro, exp));
+
macro->line = pfile->directive_line;
macro->parm.params = 0;
macro->lazy = 0;
}
/* Notify the use of NODE in a macro-aware context (i.e. expanding it,
- or testing its existance). Also applies any lazy definition. */
+ or testing its existance). Also applies any lazy definition.
+ Return FALSE if the macro isn't really there. */
extern void
-_cpp_notify_macro_use (cpp_reader *pfile, cpp_hashnode *node)
+_cpp_notify_macro_use (cpp_reader *pfile, cpp_hashnode *node,
+ location_t loc)
{
node->flags |= NODE_USED;
switch (node->type)
case NT_BUILTIN_MACRO:
if (pfile->cb.used_define)
- pfile->cb.used_define (pfile, pfile->directive_line, node);
+ pfile->cb.used_define (pfile, loc, node);
break;
case NT_VOID:
if (pfile->cb.used_undef)
- pfile->cb.used_undef (pfile, pfile->directive_line, node);
+ pfile->cb.used_undef (pfile, loc, node);
break;
default: