mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-17 16:23:04 +00:00
errors: pointerize complain_at_indent
* src/complain.c (complain_at_indent): Rename as... (complaint_indent): This, and take the location as a pointer. * src/complain.h, src/muscle-tab.c, src/reader.c, src/scan-code.l, src/symtab.c: Adjust. Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
This commit is contained in:
committed by
Akim Demaille
parent
9ec79612e8
commit
b999409e09
@@ -50,7 +50,7 @@ XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
|
|||||||
--from-code=UTF-8\\\
|
--from-code=UTF-8\\\
|
||||||
--flag=asprintf:2:c-format\\\
|
--flag=asprintf:2:c-format\\\
|
||||||
--flag=complain:3:c-format\\\
|
--flag=complain:3:c-format\\\
|
||||||
--flag=complain_at_indent:4:c-format\\\
|
--flag=complain_indent:4:c-format\\\
|
||||||
--flag=unexpected_end:2:c-format\\\
|
--flag=unexpected_end:2:c-format\\\
|
||||||
'
|
'
|
||||||
XGETTEXT_OPTIONS_RUNTIME=$XGETTEXT_OPTIONS'\\\
|
XGETTEXT_OPTIONS_RUNTIME=$XGETTEXT_OPTIONS'\\\
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ complains (const location *loc, warnings flags, const char *message,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
complain (location const* loc, warnings flags, const char *message, ...)
|
complain (location const *loc, warnings flags, const char *message, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start (args, message);
|
va_start (args, message);
|
||||||
@@ -148,13 +148,13 @@ complain (location const* loc, warnings flags, const char *message, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
complain_at_indent (location loc, warnings flags, unsigned *indent,
|
complain_indent (location const *loc, warnings flags, unsigned *indent,
|
||||||
const char *message, ...)
|
const char *message, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
indent_ptr = indent;
|
indent_ptr = indent;
|
||||||
va_start (args, message);
|
va_start (args, message);
|
||||||
complains (&loc, flags, message, args);
|
complains (loc, flags, message, args);
|
||||||
va_end (args);
|
va_end (args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,15 +58,15 @@ extern warnings errors_flag;
|
|||||||
void warnings_print_categories (warnings warn_flags);
|
void warnings_print_categories (warnings warn_flags);
|
||||||
|
|
||||||
/** Make a complaint, with maybe a location. */
|
/** Make a complaint, with maybe a location. */
|
||||||
void complain (location const* loc, warnings flags, char const *message, ...)
|
void complain (location const *loc, warnings flags, char const *message, ...)
|
||||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||||
|
|
||||||
/** Likewise, but with an \a argc/argv interface. */
|
/** Likewise, but with an \a argc/argv interface. */
|
||||||
void complain_args (location const *loc, warnings w, int argc, char *arg[]);
|
void complain_args (location const *loc, warnings w, int argc, char *arg[]);
|
||||||
|
|
||||||
/** Make a complaint with location and some indentation. */
|
/** Make a complaint with location and some indentation. */
|
||||||
void complain_at_indent (location loc, warnings flags, unsigned *indent,
|
void complain_indent (location const *loc, warnings flags, unsigned *indent,
|
||||||
char const *message, ...)
|
char const *message, ...)
|
||||||
__attribute__ ((__format__ (__printf__, 4, 5)));
|
__attribute__ ((__format__ (__printf__, 4, 5)));
|
||||||
|
|
||||||
/** Whether an error was reported. */
|
/** Whether an error was reported. */
|
||||||
|
|||||||
@@ -442,13 +442,12 @@ muscle_percent_define_insert (char const *variable, location variable_loc,
|
|||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
if (how_old == MUSCLE_PERCENT_DEFINE_F)
|
if (how_old == MUSCLE_PERCENT_DEFINE_F)
|
||||||
return;
|
return;
|
||||||
complain_at_indent (variable_loc, complaint, &i,
|
complain_indent (&variable_loc, complaint, &i,
|
||||||
_("%%define variable %s redefined"),
|
_("%%define variable %s redefined"),
|
||||||
quote (variable));
|
quote (variable));
|
||||||
i += SUB_INDENT;
|
i += SUB_INDENT;
|
||||||
complain_at_indent (muscle_percent_define_get_loc (variable),
|
location loc = muscle_percent_define_get_loc (variable);
|
||||||
complaint, &i,
|
complain_indent (&loc, complaint, &i, _("previous definition"));
|
||||||
_("previous definition"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MUSCLE_INSERT_STRING (name, value);
|
MUSCLE_INSERT_STRING (name, value);
|
||||||
@@ -606,14 +605,13 @@ muscle_percent_define_check_values (char const * const *values)
|
|||||||
{
|
{
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
location loc = muscle_percent_define_get_loc (*variablep);
|
location loc = muscle_percent_define_get_loc (*variablep);
|
||||||
complain_at_indent
|
complain_indent (&loc, complaint, &i,
|
||||||
(loc, complaint, &i,
|
_("invalid value for %%define variable %s: %s"),
|
||||||
_("invalid value for %%define variable %s: %s"),
|
quote (*variablep), quote_n (1, value));
|
||||||
quote (*variablep), quote_n (1, value));
|
|
||||||
i += SUB_INDENT;
|
i += SUB_INDENT;
|
||||||
for (values = variablep + 1; *values; ++values)
|
for (values = variablep + 1; *values; ++values)
|
||||||
complain_at_indent (loc, complaint, &i, _("accepted value: %s"),
|
complain_indent (&loc, complaint, &i, _("accepted value: %s"),
|
||||||
quote (*values));
|
quote (*values));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
16
src/reader.c
16
src/reader.c
@@ -129,15 +129,15 @@ record_merge_function_type (int merger, uniqstr type, location declaration_loc)
|
|||||||
if (merge_function->type != NULL && !UNIQSTR_EQ (merge_function->type, type))
|
if (merge_function->type != NULL && !UNIQSTR_EQ (merge_function->type, type))
|
||||||
{
|
{
|
||||||
unsigned indent = 0;
|
unsigned indent = 0;
|
||||||
complain_at_indent (declaration_loc, complaint, &indent,
|
complain_indent (&declaration_loc, complaint, &indent,
|
||||||
_("result type clash on merge function %s: "
|
_("result type clash on merge function %s: "
|
||||||
"<%s> != <%s>"),
|
"<%s> != <%s>"),
|
||||||
quote (merge_function->name), type,
|
quote (merge_function->name), type,
|
||||||
merge_function->type);
|
merge_function->type);
|
||||||
indent += SUB_INDENT;
|
indent += SUB_INDENT;
|
||||||
complain_at_indent (merge_function->type_declaration_location, complaint,
|
complain_indent (&merge_function->type_declaration_location, complaint,
|
||||||
&indent,
|
&indent,
|
||||||
_("previous declaration"));
|
_("previous declaration"));
|
||||||
}
|
}
|
||||||
merge_function->type = uniqstr_new (type);
|
merge_function->type = uniqstr_new (type);
|
||||||
merge_function->type_declaration_location = declaration_loc;
|
merge_function->type_declaration_location = declaration_loc;
|
||||||
|
|||||||
@@ -405,9 +405,9 @@ show_sub_message (const char* cp, bool explicit_bracketing,
|
|||||||
const char *at_spec = get_at_spec (var->symbol_index);
|
const char *at_spec = get_at_spec (var->symbol_index);
|
||||||
|
|
||||||
if (var->err == 0)
|
if (var->err == 0)
|
||||||
complain_at_indent (var->loc, silent, &indent,
|
complain_indent (&var->loc, silent, &indent,
|
||||||
_("refers to: %c%s at %s"), dollar_or_at,
|
_("refers to: %c%s at %s"), dollar_or_at,
|
||||||
var->id, at_spec);
|
var->id, at_spec);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
static struct obstack msg_buf;
|
static struct obstack msg_buf;
|
||||||
@@ -442,8 +442,8 @@ show_sub_message (const char* cp, bool explicit_bracketing,
|
|||||||
_(", cannot be accessed from mid-rule action at $%d"),
|
_(", cannot be accessed from mid-rule action at $%d"),
|
||||||
midrule_rhs_index);
|
midrule_rhs_index);
|
||||||
|
|
||||||
complain_at_indent (id_loc, silent, &indent, "%s",
|
complain_indent (&id_loc, silent, &indent, "%s",
|
||||||
obstack_finish0 (&msg_buf));
|
obstack_finish0 (&msg_buf));
|
||||||
obstack_free (&msg_buf, 0);
|
obstack_free (&msg_buf, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -586,28 +586,28 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
|
|||||||
cp_end - cp : ref_tail_fields - cp;
|
cp_end - cp : ref_tail_fields - cp;
|
||||||
unsigned indent = 0;
|
unsigned indent = 0;
|
||||||
|
|
||||||
complain_at_indent (text_loc, complaint, &indent,
|
complain_indent (&text_loc, complaint, &indent,
|
||||||
_("invalid reference: %s"), quote (text));
|
_("invalid reference: %s"), quote (text));
|
||||||
indent += SUB_INDENT;
|
indent += SUB_INDENT;
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
{
|
{
|
||||||
location sym_loc = text_loc;
|
location sym_loc = text_loc;
|
||||||
sym_loc.start.column += 1;
|
sym_loc.start.column += 1;
|
||||||
sym_loc.end = sym_loc.start;
|
sym_loc.end = sym_loc.start;
|
||||||
complain_at_indent (sym_loc, complaint, &indent,
|
complain_indent (&sym_loc, complaint, &indent,
|
||||||
_("syntax error after '%c', expecting integer, "
|
_("syntax error after '%c', expecting integer, "
|
||||||
"letter, '_', '[', or '$'"),
|
"letter, '_', '[', or '$'"),
|
||||||
dollar_or_at);
|
dollar_or_at);
|
||||||
}
|
}
|
||||||
else if (midrule_rhs_index)
|
else if (midrule_rhs_index)
|
||||||
complain_at_indent (rule->location, complaint, &indent,
|
complain_indent (&rule->location, complaint, &indent,
|
||||||
_("symbol not found in production before $%d: "
|
_("symbol not found in production before $%d: "
|
||||||
"%.*s"),
|
"%.*s"),
|
||||||
midrule_rhs_index, len, cp);
|
midrule_rhs_index, len, cp);
|
||||||
else
|
else
|
||||||
complain_at_indent (rule->location, complaint, &indent,
|
complain_indent (&rule->location, complaint, &indent,
|
||||||
_("symbol not found in production: %.*s"),
|
_("symbol not found in production: %.*s"),
|
||||||
len, cp);
|
len, cp);
|
||||||
|
|
||||||
if (variant_count > 0)
|
if (variant_count > 0)
|
||||||
show_sub_messages (cp, explicit_bracketing, midrule_rhs_index,
|
show_sub_messages (cp, explicit_bracketing, midrule_rhs_index,
|
||||||
@@ -619,8 +619,8 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
|
|||||||
unsigned indent = 0;
|
unsigned indent = 0;
|
||||||
if (variant_count > 1)
|
if (variant_count > 1)
|
||||||
{
|
{
|
||||||
complain_at_indent (text_loc, Wother, &indent,
|
complain_indent (&text_loc, Wother, &indent,
|
||||||
_("misleading reference: %s"), quote (text));
|
_("misleading reference: %s"), quote (text));
|
||||||
show_sub_messages (cp, explicit_bracketing, midrule_rhs_index,
|
show_sub_messages (cp, explicit_bracketing, midrule_rhs_index,
|
||||||
dollar_or_at, indent + SUB_INDENT);
|
dollar_or_at, indent + SUB_INDENT);
|
||||||
}
|
}
|
||||||
@@ -634,8 +634,8 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
|
|||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
unsigned indent = 0;
|
unsigned indent = 0;
|
||||||
complain_at_indent (text_loc, complaint, &indent,
|
complain_indent (&text_loc, complaint, &indent,
|
||||||
_("ambiguous reference: %s"), quote (text));
|
_("ambiguous reference: %s"), quote (text));
|
||||||
show_sub_messages (cp, explicit_bracketing, midrule_rhs_index,
|
show_sub_messages (cp, explicit_bracketing, midrule_rhs_index,
|
||||||
dollar_or_at, indent + SUB_INDENT);
|
dollar_or_at, indent + SUB_INDENT);
|
||||||
return INVALID_REF;
|
return INVALID_REF;
|
||||||
|
|||||||
28
src/symtab.c
28
src/symtab.c
@@ -194,11 +194,11 @@ symbol_redeclaration (symbol *s, const char *what, location first,
|
|||||||
location second)
|
location second)
|
||||||
{
|
{
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
complain_at_indent (second, complaint, &i,
|
complain_indent (&second, complaint, &i,
|
||||||
_("%s redeclaration for %s"), what, s->tag);
|
_("%s redeclaration for %s"), what, s->tag);
|
||||||
i += SUB_INDENT;
|
i += SUB_INDENT;
|
||||||
complain_at_indent (first, complaint, &i,
|
complain_indent (&first, complaint, &i,
|
||||||
_("previous declaration"));
|
_("previous declaration"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -206,11 +206,11 @@ semantic_type_redeclaration (semantic_type *s, const char *what, location first,
|
|||||||
location second)
|
location second)
|
||||||
{
|
{
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
complain_at_indent (second, complaint, &i,
|
complain_indent (&second, complaint, &i,
|
||||||
_("%s redeclaration for <%s>"), what, s->tag);
|
_("%s redeclaration for <%s>"), what, s->tag);
|
||||||
i += SUB_INDENT;
|
i += SUB_INDENT;
|
||||||
complain_at_indent (first, complaint, &i,
|
complain_indent (&first, complaint, &i,
|
||||||
_("previous declaration"));
|
_("previous declaration"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -566,13 +566,13 @@ user_token_number_redeclaration (int num, symbol *first, symbol *second)
|
|||||||
first = second;
|
first = second;
|
||||||
second = tmp;
|
second = tmp;
|
||||||
}
|
}
|
||||||
complain_at_indent (second->location, complaint, &i,
|
complain_indent (&second->location, complaint, &i,
|
||||||
_("user token number %d redeclaration for %s"),
|
_("user token number %d redeclaration for %s"),
|
||||||
num, second->tag);
|
num, second->tag);
|
||||||
i += SUB_INDENT;
|
i += SUB_INDENT;
|
||||||
complain_at_indent (first->location, complaint, &i,
|
complain_indent (&first->location, complaint, &i,
|
||||||
_("previous declaration for %s"),
|
_("previous declaration for %s"),
|
||||||
first->tag);
|
first->tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------.
|
/*--------------------------------------------------.
|
||||||
|
|||||||
Reference in New Issue
Block a user