static const cpp_token *get__Pragma_string (cpp_reader *);
static void destringize_and_run (cpp_reader *, const cpp_string *,
source_location);
-static bool parse_answer (cpp_reader *, int, source_location, struct answer **);
-static cpp_hashnode *parse_assertion (cpp_reader *, int, struct answer **);
-static struct answer ** find_answer (cpp_hashnode *, const struct answer *);
+static bool parse_answer (cpp_reader *, int, source_location, cpp_macro **);
+static cpp_hashnode *parse_assertion (cpp_reader *, int, cpp_macro **);
+static cpp_macro **find_answer (cpp_hashnode *, const cpp_macro *);
static void handle_assertion (cpp_reader *, const char *, int);
static void do_pragma_push_macro (cpp_reader *);
static void do_pragma_pop_macro (cpp_reader *);
predicate. */
static bool
parse_answer (cpp_reader *pfile, int type, source_location pred_loc,
- struct answer **answer_ptr)
+ cpp_macro **answer_ptr)
{
/* In a conditional, it is legal to not have an open paren. We
should save the following token in this case. */
return false;
}
- struct answer *answer
- = (struct answer *)_cpp_reserve_room (pfile, 0, sizeof (struct answer));
- answer->next = NULL;
+ cpp_macro *answer = _cpp_new_macro (pfile, cmk_assert,
+ _cpp_reserve_room (pfile, 0,
+ sizeof (cpp_macro)));
+ answer->parm.next = NULL;
unsigned count = 0;
for (;;)
{
return false;
}
- answer = (struct answer *)_cpp_reserve_room
- (pfile, sizeof (struct answer) + count * sizeof (cpp_token),
+ answer = (cpp_macro *)_cpp_reserve_room
+ (pfile, sizeof (cpp_macro) + count * sizeof (cpp_token),
sizeof (cpp_token));
- answer->exp[count++] = *token;
+ answer->exp.tokens[count++] = *token;
}
if (!count)
}
/* Drop whitespace at start, for answer equivalence purposes. */
- answer->exp[0].flags &= ~PREV_WHITE;
+ answer->exp.tokens[0].flags &= ~PREV_WHITE;
answer->count = count;
*answer_ptr = answer;
supplied, it is placed in EXP_PTR & EXP_COUNT, which is otherwise
set to 0. */
static cpp_hashnode *
-parse_assertion (cpp_reader *pfile, int type, struct answer **answer_ptr)
+parse_assertion (cpp_reader *pfile, int type, cpp_macro **answer_ptr)
{
cpp_hashnode *result = 0;
/* Returns a pointer to the pointer to CANDIDATE in the answer chain,
or a pointer to NULL if the answer is not in the chain. */
-static struct answer **
-find_answer (cpp_hashnode *node, const struct answer *candidate)
+static cpp_macro **
+find_answer (cpp_hashnode *node, const cpp_macro *candidate)
{
unsigned int i;
- struct answer **result;
+ cpp_macro **result;
- for (result = &node->value.answers; *result; result = &(*result)->next)
+ for (result = &node->value.macro; *result; result = &(*result)->parm.next)
{
- struct answer *answer = *result;
+ cpp_macro *answer = *result;
if (answer->count == candidate->count)
{
for (i = 0; i < answer->count; i++)
- if (!_cpp_equiv_tokens (&answer->exp[i], &candidate->exp[i]))
+ if (!_cpp_equiv_tokens (&answer->exp.tokens[i],
+ &candidate->exp.tokens[i]))
break;
if (i == answer->count)
int
_cpp_test_assertion (cpp_reader *pfile, unsigned int *value)
{
- struct answer *answer;
+ cpp_macro *answer;
cpp_hashnode *node = parse_assertion (pfile, T_IF, &answer);
/* For recovery, an erroneous assertion expression is handled as a
static void
do_assert (cpp_reader *pfile)
{
- struct answer *answer;
+ cpp_macro *answer;
cpp_hashnode *node = parse_assertion (pfile, T_ASSERT, &answer);
if (node)
{
- struct answer *next = NULL;
+ cpp_macro *next = NULL;
/* Place the new answer in the answer list. First check there
is not a duplicate. */
NODE_NAME (node) + 1);
return;
}
- next = node->value.answers;
+ next = node->value.macro;
}
/* Commit or allocate storage for the answer. */
- answer = (struct answer *)_cpp_commit_buff
- (pfile, sizeof (struct answer) - sizeof (cpp_token)
+ answer = (cpp_macro *)_cpp_commit_buff
+ (pfile, sizeof (cpp_macro) - sizeof (cpp_token)
+ sizeof (cpp_token) * answer->count);
- answer->next = next;
+ answer->parm.next = next;
node->type = NT_ASSERTION;
- node->value.answers = answer;
+ node->value.macro = answer;
check_eol (pfile, false);
}
do_unassert (cpp_reader *pfile)
{
cpp_hashnode *node;
- struct answer *answer;
+ cpp_macro *answer;
node = parse_assertion (pfile, T_UNASSERT, &answer);
/* It isn't an error to #unassert something that isn't asserted. */
{
if (answer)
{
- struct answer **p = find_answer (node, answer), *temp;
+ cpp_macro **p = find_answer (node, answer), *temp;
/* Remove the answer from the list. */
temp = *p;
if (temp)
- *p = temp->next;
+ *p = temp->parm.next;
/* Did we free the last answer? */
- if (node->value.answers == 0)
+ if (node->value.macro == 0)
node->type = NT_VOID;
check_eol (pfile, false);
typedef struct cpp_callbacks cpp_callbacks;
typedef struct cpp_dir cpp_dir;
-struct answer;
struct _cpp_file;
/* The first three groups, apart from '=', can appear in preprocessor
enum {
NTV_MACRO,
- NTV_ANSWER,
NTV_BUILTIN,
NTV_ARGUMENT,
NTV_NONE
((HNODE.flags & NODE_MACRO_ARG) ? NTV_ARGUMENT \
: HNODE.type == NT_MACRO ? ((HNODE.flags & NODE_BUILTIN) \
? NTV_BUILTIN : NTV_MACRO) \
- : HNODE.type == NT_ASSERTION ? NTV_ANSWER \
+ : HNODE.type == NT_ASSERTION ? NTV_MACRO \
: NTV_NONE)
/* The common part of an identifier node shared amongst all 3 C front
identifiers in the grammatical sense. */
union GTY(()) _cpp_hashnode_value {
- /* If a macro. */
+ /* Macro or assert */
cpp_macro * GTY((tag ("NTV_MACRO"))) macro;
- /* Answers to an assertion. */
- struct answer * GTY ((tag ("NTV_ANSWER"))) answers;
/* Code for a builtin macro. */
enum cpp_builtin_type GTY ((tag ("NTV_BUILTIN"))) builtin;
/* Macro argument index. */
extern const cpp_token *cpp_get_token (cpp_reader *);
extern const cpp_token *cpp_get_token_with_location (cpp_reader *,
source_location *);
-inline bool cpp_macro_p (cpp_hashnode *node, bool builtin_ok = false)
-{
- return (node->type == NT_MACRO
- && (builtin_ok || !(node->flags & NODE_BUILTIN)));
-}
+extern bool cpp_macro_p (cpp_hashnode *node, bool builtin_ok = false);
extern bool cpp_fun_like_macro_p (cpp_hashnode *);
extern const unsigned char *cpp_macro_definition (cpp_reader *,
cpp_hashnode *);