Merge remote-tracking branch 'origin/maint'

* origin/maint:
  package: install the examples
  package: install README and the like in docdir
  diagnostics: fix the order of multiple declarations reports
  symbol: provide an easy means to compare them in source order

Conflicts:
  src/symtab.c
  tests/input.at

* tests/input.at: Comment out a test that master currently does not
pass (because of a728075710).
This commit is contained in:
Akim Demaille
2013-12-10 08:49:49 +01:00
10 changed files with 232 additions and 64 deletions

View File

@@ -138,6 +138,42 @@ symbol_free (void *ptr)
if (!sym->is_alias)
sym_content_free (sym->content);
free (sym);
}
/* If needed, swap first and second so that first has the earliest
location (according to location_cmp).
Many symbol features (e.g., user token numbers) are not assigned
during the parsing, but in a second step, via a traversal of the
symbol table sorted on tag.
However, error messages make more sense if we keep the first
declaration first.
*/
static
void symbols_sort (symbol **first, symbol **second)
{
if (0 < location_cmp ((*first)->location, (*second)->location))
{
symbol* tmp = *first;
*first = *second;
*second = tmp;
}
}
/* Likewise, for locations. */
static
void locations_sort (location *first, location *second)
{
if (0 < location_cmp (*first, *second))
{
location tmp = *first;
*first = *second;
*second = tmp;
}
}
char const *
@@ -250,6 +286,7 @@ symbol_redeclaration (symbol *s, const char *what, location first,
location second)
{
unsigned i = 0;
locations_sort (&first, &second);
complain_indent (&second, complaint, &i,
_("%s redeclaration for %s"), what, s->tag);
i += SUB_INDENT;
@@ -262,6 +299,7 @@ semantic_type_redeclaration (semantic_type *s, const char *what, location first,
location second)
{
unsigned i = 0;
locations_sort (&first, &second);
complain_indent (&second, complaint, &i,
_("%s redeclaration for <%s>"), what, s->tag);
i += SUB_INDENT;
@@ -570,17 +608,7 @@ static void
user_token_number_redeclaration (int num, symbol *first, symbol *second)
{
unsigned i = 0;
/* User token numbers are not assigned during the parsing, but in a
second step, via a traversal of the symbol table sorted on tag.
However, error messages make more sense if we keep the first
declaration first. */
if (location_cmp (first->location, second->location) > 0)
{
symbol* tmp = first;
first = second;
second = tmp;
}
symbols_sort (&first, &second);
complain_indent (&second->location, complaint, &i,
_("user token number %d redeclaration for %s"),
num, second->tag);