/* Part of CPP library. (Precompiled header reading/writing.)
- Copyright (C) 2000-2015 Free Software Foundation, Inc.
+ Copyright (C) 2000-2020 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
write_macdef (cpp_reader *pfile, cpp_hashnode *hn, void *file_p)
{
FILE *f = (FILE *) file_p;
+ bool is_void = false;
switch (hn->type)
{
case NT_VOID:
if (! (hn->flags & NODE_POISONED))
return 1;
+ is_void = true;
+ goto poisoned;
- case NT_MACRO:
- if ((hn->flags & NODE_BUILTIN)
- && (!pfile->cb.user_builtin_macro
- || !pfile->cb.user_builtin_macro (pfile, hn)))
- return 1;
-
- {
- struct macrodef_struct s;
- const unsigned char *defn;
+ case NT_BUILTIN_MACRO:
+ return 1;
- s.name_length = NODE_LEN (hn);
- s.flags = hn->flags & NODE_POISONED;
+ case NT_USER_MACRO:
+ if (hn->value.macro->kind != cmk_assert)
+ {
+ poisoned:
+ struct macrodef_struct s;
+ const unsigned char *defn;
- if (hn->type == NT_MACRO)
- {
- defn = cpp_macro_definition (pfile, hn);
- s.definition_length = ustrlen (defn);
- }
- else
- {
- defn = NODE_NAME (hn);
- s.definition_length = s.name_length;
- }
+ s.name_length = NODE_LEN (hn);
+ s.flags = hn->flags & NODE_POISONED;
- if (fwrite (&s, sizeof (s), 1, f) != 1
- || fwrite (defn, 1, s.definition_length, f) != s.definition_length)
- {
- cpp_errno (pfile, CPP_DL_ERROR,
- "while writing precompiled header");
- return 0;
- }
- }
- return 1;
+ if (is_void)
+ {
+ defn = NODE_NAME (hn);
+ s.definition_length = s.name_length;
+ }
+ else
+ {
+ defn = cpp_macro_definition (pfile, hn);
+ s.definition_length = ustrlen (defn);
+ }
- case NT_ASSERTION:
- /* Not currently implemented. */
+ if (fwrite (&s, sizeof (s), 1, f) != 1
+ || fwrite (defn, 1, s.definition_length, f) != s.definition_length)
+ {
+ cpp_errno (pfile, CPP_DL_ERROR,
+ "while writing precompiled header");
+ return 0;
+ }
+ }
return 1;
default:
switch (hn->type)
{
- case NT_MACRO:
- if (hn->flags & NODE_BUILTIN)
+ case NT_BUILTIN_MACRO:
+ return 1;
+
+ case NT_USER_MACRO:
+ if (hn->value.macro->kind == cmk_assert)
return 1;
- /* else fall through. */
+ /* fall through. */
case NT_VOID:
{
}
return 1;
- case NT_ASSERTION:
- /* Not currently implemented. */
- return 1;
-
default:
abort ();
}
switch (hn->type)
{
- case NT_MACRO:
- if (hn->flags & NODE_BUILTIN)
+ case NT_BUILTIN_MACRO:
+ return 1;
+
+ case NT_USER_MACRO:
+ if (hn->value.macro->kind == cmk_assert)
return 1;
- /* else fall through. */
+ /* fall through. */
case NT_VOID:
{
}
return 1;
- case NT_ASSERTION:
- /* Not currently implemented. */
- return 1;
-
default:
abort ();
}
return 0;
p->definition = defn;
- if (fread (&(p->line), sizeof (source_location), 1, f) != 1)
+ if (fread (&(p->line), sizeof (location_t), 1, f) != 1)
return 0;
defnlen = 0;
if (fread (&defnlen, sizeof (defnlen), 1, f) != 1)
if (fwrite (&defnlen, sizeof (size_t), 1, f) != 1
|| fwrite (pp[i]->definition, defnlen, 1, f) != 1)
return 0;
- if (fwrite (&(pp[i]->line), sizeof (source_location), 1, f) != 1)
+ if (fwrite (&(pp[i]->line), sizeof (location_t), 1, f) != 1)
return 0;
defnlen = 0;
defnlen |= (pp[i]->syshdr != 0 ? 1 : 0);
goto fail;
}
- if (h->type != NT_MACRO)
+ if (h->type == NT_VOID)
{
/* It's ok if __GCC_HAVE_DWARF2_CFI_ASM becomes undefined,
as in, when the PCH file is created with -g and we're
attempting to use it without -g. Restoring the PCH file
is supposed to bring in this definition *and* enable the
generation of call frame information, so that precompiled
- definitions that take this macro into accout, to decide
+ definitions that take this macro into account, to decide
what asm to emit, won't issue .cfi directives when the
compiler doesn't. */
if (!(h->flags & NODE_USED)
cpp_warning_syshdr (r, CPP_W_INVALID_PCH,
"%s: not used because `__COUNTER__' is invalid",
name);
- goto fail;
+ goto fail;
}
/* We win! */
{
struct save_macro_data *data = (struct save_macro_data *)data_p;
- if ((h->flags & NODE_BUILTIN)
- && h->type == NT_MACRO
- && r->cb.user_builtin_macro)
- r->cb.user_builtin_macro (r, h);
-
- if (h->type != NT_VOID
- && (h->flags & NODE_BUILTIN) == 0)
+ if (cpp_user_macro_p (h))
{
if (data->count == data->array_size)
{
data->defns = XRESIZEVEC (uchar *, data->defns, (data->array_size));
}
- switch (h->type)
- {
- case NT_ASSERTION:
- /* Not currently implemented. */
- return 1;
-
- case NT_MACRO:
- {
- const uchar * defn = cpp_macro_definition (r, h);
- size_t defnlen = ustrlen (defn);
+ const uchar * defn = cpp_macro_definition (r, h);
+ size_t defnlen = ustrlen (defn);
- data->defns[data->count] = (uchar *) xmemdup (defn, defnlen,
- defnlen + 2);
- data->defns[data->count][defnlen] = '\n';
- }
- break;
-
- default:
- abort ();
- }
+ data->defns[data->count] = (uchar *) xmemdup (defn, defnlen, defnlen + 2);
+ data->defns[data->count][defnlen] = '\n';
data->count++;
}
+
return 1;
}
s->n_true = cpp_lookup (r, DSC("true"));
s->n_false = cpp_lookup (r, DSC("false"));
s->n__VA_ARGS__ = cpp_lookup (r, DSC("__VA_ARGS__"));
- s->n__has_include__ = cpp_lookup (r, DSC("__has_include__"));
- s->n__has_include_next__ = cpp_lookup (r, DSC("__has_include_next__"));
+ s->n__VA_OPT__ = cpp_lookup (r, DSC("__VA_OPT__"));
}
old_state = r->state;