mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-20 17:53:02 +00:00
allow modification on retrieved code_props.
The logic to compute the %printer or %destructor to used (i.e., a code_props) is implemented twice: one, of course, in symbol_code_props_get, and another time in symbol_check_defined to record the fact that a code_props is used (so that we can reported unused ones). Let the former use the latter. I would probably use "mutable" in C++ and keep these guys const, but this is C. And casting away constness triggers warnings. * src/scan-code.h, src/scan-code.l (code_props_none): Is not const. * src/symtab.h, src/symtab.c (symbol_code_props_get): The symbol is not const. (symbol_check_defined): Use it.
This commit is contained in:
@@ -103,7 +103,7 @@ void code_props_none_init (code_props *self);
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Initialized by \c CODE_PROPS_NONE_INIT with no further modification. */
|
/** Initialized by \c CODE_PROPS_NONE_INIT with no further modification. */
|
||||||
extern code_props const code_props_none;
|
extern code_props code_props_none;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \pre
|
* \pre
|
||||||
|
|||||||
@@ -890,7 +890,7 @@ code_props_none_init (code_props *self)
|
|||||||
*self = code_props_none;
|
*self = code_props_none;
|
||||||
}
|
}
|
||||||
|
|
||||||
code_props const code_props_none = CODE_PROPS_NONE_INIT;
|
code_props code_props_none = CODE_PROPS_NONE_INIT;
|
||||||
|
|
||||||
void
|
void
|
||||||
code_props_plain_init (code_props *self, char const *code,
|
code_props_plain_init (code_props *self, char const *code,
|
||||||
|
|||||||
15
src/symtab.c
15
src/symtab.c
@@ -274,9 +274,8 @@ semantic_type_code_props_set (semantic_type *type,
|
|||||||
| Get the computed %destructor or %printer for SYM. |
|
| Get the computed %destructor or %printer for SYM. |
|
||||||
`---------------------------------------------------*/
|
`---------------------------------------------------*/
|
||||||
|
|
||||||
code_props const *
|
code_props *
|
||||||
symbol_code_props_get (symbol const *sym,
|
symbol_code_props_get (symbol *sym, code_props_type kind)
|
||||||
code_props_type kind)
|
|
||||||
{
|
{
|
||||||
/* Per-symbol code props. */
|
/* Per-symbol code props. */
|
||||||
if (sym->props[kind].code)
|
if (sym->props[kind].code)
|
||||||
@@ -285,7 +284,7 @@ symbol_code_props_get (symbol const *sym,
|
|||||||
/* Per-type code props. */
|
/* Per-type code props. */
|
||||||
if (sym->type_name)
|
if (sym->type_name)
|
||||||
{
|
{
|
||||||
code_props const *code =
|
code_props *code =
|
||||||
&semantic_type_get (sym->type_name, NULL)->props[kind];
|
&semantic_type_get (sym->type_name, NULL)->props[kind];
|
||||||
if (code->code)
|
if (code->code)
|
||||||
return code;
|
return code;
|
||||||
@@ -421,13 +420,7 @@ symbol_check_defined (symbol *sym)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 2; ++i)
|
for (int i = 0; i < 2; ++i)
|
||||||
if (sym->props[i].kind == CODE_PROPS_NONE && sym->type_name)
|
symbol_code_props_get (sym, i)->is_used = true;
|
||||||
{
|
|
||||||
semantic_type *sem_type = semantic_type_get (sym->type_name, NULL);
|
|
||||||
if (sem_type
|
|
||||||
&& sem_type->props[i].kind != CODE_PROPS_NONE)
|
|
||||||
sem_type->props[i].is_used = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set the semantic type status associated to the current symbol to
|
/* Set the semantic type status associated to the current symbol to
|
||||||
'declared' so that we could check semantic types unnecessary uses. */
|
'declared' so that we could check semantic types unnecessary uses. */
|
||||||
|
|||||||
@@ -181,8 +181,7 @@ void symbol_code_props_set (symbol *sym, code_props_type kind,
|
|||||||
/** Get the computed \c \%destructor or \c %printer for \c sym, which was
|
/** Get the computed \c \%destructor or \c %printer for \c sym, which was
|
||||||
initialized with \c code_props_none_init if there's no \c \%destructor or
|
initialized with \c code_props_none_init if there's no \c \%destructor or
|
||||||
\c %printer. */
|
\c %printer. */
|
||||||
code_props const *symbol_code_props_get (symbol const *sym,
|
code_props *symbol_code_props_get (symbol *sym, code_props_type kind);
|
||||||
code_props_type kind);
|
|
||||||
|
|
||||||
/** Set the \c precedence associated with \c sym.
|
/** Set the \c precedence associated with \c sym.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user