diff --git a/src/complain.c b/src/complain.c index fdc4b542..ac338d36 100644 --- a/src/complain.c +++ b/src/complain.c @@ -46,11 +46,28 @@ typedef enum } severity; +/** Struct to sort the warnings according to location. */ +typedef struct + { + location *loc; + char *message; + } warning; + +warning **warning_list; + +struct obstack obstack_warning; + +#define WARNING_LIST_INCREMENT 100 + +int warning_count = 0; + /** For each warning type, its severity. */ static severity warnings_flag[warnings_size]; static unsigned *indent_ptr = 0; +static const location *complain_loc; + /*------------------------. | --warnings's handling. | `------------------------*/ @@ -176,6 +193,9 @@ complain_init (void) warnings_flag[b] = (1 << b & warnings_default ? severity_warning : severity_unset); + + warning_list = xmalloc (WARNING_LIST_INCREMENT * sizeof (*warning_list)); + obstack_init (&obstack_warning); } static severity @@ -211,7 +231,7 @@ warning_is_unset (warnings flags) /** Display a "[-Wyacc]" like message on \a f. */ static void -warnings_print_categories (warnings warn_flags, FILE *f) +warnings_print_categories (warnings warn_flags, struct obstack *obs) { /* Display only the first match, the second is "-Wall". */ size_t i; @@ -219,13 +239,79 @@ warnings_print_categories (warnings warn_flags, FILE *f) if (warn_flags & warnings_types[i]) { severity s = warning_severity (warnings_types[i]); - fprintf (f, " [-W%s%s]", + obstack_printf (obs, " [-W%s%s]", s == severity_error ? "error=" : "", warnings_args[i]); return; } } +static void +start_error (const location *loc, warnings flags, const char *prefix, + const char *message, va_list args) +{ + unsigned pos = 0; + + if (loc) + pos += location_obstack_print (*loc, &obstack_warning); + else + pos += obstack_printf (&obstack_warning, "%s", current_file ? current_file + : program_name); + pos += obstack_printf (&obstack_warning, ": "); + + if (indent_ptr) + { + if (*indent_ptr) + prefix = NULL; + if (!*indent_ptr) + *indent_ptr = pos; + else if (*indent_ptr > pos) + obstack_printf (&obstack_warning, "%*s", *indent_ptr - pos, ""); + indent_ptr = 0; + } + + if (prefix) + obstack_printf (&obstack_warning, "%s: ", prefix); + + obstack_vprintf (&obstack_warning, message, args); + if (! (flags & silent)) + warnings_print_categories (flags, &obstack_warning); + { + size_t l = strlen (message); + if (l < 2 || message[l - 2] != ':' || message[l - 1] != ' ') + { + obstack_1grow (&obstack_warning, '\n'); + if (loc && feature_flag & feature_caret && !(flags & no_caret)) + location_obstack_caret (*loc, &obstack_warning); + } + } + + if (!complain_loc) + complain_loc = loc; +} + +void +finish_complaint (void) +{ + + if (!((warning_count + 1) % WARNING_LIST_INCREMENT)) + warning_list = xnrealloc (warning_list, warning_count + 1 + + WARNING_LIST_INCREMENT, sizeof (*warning_list)); + warning_list[warning_count] = xmalloc (sizeof **warning_list); + warning *w = warning_list[warning_count]; + if (complain_loc) + { + w->loc = xmalloc (sizeof *w->loc); + *w->loc = *complain_loc; + } + else + w->loc = NULL; + complain_loc = NULL; + w->message = obstack_finish0 (&obstack_warning); + warning_count ++; +} + + /** Report an error message. * * \param loc the location, defaulting to the current file, @@ -243,44 +329,38 @@ void error_message (const location *loc, warnings flags, const char *prefix, const char *message, va_list args) { - unsigned pos = 0; + start_error (loc, flags, prefix, message, args); + finish_complaint (); +} - if (loc) - pos += location_print (*loc, stderr); - else - pos += fprintf (stderr, "%s", current_file ? current_file : program_name); - pos += fprintf (stderr, ": "); - if (indent_ptr) +/** Start an error message, but don't conclude it. That can be a fatal error, + an error or just a warning. */ + +static void +start_complains (const location *loc, warnings flags, const char *message, + va_list args) +{ + severity s = warning_severity (flags); + if ((flags & complaint) && complaint_status < status_complaint) + complaint_status = status_complaint; + + if (severity_warning <= s) { - if (*indent_ptr) - prefix = NULL; - if (!*indent_ptr) - *indent_ptr = pos; - else if (*indent_ptr > pos) - fprintf (stderr, "%*s", *indent_ptr - pos, ""); - indent_ptr = 0; + const char* prefix = + s == severity_fatal ? _("fatal error") + : s == severity_error ? _("error") + : _("warning"); + if (severity_error <= s && ! complaint_status) + complaint_status = status_warning_as_error; + start_error (loc, flags, prefix, message, args); } - if (prefix) - fprintf (stderr, "%s: ", prefix); - - vfprintf (stderr, message, args); - if (! (flags & silent)) - warnings_print_categories (flags, stderr); - { - size_t l = strlen (message); - if (l < 2 || message[l - 2] != ':' || message[l - 1] != ' ') - { - putc ('\n', stderr); - fflush (stderr); - if (loc && feature_flag & feature_caret && !(flags & no_caret)) - location_caret (*loc, stderr); - } - } - fflush (stderr); + if (flags & fatal) + print_warnings_and_exit (stderr, EXIT_FAILURE); } + /** Raise a complaint. That can be a fatal error, an error or just a warning. */ @@ -304,7 +384,7 @@ complains (const location *loc, warnings flags, const char *message, } if (flags & fatal) - exit (EXIT_FAILURE); + print_warnings_and_exit (stderr, EXIT_FAILURE); } void @@ -316,6 +396,15 @@ complain (location const *loc, warnings flags, const char *message, ...) va_end (args); } +void +start_complain (location const *loc, warnings flags, const char *message, ...) +{ + va_list args; + va_start (args, message); + start_complains (loc, flags, message, args); + va_end (args); +} + void complain_indent (location const *loc, warnings flags, unsigned *indent, const char *message, ...) @@ -327,6 +416,17 @@ complain_indent (location const *loc, warnings flags, unsigned *indent, va_end (args); } +void +start_complain_indent (location const *loc, warnings flags, unsigned *indent, + const char *message, ...) +{ + va_list args; + indent_ptr = indent; + va_start (args, message); + start_complains (loc, flags, message, args); + va_end (args); +} + void complain_args (location const *loc, warnings w, unsigned *indent, int argc, char *argv[]) @@ -373,7 +473,45 @@ duplicate_directive (char const *directive, location first, location second) { unsigned i = 0; - complain (&second, complaint, _("only one %s allowed per rule"), directive); + start_complain (&second, complaint, _("only one %s allowed per rule"), directive); i += SUB_INDENT; complain_indent (&first, complaint, &i, _("previous declaration")); } + +/** Compare warnings, to sort them. */ +static int +warning_cmp (void const *a, void const *b) +{ + warning *wa = *(warning * const *)a, *wb = *(warning * const *)b; + if (wa->loc && wb->loc) + return location_cmp (*wa->loc, *wb->loc); + /* Undefined location/line number at the end. */ + else if (wa->loc) + return -1; + else if (wb->loc) + return 1; + return 0; +} + +void +print_warnings (FILE *f) +{ + if (obstack_object_size (&obstack_warning)) + finish_complaint (); + qsort (warning_list, warning_count, sizeof *warning_list, warning_cmp); + for (int i = 0; i < warning_count; ++i) + { + fprintf (f, "%s", warning_list[i]->message); + free (warning_list[i]->loc); + free (warning_list[i]); + } + free (warning_list); + obstack_free (&obstack_warning, NULL); +} + +void +print_warnings_and_exit (FILE *f, int exit_status) +{ + print_warnings (f); + exit (exit_status); +} diff --git a/src/complain.h b/src/complain.h index 0d81503d..ce4d168c 100644 --- a/src/complain.h +++ b/src/complain.h @@ -106,6 +106,12 @@ typedef enum (Never enabled, never disabled). */ bool warning_is_unset (warnings flags); +/** Start a complaint, with maybe a location, but don't finish it until a + normal complaint or a call to finish_complaint. */ +void start_complain (location const *loc, warnings flags, char const *message, + ...) + __attribute__ ((__format__ (__printf__, 3, 4))); + /** Make a complaint, with maybe a location. */ void complain (location const *loc, warnings flags, char const *message, ...) __attribute__ ((__format__ (__printf__, 3, 4))); @@ -114,11 +120,19 @@ void complain (location const *loc, warnings flags, char const *message, ...) void complain_args (location const *loc, warnings w, unsigned *indent, int argc, char *arg[]); +/** Start a complaint message with location and some indentation, but don't + finish it until a normal complaint or a call to finish_complaint. */ +void start_complain_indent (location const *loc, warnings flags, unsigned *indent, + char const *message, ...) + __attribute__ ((__format__ (__printf__, 4, 5))); + /** Make a complaint with location and some indentation. */ void complain_indent (location const *loc, warnings flags, unsigned *indent, char const *message, ...) __attribute__ ((__format__ (__printf__, 4, 5))); +/** Finish the current complaint. */ +void finish_complaint (void); /** Report an obsolete syntax, suggest the updated one. */ void deprecated_directive (location const *loc, @@ -141,4 +155,10 @@ typedef enum /** Whether an error was reported. */ extern err_status complaint_status; +/** Sort and print warnings, and free them. */ +void print_warnings (FILE *f); + +/** Sort and print warnings, free them, then exit. */ +void print_warnings_and_exit (FILE *f, int exit_status); + #endif /* !COMPLAIN_H_ */ diff --git a/src/location.c b/src/location.c index 662b2a12..d6ae6c51 100644 --- a/src/location.c +++ b/src/location.c @@ -137,6 +137,48 @@ location_print (location loc, FILE *out) } +unsigned +location_obstack_print (location loc, struct obstack *obs) +{ + unsigned res = 0; + int end_col = 0 != loc.end.column ? loc.end.column - 1 : 0; + res += obstack_printf (obs, "%s", + quotearg_n_style (3, escape_quoting_style, loc.start.file)); + if (0 <= loc.start.line) + { + res += obstack_printf (obs, ":%d", loc.start.line); + if (0 <= loc.start.column) + res += obstack_printf (obs, ".%d", loc.start.column); + } + if (loc.start.file != loc.end.file) + { + res += obstack_printf (obs, "-%s", + quotearg_n_style (3, escape_quoting_style, + loc.end.file)); + if (0 <= loc.end.line) + { + res += obstack_printf (obs, ":%d", loc.end.line); + if (0 <= end_col) + res += obstack_printf (obs, ".%d", end_col); + } + } + else if (0 <= loc.end.line) + { + if (loc.start.line < loc.end.line) + { + res += obstack_printf (obs, "-%d", loc.end.line); + if (0 <= end_col) + res += obstack_printf (obs, ".%d", end_col); + } + else if (0 <= end_col && loc.start.column < end_col) + res += obstack_printf (obs, "-%d", end_col); + } + + return res; +} + + + /* Persistant data used by location_caret to avoid reopening and rereading the same file all over for each error. */ struct caret_info @@ -215,6 +257,64 @@ location_caret (location loc, FILE *out) } } + +void +location_obstack_caret (location loc, struct obstack *obs) +{ + /* FIXME: find a way to support multifile locations, and only open once each + file. That would make the procedure future-proof. */ + if (! (caret_info.source + || (caret_info.source = fopen (loc.start.file, "r"))) + || loc.start.column == -1 || loc.start.line == -1) + return; + + /* If the line we want to quote is seekable (the same line as the previous + location), just seek it. If it was a previous line, we lost track of it, + so return to the start of file. */ + if (caret_info.line <= loc.start.line) + fseek (caret_info.source, caret_info.offset, SEEK_SET); + else + { + caret_info.line = 1; + caret_info.offset = 0; + fseek (caret_info.source, caret_info.offset, SEEK_SET); + } + + /* Advance to the line's position, keeping track of the offset. */ + while (caret_info.line < loc.start.line) + caret_info.line += getc (caret_info.source) == '\n'; + caret_info.offset = ftell (caret_info.source); + + /* Read the actual line. Don't update the offset, so that we keep a pointer + to the start of the line. */ + { + char c = getc (caret_info.source); + if (c != EOF) + { + /* Quote the file, indent by a single column. */ + obstack_1grow (obs, ' '); + do + obstack_1grow (obs, c); + while ((c = getc (caret_info.source)) != EOF && c != '\n'); + obstack_1grow (obs, '\n'); + + { + /* The caret of a multiline location ends with the first line. */ + size_t len = loc.start.line != loc.end.line + ? ftell (caret_info.source) - caret_info.offset + : loc.end.column; + int i; + + /* Print the carets (at least one), with the same indent as above.*/ + obstack_printf (obs, " %*s", loc.start.column - 1, ""); + for (i = loc.start.column; i == loc.start.column || i < len; ++i) + obstack_1grow (obs, '^'); + } + obstack_1grow (obs, '\n'); + } + } +} + void boundary_set_from_string (boundary *bound, char *loc_str) { diff --git a/src/location.h b/src/location.h index 9c6e53c1..c14e2cbd 100644 --- a/src/location.h +++ b/src/location.h @@ -24,6 +24,8 @@ # include # include /* strcmp */ +# include "system.h" + # include "uniqstr.h" /* A boundary between two characters. */ @@ -107,6 +109,9 @@ void location_compute (location *loc, Warning: uses quotearg's slot 3. */ unsigned location_print (location loc, FILE *out); +/* Same as location_print, only to an obstack. */ +unsigned location_obstack_print (location loc, struct obstack *obs); + /* Free any allocated ressources and close any open file handles that are left-over by the usage of location_caret. */ void cleanup_caret (void); @@ -114,6 +119,9 @@ void cleanup_caret (void); /* Output to OUT the line and caret corresponding to location LOC. */ void location_caret (location loc, FILE *out); +/* Same as location_caret, only with an obstack. */ +void location_obstack_caret (location loc, struct obstack *obs); + /* Return -1, 0, 1, depending whether a is before, equal, or after b. */ static inline int diff --git a/src/main.c b/src/main.c index aa8c7bfa..e2c34623 100644 --- a/src/main.c +++ b/src/main.c @@ -203,7 +203,6 @@ main (int argc, char *argv[]) contains things such as user actions, prologue, epilogue etc. */ gram_scanner_free (); muscle_free (); - uniqstrs_free (); code_scanner_free (); skel_scanner_free (); quotearg_free (); @@ -218,6 +217,9 @@ main (int argc, char *argv[]) timevar_stop (TV_TOTAL); timevar_print (stderr); + print_warnings (stderr); + + uniqstrs_free (); cleanup_caret (); return complaint_status ? EXIT_FAILURE : EXIT_SUCCESS; diff --git a/src/muscle-tab.c b/src/muscle-tab.c index cc5d01df..90784840 100644 --- a/src/muscle-tab.c +++ b/src/muscle-tab.c @@ -509,7 +509,7 @@ muscle_percent_define_insert (char const *var, location variable_loc, unsigned i = 0; if (how_old == MUSCLE_PERCENT_DEFINE_F) goto end; - complain_indent (&variable_loc, complaint, &i, + start_complain_indent (&variable_loc, complaint, &i, _("%%define variable %s redefined"), quote (variable)); i += SUB_INDENT; diff --git a/src/reader.c b/src/reader.c index aeee81ed..9e69252a 100644 --- a/src/reader.c +++ b/src/reader.c @@ -129,7 +129,7 @@ record_merge_function_type (int merger, uniqstr type, location declaration_loc) if (merge_function->type != NULL && !UNIQSTR_EQ (merge_function->type, type)) { unsigned indent = 0; - complain_indent (&declaration_loc, complaint, &indent, + start_complain_indent (&declaration_loc, complaint, &indent, _("result type clash on merge function %s: " "<%s> != <%s>"), quote (merge_function->name), type, diff --git a/src/scan-code.l b/src/scan-code.l index cced97bf..93994fcd 100644 --- a/src/scan-code.l +++ b/src/scan-code.l @@ -335,7 +335,7 @@ show_sub_message (warnings warning, const char *at_spec = get_at_spec (var->symbol_index); if (var->err == 0) - complain_indent (&var->loc, warning, &indent, + start_complain_indent (&var->loc, warning, &indent, _("refers to: %c%s at %s"), dollar_or_at, var->id, at_spec); else @@ -372,7 +372,7 @@ show_sub_message (warnings warning, _(", cannot be accessed from mid-rule action at $%d"), midrule_rhs_index); - complain_indent (&id_loc, warning, &indent, "%s", + start_complain_indent (&id_loc, warning, &indent, "%s", obstack_finish0 (&msg_buf)); obstack_free (&msg_buf, 0); } @@ -515,7 +515,7 @@ parse_ref (char *cp, symbol_list *rule, int rule_length, cp_end - cp : ref_tail_fields - cp; unsigned indent = 0; - complain_indent (&text_loc, complaint, &indent, + start_complain_indent (&text_loc, complaint, &indent, _("invalid reference: %s"), quote (text)); indent += SUB_INDENT; if (len == 0) @@ -523,18 +523,18 @@ parse_ref (char *cp, symbol_list *rule, int rule_length, location sym_loc = text_loc; sym_loc.start.column += 1; sym_loc.end = sym_loc.start; - complain_indent (&sym_loc, complaint, &indent, + start_complain_indent (&sym_loc, complaint, &indent, _("syntax error after '%c', expecting integer, " "letter, '_', '[', or '$'"), dollar_or_at); } else if (midrule_rhs_index) - complain_indent (&rule->location, complaint, &indent, + start_complain_indent (&rule->location, complaint, &indent, _("symbol not found in production before $%d: " "%.*s"), midrule_rhs_index, len, cp); else - complain_indent (&rule->location, complaint, &indent, + start_complain_indent (&rule->location, complaint, &indent, _("symbol not found in production: %.*s"), len, cp); @@ -542,6 +542,7 @@ parse_ref (char *cp, symbol_list *rule, int rule_length, show_sub_messages (complaint, cp, explicit_bracketing, midrule_rhs_index, dollar_or_at, indent); + finish_complaint (); return INVALID_REF; } case 1: @@ -549,11 +550,12 @@ parse_ref (char *cp, symbol_list *rule, int rule_length, unsigned indent = 0; if (variant_count > 1) { - complain_indent (&text_loc, Wother, &indent, + start_complain_indent (&text_loc, Wother, &indent, _("misleading reference: %s"), quote (text)); show_sub_messages (Wother, cp, explicit_bracketing, midrule_rhs_index, dollar_or_at, indent + SUB_INDENT); + finish_complaint (); } { unsigned symbol_index = @@ -565,11 +567,12 @@ parse_ref (char *cp, symbol_list *rule, int rule_length, default: { unsigned indent = 0; - complain_indent (&text_loc, complaint, &indent, + start_complain_indent (&text_loc, complaint, &indent, _("ambiguous reference: %s"), quote (text)); show_sub_messages (complaint, cp, explicit_bracketing, midrule_rhs_index, dollar_or_at, indent + SUB_INDENT); + finish_complaint (); return INVALID_REF; } } diff --git a/src/symtab.c b/src/symtab.c index f6761c4a..d07f8aca 100644 --- a/src/symtab.c +++ b/src/symtab.c @@ -250,7 +250,7 @@ symbol_redeclaration (symbol *s, const char *what, location first, location second) { unsigned i = 0; - complain_indent (&second, complaint, &i, + start_complain_indent (&second, complaint, &i, _("%s redeclaration for %s"), what, s->tag); i += SUB_INDENT; complain_indent (&first, complaint, &i, @@ -262,7 +262,7 @@ semantic_type_redeclaration (semantic_type *s, const char *what, location first, location second) { unsigned i = 0; - complain_indent (&second, complaint, &i, + start_complain_indent (&second, complaint, &i, _("%s redeclaration for <%s>"), what, s->tag); i += SUB_INDENT; complain_indent (&first, complaint, &i, @@ -581,7 +581,7 @@ user_token_number_redeclaration (int num, symbol *first, symbol *second) first = second; second = tmp; } - complain_indent (&second->location, complaint, &i, + start_complain_indent (&second->location, complaint, &i, _("user token number %d redeclaration for %s"), num, second->tag); i += SUB_INDENT; diff --git a/tests/actions.at b/tests/actions.at index 6c1ecbc1..526cb0d7 100644 --- a/tests/actions.at +++ b/tests/actions.at @@ -1385,8 +1385,8 @@ AT_BISON_OPTION_POPDEFS AT_BISON_CHECK([-o input.c input.y], 0,, [[input.y:24.70-72: warning: useless %destructor for type <*> [-Wother] input.y:24.70-72: warning: useless %printer for type <*> [-Wother] -input.y:33.3-23: warning: unset value: $$ [-Wother] input.y:32.3-23: warning: unused value: $3 [-Wother] +input.y:33.3-23: warning: unset value: $$ [-Wother] ]]) AT_BISON_CHECK([-fcaret -o input.c input.y], 0,, @@ -1396,12 +1396,12 @@ AT_BISON_CHECK([-fcaret -o input.c input.y], 0,, input.y:24.70-72: warning: useless %printer for type <*> [-Wother] %printer { fprintf (yyoutput, "<*> printer should not be called"); } <*> ^^^ -input.y:33.3-23: warning: unset value: $$ [-Wother] - { @$ = 4; } // Only used. - ^^^^^^^^^^^^^^^^^^^^^ input.y:32.3-23: warning: unused value: $3 [-Wother] { USE ($$); @$ = 3; } // Only set. ^^^^^^^^^^^^^^^^^^^^^ +input.y:33.3-23: warning: unset value: $$ [-Wother] + { @$ = 4; } // Only used. + ^^^^^^^^^^^^^^^^^^^^^ ]]) AT_COMPILE([input]) diff --git a/tests/conflicts.at b/tests/conflicts.at index bbb3f89d..44d9e491 100644 --- a/tests/conflicts.at +++ b/tests/conflicts.at @@ -243,18 +243,18 @@ f: B ]]) AT_BISON_CHECK([-Wprecedence -fcaret -o input.c input.y], 0, [], -[[input.y:7.1-9: warning: useless precedence and associativity for U [-Wprecedence] - %nonassoc U - ^^^^^^^^^ -input.y:6.1-6: warning: useless precedence and associativity for V [-Wprecedence] - %right V - ^^^^^^ +[[input.y:2.1-11: warning: useless precedence for Z [-Wprecedence] + %precedence Z + ^^^^^^^^^^^ input.y:5.1-5: warning: useless precedence and associativity for W [-Wprecedence] %left W ^^^^^ -input.y:2.1-11: warning: useless precedence for Z [-Wprecedence] - %precedence Z - ^^^^^^^^^^^ +input.y:6.1-6: warning: useless precedence and associativity for V [-Wprecedence] + %right V + ^^^^^^ +input.y:7.1-9: warning: useless precedence and associativity for U [-Wprecedence] + %nonassoc U + ^^^^^^^^^ ]]) AT_CLEANUP @@ -1006,8 +1006,8 @@ cond: ]]) AT_BISON_CHECK([-o input.c input.y], 0, [], -[[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr] -input.y:12.3-18: warning: rule useless in parser due to conflicts [-Wother] +[[input.y:12.3-18: warning: rule useless in parser due to conflicts [-Wother] +input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr] ]]) AT_CLEANUP @@ -1050,8 +1050,8 @@ id : '0'; ]]) AT_BISON_CHECK([-o input.c --report=all input.y], 0, [], -[[input.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr] -input.y:4.6-8: warning: rule useless in parser due to conflicts [-Wother] +[[input.y:4.6-8: warning: rule useless in parser due to conflicts [-Wother] +input.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr] ]]) # Check the contents of the report. @@ -1265,9 +1265,9 @@ e: e '+' e ]]) AT_BISON_CHECK([-Wall -o input.c input.y], 0, [], -[[input.y: warning: 4 shift/reduce conflicts [-Wconflicts-sr] -input.y:1.1-5: warning: useless precedence and associativity for '+' [-Wprecedence] +[[input.y:1.1-5: warning: useless precedence and associativity for '+' [-Wprecedence] input.y:2.1-5: warning: useless precedence and associativity for '*' [-Wprecedence] +input.y: warning: 4 shift/reduce conflicts [-Wconflicts-sr] ]]) AT_CLEANUP @@ -1369,15 +1369,15 @@ reported_conflicts: ]]) AT_BISON_CHECK([[--report=all input.y]], 0, [], -[[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr] -input.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr] -input.y:12.5-20: warning: rule useless in parser due to conflicts [-Wother] +[[input.y:12.5-20: warning: rule useless in parser due to conflicts [-Wother] input.y:20.5-20: warning: rule useless in parser due to conflicts [-Wother] input.y:21.4: warning: rule useless in parser due to conflicts [-Wother] input.y:25.13: warning: rule useless in parser due to conflicts [-Wother] input.y:25.16: warning: rule useless in parser due to conflicts [-Wother] input.y:31.5-7: warning: rule useless in parser due to conflicts [-Wother] input.y:32.4: warning: rule useless in parser due to conflicts [-Wother] +input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr] +input.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr] ]]) AT_CHECK([[cat input.output]], 0, @@ -1522,12 +1522,12 @@ AT_DATA([[input-keep.y]], AT_CHECK([[cat input.y >> input-keep.y]]) AT_BISON_CHECK([[input-keep.y]], 0, [], -[[input-keep.y: warning: 2 shift/reduce conflicts [-Wconflicts-sr] -input-keep.y: warning: 2 reduce/reduce conflicts [-Wconflicts-rr] -input-keep.y:22.4: warning: rule useless in parser due to conflicts [-Wother] +[[input-keep.y:22.4: warning: rule useless in parser due to conflicts [-Wother] input-keep.y:26.16: warning: rule useless in parser due to conflicts [-Wother] input-keep.y:32.5-7: warning: rule useless in parser due to conflicts [-Wother] input-keep.y:33.4: warning: rule useless in parser due to conflicts [-Wother] +input-keep.y: warning: 2 shift/reduce conflicts [-Wconflicts-sr] +input-keep.y: warning: 2 reduce/reduce conflicts [-Wconflicts-rr] ]]) AT_CLEANUP @@ -1705,9 +1705,9 @@ exp: 'a' | 'a'; ]]) AT_BISON_CHECK([[2.y]], [[0]], [], -[[2.y: warning: %expect-rr applies only to GLR parsers [-Wother] +[[2.y:3.12-14: warning: rule useless in parser due to conflicts [-Wother] +2.y: warning: %expect-rr applies only to GLR parsers [-Wother] 2.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr] -2.y:3.12-14: warning: rule useless in parser due to conflicts [-Wother] ]]) AT_CLEANUP diff --git a/tests/existing.at b/tests/existing.at index a1b95ac9..d6b8e660 100644 --- a/tests/existing.at +++ b/tests/existing.at @@ -426,7 +426,25 @@ dnl don't like even 'print $!4;'. [[LEX_GETLINE, '$', '!', YNUMBER, '*', YNUMBER, ';']], dnl BISON-STDERR -[[input.y:66.10: warning: empty rule without %empty [-Wempty-rule] +[[input.y:33.1-6: warning: useless associativity for ASSIGNOP, use %precedence [-Wprecedence] +input.y:37.1-5: warning: useless precedence and associativity for LEX_GETLINE [-Wprecedence] +input.y:38.1-9: warning: useless associativity for LEX_IN, use %precedence [-Wprecedence] +input.y:39.1-5: warning: useless associativity for FUNC_CALL, use %precedence [-Wprecedence] +input.y:39.1-5: warning: useless associativity for LEX_BUILTIN, use %precedence [-Wprecedence] +input.y:39.1-5: warning: useless associativity for LEX_LENGTH, use %precedence [-Wprecedence] +input.y:40.1-9: warning: useless precedence and associativity for ',' [-Wprecedence] +input.y:42.1-9: warning: useless precedence and associativity for APPEND_OP [-Wprecedence] +input.y:43.1-5: warning: useless associativity for CONCAT_OP, use %precedence [-Wprecedence] +input.y:44.1-5: warning: useless associativity for YNUMBER, use %precedence [-Wprecedence] +input.y:44.1-5: warning: useless associativity for YSTRING, use %precedence [-Wprecedence] +input.y:47.1-6: warning: useless associativity for '!', use %precedence [-Wprecedence] +input.y:47.1-6: warning: useless associativity for UNARY, use %precedence [-Wprecedence] +input.y:49.1-5: warning: useless associativity for INCREMENT, use %precedence [-Wprecedence] +input.y:49.1-5: warning: useless associativity for DECREMENT, use %precedence [-Wprecedence] +input.y:50.1-5: warning: useless associativity for '$', use %precedence [-Wprecedence] +input.y:51.1-5: warning: useless associativity for '(', use %precedence [-Wprecedence] +input.y:51.1-5: warning: useless precedence and associativity for ')' [-Wprecedence] +input.y:66.10: warning: empty rule without %empty [-Wempty-rule] input.y:169.8: warning: empty rule without %empty [-Wempty-rule] input.y:174.12: warning: empty rule without %empty [-Wempty-rule] input.y:179.13: warning: empty rule without %empty [-Wempty-rule] @@ -439,24 +457,6 @@ input.y:322.9: warning: empty rule without %empty [-Wempty-rule] ]AT_COND_CASE([[canonical LR]], [[input.y: warning: 265 shift/reduce conflicts [-Wconflicts-sr]]], [[input.y: warning: 65 shift/reduce conflicts [-Wconflicts-sr]]])[ -input.y:39.1-5: warning: useless associativity for FUNC_CALL, use %precedence [-Wprecedence] -input.y:44.1-5: warning: useless associativity for YNUMBER, use %precedence [-Wprecedence] -input.y:44.1-5: warning: useless associativity for YSTRING, use %precedence [-Wprecedence] -input.y:42.1-9: warning: useless precedence and associativity for APPEND_OP [-Wprecedence] -input.y:33.1-6: warning: useless associativity for ASSIGNOP, use %precedence [-Wprecedence] -input.y:43.1-5: warning: useless associativity for CONCAT_OP, use %precedence [-Wprecedence] -input.y:37.1-5: warning: useless precedence and associativity for LEX_GETLINE [-Wprecedence] -input.y:38.1-9: warning: useless associativity for LEX_IN, use %precedence [-Wprecedence] -input.y:49.1-5: warning: useless associativity for INCREMENT, use %precedence [-Wprecedence] -input.y:49.1-5: warning: useless associativity for DECREMENT, use %precedence [-Wprecedence] -input.y:39.1-5: warning: useless associativity for LEX_BUILTIN, use %precedence [-Wprecedence] -input.y:39.1-5: warning: useless associativity for LEX_LENGTH, use %precedence [-Wprecedence] -input.y:40.1-9: warning: useless precedence and associativity for ',' [-Wprecedence] -input.y:47.1-6: warning: useless associativity for '!', use %precedence [-Wprecedence] -input.y:47.1-6: warning: useless associativity for UNARY, use %precedence [-Wprecedence] -input.y:50.1-5: warning: useless associativity for '$', use %precedence [-Wprecedence] -input.y:51.1-5: warning: useless associativity for '(', use %precedence [-Wprecedence] -input.y:51.1-5: warning: useless precedence and associativity for ')' [-Wprecedence] ]], dnl LAST-STATE @@ -1395,7 +1395,13 @@ dnl INPUT [[]], dnl BISON-STDERR -[[input.y:128.12: warning: empty rule without %empty [-Wempty-rule] +[[input.y:53.1-6: warning: useless associativity for HASSIGN, use %precedence [-Wprecedence] +input.y:54.1-5: warning: useless associativity for HORELSE, use %precedence [-Wprecedence] +input.y:55.1-5: warning: useless associativity for HANDTHEN, use %precedence [-Wprecedence] +input.y:61.1-5: warning: useless associativity for HNOT, use %precedence [-Wprecedence] +input.y:68.1-5: warning: useless associativity for UNEAR, use %precedence [-Wprecedence] +input.y:72.1-5: warning: useless associativity for HQUA, use %precedence [-Wprecedence] +input.y:128.12: warning: empty rule without %empty [-Wempty-rule] input.y:137.10: warning: empty rule without %empty [-Wempty-rule] input.y:142.8: warning: empty rule without %empty [-Wempty-rule] input.y:161.15: warning: empty rule without %empty [-Wempty-rule] @@ -1422,12 +1428,6 @@ input.y:591.14: warning: empty rule without %empty [-Wempty-rule] input.y: warning: 144 reduce/reduce conflicts [-Wconflicts-rr]]], [[input.y: warning: 78 shift/reduce conflicts [-Wconflicts-sr] input.y: warning: 10 reduce/reduce conflicts [-Wconflicts-rr]]])[ -input.y:72.1-5: warning: useless associativity for HQUA, use %precedence [-Wprecedence] -input.y:53.1-6: warning: useless associativity for HASSIGN, use %precedence [-Wprecedence] -input.y:54.1-5: warning: useless associativity for HORELSE, use %precedence [-Wprecedence] -input.y:55.1-5: warning: useless associativity for HANDTHEN, use %precedence [-Wprecedence] -input.y:61.1-5: warning: useless associativity for HNOT, use %precedence [-Wprecedence] -input.y:68.1-5: warning: useless associativity for UNEAR, use %precedence [-Wprecedence] ]], dnl LAST-STATE @@ -2009,57 +2009,27 @@ dnl without being followed by "of".) [[VARIABLE, '=', LABEL, LEFT, DOT_X]], dnl BISON-STDERR -[[input.y:202.19: warning: empty rule without %empty [-Wempty-rule] -input.y:270.6: warning: empty rule without %empty [-Wempty-rule] -input.y:292.12: warning: empty rule without %empty [-Wempty-rule] -input.y:309.17: warning: empty rule without %empty [-Wempty-rule] -input.y:382.13: warning: empty rule without %empty [-Wempty-rule] -input.y:471.11-48: warning: rule useless in parser due to conflicts [-Wother] -input.y:154.1-5: warning: useless associativity for LABEL, use %precedence [-Wprecedence] -input.y:156.1-5: warning: useless associativity for VARIABLE, use %precedence [-Wprecedence] -input.y:156.1-5: warning: useless associativity for NUMBER, use %precedence [-Wprecedence] +[[input.y:137.1-5: warning: useless associativity for '.', use %precedence [-Wprecedence] +input.y:140.1-5: warning: useless associativity for PLOT, use %precedence [-Wprecedence] input.y:141.1-5: warning: useless associativity for TEXT, use %precedence [-Wprecedence] -input.y:157.1-5: warning: useless associativity for ORDINAL, use %precedence [-Wprecedence] -input.y:156.1-5: warning: useless associativity for LAST, use %precedence [-Wprecedence] -input.y:153.1-5: warning: useless associativity for UP, use %precedence [-Wprecedence] -input.y:153.1-5: warning: useless associativity for DOWN, use %precedence [-Wprecedence] -input.y:159.1-5: warning: useless associativity for BOX, use %precedence [-Wprecedence] -input.y:159.1-5: warning: useless associativity for CIRCLE, use %precedence [-Wprecedence] -input.y:159.1-5: warning: useless associativity for ELLIPSE, use %precedence [-Wprecedence] -input.y:159.1-5: warning: useless associativity for ARC, use %precedence [-Wprecedence] -input.y:159.1-5: warning: useless associativity for LINE, use %precedence [-Wprecedence] -input.y:159.1-5: warning: useless associativity for ARROW, use %precedence [-Wprecedence] -input.y:159.1-5: warning: useless associativity for SPLINE, use %precedence [-Wprecedence] -input.y:162.1-5: warning: useless associativity for HEIGHT, use %precedence [-Wprecedence] -input.y:162.1-5: warning: useless associativity for RADIUS, use %precedence [-Wprecedence] -input.y:162.1-5: warning: useless associativity for WIDTH, use %precedence [-Wprecedence] -input.y:162.1-5: warning: useless associativity for DIAMETER, use %precedence [-Wprecedence] -input.y:162.1-5: warning: useless associativity for FROM, use %precedence [-Wprecedence] -input.y:162.1-5: warning: useless associativity for TO, use %precedence [-Wprecedence] -input.y:162.1-5: warning: useless associativity for AT, use %precedence [-Wprecedence] -input.y:153.1-5: warning: useless precedence and associativity for SOLID [-Wprecedence] -input.y:153.1-5: warning: useless associativity for DOTTED, use %precedence [-Wprecedence] -input.y:153.1-5: warning: useless associativity for DASHED, use %precedence [-Wprecedence] -input.y:153.1-5: warning: useless associativity for CHOP, use %precedence [-Wprecedence] +input.y:141.1-5: warning: useless associativity for SPRINTF, use %precedence [-Wprecedence] input.y:147.1-5: warning: useless precedence and associativity for LJUST [-Wprecedence] input.y:147.1-5: warning: useless precedence and associativity for RJUST [-Wprecedence] input.y:147.1-5: warning: useless precedence and associativity for ABOVE [-Wprecedence] input.y:147.1-5: warning: useless precedence and associativity for BELOW [-Wprecedence] -input.y:176.1-5: warning: useless associativity for OF, use %precedence [-Wprecedence] -input.y:176.1-5: warning: useless associativity for BETWEEN, use %precedence [-Wprecedence] -input.y:177.1-5: warning: useless associativity for AND, use %precedence [-Wprecedence] -input.y:157.1-5: warning: useless associativity for HERE, use %precedence [-Wprecedence] -input.y:166.1-5: warning: useless associativity for DOT_N, use %precedence [-Wprecedence] -input.y:166.1-5: warning: useless associativity for DOT_E, use %precedence [-Wprecedence] -input.y:166.1-5: warning: useless associativity for DOT_W, use %precedence [-Wprecedence] -input.y:166.1-5: warning: useless associativity for DOT_S, use %precedence [-Wprecedence] -input.y:166.1-5: warning: useless associativity for DOT_NE, use %precedence [-Wprecedence] -input.y:166.1-5: warning: useless associativity for DOT_SE, use %precedence [-Wprecedence] -input.y:166.1-5: warning: useless associativity for DOT_NW, use %precedence [-Wprecedence] -input.y:166.1-5: warning: useless associativity for DOT_SW, use %precedence [-Wprecedence] -input.y:166.1-5: warning: useless associativity for DOT_C, use %precedence [-Wprecedence] -input.y:167.1-5: warning: useless associativity for DOT_START, use %precedence [-Wprecedence] -input.y:167.1-5: warning: useless associativity for DOT_END, use %precedence [-Wprecedence] +input.y:153.1-5: warning: useless associativity for UP, use %precedence [-Wprecedence] +input.y:153.1-5: warning: useless associativity for DOWN, use %precedence [-Wprecedence] +input.y:153.1-5: warning: useless precedence and associativity for SOLID [-Wprecedence] +input.y:153.1-5: warning: useless associativity for DOTTED, use %precedence [-Wprecedence] +input.y:153.1-5: warning: useless associativity for DASHED, use %precedence [-Wprecedence] +input.y:153.1-5: warning: useless associativity for CHOP, use %precedence [-Wprecedence] +input.y:153.1-5: warning: useless associativity for FILL, use %precedence [-Wprecedence] +input.y:153.1-5: warning: useless precedence and associativity for COLORED [-Wprecedence] +input.y:153.1-5: warning: useless precedence and associativity for OUTLINED [-Wprecedence] +input.y:154.1-5: warning: useless associativity for LABEL, use %precedence [-Wprecedence] +input.y:156.1-5: warning: useless associativity for VARIABLE, use %precedence [-Wprecedence] +input.y:156.1-5: warning: useless associativity for NUMBER, use %precedence [-Wprecedence] +input.y:156.1-5: warning: useless associativity for LAST, use %precedence [-Wprecedence] input.y:156.1-5: warning: useless associativity for SIN, use %precedence [-Wprecedence] input.y:156.1-5: warning: useless associativity for COS, use %precedence [-Wprecedence] input.y:156.1-5: warning: useless associativity for ATAN2, use %precedence [-Wprecedence] @@ -2071,12 +2041,43 @@ input.y:156.1-5: warning: useless associativity for K_MIN, use %precedence [-Wpr input.y:156.1-5: warning: useless associativity for INT, use %precedence [-Wprecedence] input.y:156.1-5: warning: useless associativity for RAND, use %precedence [-Wprecedence] input.y:156.1-5: warning: useless associativity for SRAND, use %precedence [-Wprecedence] +input.y:156.1-5: warning: useless associativity for '(', use %precedence [-Wprecedence] +input.y:157.1-5: warning: useless associativity for ORDINAL, use %precedence [-Wprecedence] +input.y:157.1-5: warning: useless associativity for HERE, use %precedence [-Wprecedence] +input.y:157.1-5: warning: useless associativity for '`', use %precedence [-Wprecedence] +input.y:159.1-5: warning: useless associativity for BOX, use %precedence [-Wprecedence] +input.y:159.1-5: warning: useless associativity for CIRCLE, use %precedence [-Wprecedence] +input.y:159.1-5: warning: useless associativity for ELLIPSE, use %precedence [-Wprecedence] +input.y:159.1-5: warning: useless associativity for ARC, use %precedence [-Wprecedence] +input.y:159.1-5: warning: useless associativity for LINE, use %precedence [-Wprecedence] +input.y:159.1-5: warning: useless associativity for ARROW, use %precedence [-Wprecedence] +input.y:159.1-5: warning: useless associativity for SPLINE, use %precedence [-Wprecedence] +input.y:159.1-5: warning: useless associativity for '@<:@', use %precedence [-Wprecedence] +input.y:162.1-5: warning: useless associativity for HEIGHT, use %precedence [-Wprecedence] +input.y:162.1-5: warning: useless associativity for RADIUS, use %precedence [-Wprecedence] +input.y:162.1-5: warning: useless associativity for WIDTH, use %precedence [-Wprecedence] +input.y:162.1-5: warning: useless associativity for DIAMETER, use %precedence [-Wprecedence] +input.y:162.1-5: warning: useless associativity for FROM, use %precedence [-Wprecedence] +input.y:162.1-5: warning: useless associativity for TO, use %precedence [-Wprecedence] +input.y:162.1-5: warning: useless associativity for AT, use %precedence [-Wprecedence] +input.y:162.1-5: warning: useless associativity for THICKNESS, use %precedence [-Wprecedence] +input.y:166.1-5: warning: useless associativity for DOT_N, use %precedence [-Wprecedence] +input.y:166.1-5: warning: useless associativity for DOT_E, use %precedence [-Wprecedence] +input.y:166.1-5: warning: useless associativity for DOT_W, use %precedence [-Wprecedence] +input.y:166.1-5: warning: useless associativity for DOT_S, use %precedence [-Wprecedence] +input.y:166.1-5: warning: useless associativity for DOT_NE, use %precedence [-Wprecedence] +input.y:166.1-5: warning: useless associativity for DOT_SE, use %precedence [-Wprecedence] +input.y:166.1-5: warning: useless associativity for DOT_NW, use %precedence [-Wprecedence] +input.y:166.1-5: warning: useless associativity for DOT_SW, use %precedence [-Wprecedence] +input.y:166.1-5: warning: useless associativity for DOT_C, use %precedence [-Wprecedence] +input.y:167.1-5: warning: useless associativity for DOT_START, use %precedence [-Wprecedence] +input.y:167.1-5: warning: useless associativity for DOT_END, use %precedence [-Wprecedence] input.y:167.1-5: warning: useless associativity for TOP, use %precedence [-Wprecedence] input.y:167.1-5: warning: useless associativity for BOTTOM, use %precedence [-Wprecedence] -input.y:168.1-5: warning: useless associativity for UPPER, use %precedence [-Wprecedence] -input.y:168.1-5: warning: useless associativity for LOWER, use %precedence [-Wprecedence] input.y:167.1-5: warning: useless associativity for LEFT_CORNER, use %precedence [-Wprecedence] input.y:167.1-5: warning: useless associativity for RIGHT_CORNER, use %precedence [-Wprecedence] +input.y:168.1-5: warning: useless associativity for UPPER, use %precedence [-Wprecedence] +input.y:168.1-5: warning: useless associativity for LOWER, use %precedence [-Wprecedence] input.y:168.1-5: warning: useless associativity for NORTH, use %precedence [-Wprecedence] input.y:168.1-5: warning: useless associativity for SOUTH, use %precedence [-Wprecedence] input.y:168.1-5: warning: useless associativity for EAST, use %precedence [-Wprecedence] @@ -2084,18 +2085,17 @@ input.y:168.1-5: warning: useless associativity for WEST, use %precedence [-Wpre input.y:168.1-5: warning: useless associativity for CENTER, use %precedence [-Wprecedence] input.y:168.1-5: warning: useless associativity for END, use %precedence [-Wprecedence] input.y:168.1-5: warning: useless associativity for START, use %precedence [-Wprecedence] -input.y:140.1-5: warning: useless associativity for PLOT, use %precedence [-Wprecedence] -input.y:162.1-5: warning: useless associativity for THICKNESS, use %precedence [-Wprecedence] -input.y:153.1-5: warning: useless associativity for FILL, use %precedence [-Wprecedence] -input.y:153.1-5: warning: useless precedence and associativity for COLORED [-Wprecedence] -input.y:153.1-5: warning: useless precedence and associativity for OUTLINED [-Wprecedence] -input.y:141.1-5: warning: useless associativity for SPRINTF, use %precedence [-Wprecedence] -input.y:137.1-5: warning: useless associativity for '.', use %precedence [-Wprecedence] -input.y:156.1-5: warning: useless associativity for '(', use %precedence [-Wprecedence] -input.y:157.1-5: warning: useless associativity for '`', use %precedence [-Wprecedence] -input.y:159.1-5: warning: useless associativity for '@<:@', use %precedence [-Wprecedence] input.y:170.1-5: warning: useless associativity for ',', use %precedence [-Wprecedence] +input.y:176.1-5: warning: useless associativity for OF, use %precedence [-Wprecedence] +input.y:176.1-5: warning: useless associativity for BETWEEN, use %precedence [-Wprecedence] +input.y:177.1-5: warning: useless associativity for AND, use %precedence [-Wprecedence] input.y:181.1-6: warning: useless associativity for '!', use %precedence [-Wprecedence] +input.y:202.19: warning: empty rule without %empty [-Wempty-rule] +input.y:270.6: warning: empty rule without %empty [-Wempty-rule] +input.y:292.12: warning: empty rule without %empty [-Wempty-rule] +input.y:309.17: warning: empty rule without %empty [-Wempty-rule] +input.y:382.13: warning: empty rule without %empty [-Wempty-rule] +input.y:471.11-48: warning: rule useless in parser due to conflicts [-Wother] ]], dnl LAST-STATE diff --git a/tests/input.at b/tests/input.at index 1548f14c..1c86dab6 100644 --- a/tests/input.at +++ b/tests/input.at @@ -142,15 +142,15 @@ exp: foo { $$; } foo { $2; } foo ]]) AT_BISON_CHECK([-fcaret input.y], [1], [], -[[input.y:5.12-13: error: $$ for the midrule at $2 of 'exp' has no declared type +[[input.y:5.6-32: warning: type clash on default action: != <> [-Wother] + exp: foo { $$; } foo { $2; } foo + ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +input.y:5.12-13: error: $$ for the midrule at $2 of 'exp' has no declared type exp: foo { $$; } foo { $2; } foo ^^ input.y:5.24-25: error: $2 of 'exp' has no declared type exp: foo { $$; } foo { $2; } foo ^^ -input.y:5.6-32: warning: type clash on default action: != <> [-Wother] - exp: foo { $$; } foo { $2; } foo - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ input.y:6.6-8: warning: type clash on default action: != <> [-Wother] | foo ^^^ @@ -208,12 +208,12 @@ _AT_UNUSED_VALUES_DECLARATIONS]) AT_BISON_CHECK(m4_ifval($2, [--warnings=midrule-values ])[-fcaret input.y], [0], [], -[[input.y:11.10-32: warning: unset value: $][$ [-Wother] - a: INT | INT { } INT { } INT { }; - ^^^^^^^^^^^^^^^^^^^^^^^ -input.y:11.10-12: warning: unused value: $][1 [-Wother] +[[input.y:11.10-12: warning: unused value: $][1 [-Wother] a: INT | INT { } INT { } INT { }; ^^^ +input.y:11.10-32: warning: unset value: $][$ [-Wother] + a: INT | INT { } INT { } INT { }; + ^^^^^^^^^^^^^^^^^^^^^^^ input.y:11.18-20: warning: unused value: $][3 [-Wother] a: INT | INT { } INT { } INT { }; ^^^ @@ -223,28 +223,28 @@ input.y:11.26-28: warning: unused value: $][5 [-Wother] input.y:12.10-15: warning: empty rule for typed nonterminal, and no action [-Wother] b: INT | %empty; ^^^^^^ +input.y:13.10-62: warning: unset value: $][$ [-Wother] + c: INT | INT { $][1; } INT { $2; } INT { $4; }; + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ]]m4_ifval($2, [[[input.y:13.14-20: warning: unset value: $][$ [-Wmidrule-values] c: INT | INT { $][1; } INT { $2; } INT { $4; }; ^^^^^^^ -input.y:13.26-41: warning: unset value: $][$ [-Wmidrule-values] - c: INT | INT { $][1; } INT { $2; } INT { $4; }; - ^^^^^^^^^^^^^^^^ -]]])[[input.y:13.10-62: warning: unset value: $][$ [-Wother] - c: INT | INT { $][1; } INT { $2; } INT { $4; }; - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -input.y:13.22-24: warning: unused value: $][3 [-Wother] +]]])[[input.y:13.22-24: warning: unused value: $][3 [-Wother] c: INT | INT { $][1; } INT { $2; } INT { $4; }; ^^^ -input.y:13.43-45: warning: unused value: $][5 [-Wother] +]]m4_ifval($2, [[[input.y:13.26-41: warning: unset value: $][$ [-Wmidrule-values] + c: INT | INT { $][1; } INT { $2; } INT { $4; }; + ^^^^^^^^^^^^^^^^ +]]])[[input.y:13.43-45: warning: unused value: $][5 [-Wother] c: INT | INT { $][1; } INT { $2; } INT { $4; }; ^^^ +input.y:14.10-49: warning: unset value: $][$ [-Wother] + d: INT | INT { } INT { $][1; } INT { $2; }; + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ]]m4_ifval($2, [[[input.y:14.14-16: warning: unset value: $][$ [-Wmidrule-values] d: INT | INT { } INT { $][1; } INT { $2; }; ^^^ -]]])[[input.y:14.10-49: warning: unset value: $][$ [-Wother] - d: INT | INT { } INT { $][1; } INT { $2; }; - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -input.y:14.18-20: warning: unused value: $][3 [-Wother] +]]])[[input.y:14.18-20: warning: unused value: $][3 [-Wother] d: INT | INT { } INT { $][1; } INT { $2; }; ^^^ input.y:14.30-32: warning: unused value: $][5 [-Wother] @@ -259,12 +259,12 @@ input.y:15.18-20: warning: unused value: $][3 [-Wother] input.y:15.27-29: warning: unused value: $][5 [-Wother] e: INT | INT { } INT { } INT { $][1; }; ^^^ -input.y:17.10-58: warning: unset value: $][$ [-Wother] - g: INT | INT { $$; } INT { $$; } INT { }; - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ input.y:17.10-12: warning: unused value: $][1 [-Wother] g: INT | INT { $$; } INT { $$; } INT { }; ^^^ +input.y:17.10-58: warning: unset value: $][$ [-Wother] + g: INT | INT { $$; } INT { $$; } INT { }; + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ]]m4_ifval($2, [[[input.y:17.14-29: warning: unused value: $][2 [-Wmidrule-values] g: INT | INT { $$; } INT { $$; } INT { }; ^^^^^^^^^^^^^^^^ @@ -277,12 +277,12 @@ input.y:17.10-12: warning: unused value: $][1 [-Wother] ]]])[[input.y:17.52-54: warning: unused value: $][5 [-Wother] g: INT | INT { $$; } INT { $$; } INT { }; ^^^ -input.y:18.10-72: warning: unset value: $][$ [-Wother] - h: INT | INT { $$; } INT { $$ = $2; } INT { }; - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ input.y:18.10-12: warning: unused value: $][1 [-Wother] h: INT | INT { $$; } INT { $$ = $2; } INT { }; ^^^ +input.y:18.10-72: warning: unset value: $][$ [-Wother] + h: INT | INT { $$; } INT { $$ = $2; } INT { }; + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ input.y:18.31-33: warning: unused value: $][3 [-Wother] h: INT | INT { $$; } INT { $$ = $2; } INT { }; ^^^ @@ -295,12 +295,12 @@ input.y:18.31-33: warning: unused value: $][3 [-Wother] ]]m4_ifval($2, [[[input.y:20.18-37: warning: unused value: $][3 [-Wmidrule-values] j: INT | INT INT { $$ = 1; } { $][$ = $][1 + $][2; }; ^^^^^^^^^^^^^^^^^^^^ -]]])[[input.y:21.10-68: warning: unset value: $][$ [-Wother] - k: INT | INT INT { $$; } { $$ = $3; } { }; - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -input.y:21.10-12: warning: unused value: $][1 [-Wother] +]]])[[input.y:21.10-12: warning: unused value: $][1 [-Wother] k: INT | INT INT { $$; } { $$ = $3; } { }; ^^^ +input.y:21.10-68: warning: unset value: $][$ [-Wother] + k: INT | INT INT { $$; } { $$ = $3; } { }; + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ input.y:21.14-16: warning: unused value: $][2 [-Wother] k: INT | INT INT { $$; } { $$ = $3; } { }; ^^^ @@ -458,15 +458,15 @@ exp: bar; ]]) AT_BISON_CHECK([-fcaret input.y], [1], [], -[[input.y:2.16-18: error: symbol bar is used, but is not defined as a token and has no rules - %destructor {} bar - ^^^ +[[input.y:1.13-15: warning: symbol foo is used, but is not defined as a token and has no rules [-Wother] + %printer {} foo baz + ^^^ input.y:1.17-19: warning: symbol baz is used, but is not defined as a token and has no rules [-Wother] %printer {} foo baz ^^^ -input.y:1.13-15: warning: symbol foo is used, but is not defined as a token and has no rules [-Wother] - %printer {} foo baz - ^^^ +input.y:2.16-18: error: symbol bar is used, but is not defined as a token and has no rules + %destructor {} bar + ^^^ input.y:3.13-15: warning: symbol qux is used, but is not defined as a token and has no rules [-Wother] %type qux ^^^ @@ -1417,9 +1417,9 @@ start: TOK; AT_BISON_CHECK([[input.yy]], [0], [], [[input.yy:2.9-25: warning: %define variable 'api.location.type' requires '{...}' values [-Wdeprecated] +input.yy:3.9-21: warning: %define variable 'api.namespace' requires '{...}' values [-Wdeprecated] input.yy:4.9-18: warning: %define variable 'api.prefix' requires '{...}' values [-Wdeprecated] input.yy:5.9-24: warning: %define variable 'api.token.prefix' requires '{...}' values [-Wdeprecated] -input.yy:3.9-21: warning: %define variable 'api.namespace' requires '{...}' values [-Wdeprecated] ]]) ]) @@ -1448,11 +1448,11 @@ exp: %empty ]]) AT_BISON_CHECK([[input.y]], [0], [], -[[input.y:5.9-15: warning: %define variable 'lr.type' requires keyword values [-Wdeprecated] +[[input.y:1.9-16: warning: %define variable 'api.pure' requires keyword values [-Wdeprecated] +input.y:2.9-21: warning: %define variable 'api.push-pull' requires keyword values [-Wdeprecated] input.y:3.9-28: warning: %define variable 'lr.default-reduction' requires keyword values [-Wdeprecated] input.y:4.9-33: warning: %define variable 'lr.keep-unreachable-state' requires keyword values [-Wdeprecated] -input.y:2.9-21: warning: %define variable 'api.push-pull' requires keyword values [-Wdeprecated] -input.y:1.9-16: warning: %define variable 'api.pure' requires keyword values [-Wdeprecated] +input.y:5.9-15: warning: %define variable 'lr.type' requires keyword values [-Wdeprecated] ]]) ]) @@ -1717,26 +1717,26 @@ AT_CHECK([[$PERL -e 'print "start: \"\\\t\\\f\\\0\\\1\" ;";' >> input.y \ || exit 77]]) AT_BISON_CHECK([input.y], [1], [], -[[input.y:2.9-12: error: invalid number after \-escape: 777 -input.y:2.8-13: warning: empty character literal [-Wother] -input.y:2.16-17: error: invalid number after \-escape: 0 +[[input.y:2.8-13: warning: empty character literal [-Wother] +input.y:2.9-12: error: invalid number after \-escape: 777 input.y:2.15-18: warning: empty character literal [-Wother] -input.y:2.21-25: error: invalid number after \-escape: xfff +input.y:2.16-17: error: invalid number after \-escape: 0 input.y:2.20-26: warning: empty character literal [-Wother] -input.y:2.29-31: error: invalid number after \-escape: x0 +input.y:2.21-25: error: invalid number after \-escape: xfff input.y:2.28-32: warning: empty character literal [-Wother] -input.y:3.9-14: error: invalid number after \-escape: uffff +input.y:2.29-31: error: invalid number after \-escape: x0 input.y:3.8-15: warning: empty character literal [-Wother] -input.y:3.18-23: error: invalid number after \-escape: u0000 +input.y:3.9-14: error: invalid number after \-escape: uffff input.y:3.17-24: warning: empty character literal [-Wother] -input.y:3.27-36: error: invalid number after \-escape: Uffffffff +input.y:3.18-23: error: invalid number after \-escape: u0000 input.y:3.26-37: warning: empty character literal [-Wother] -input.y:3.40-49: error: invalid number after \-escape: U00000000 +input.y:3.27-36: error: invalid number after \-escape: Uffffffff input.y:3.39-50: warning: empty character literal [-Wother] -input.y:4.9-10: error: invalid character after \-escape: ' ' +input.y:3.40-49: error: invalid number after \-escape: U00000000 input.y:4.8-11: warning: empty character literal [-Wother] -input.y:4.14-15: error: invalid character after \-escape: A +input.y:4.9-10: error: invalid character after \-escape: ' ' input.y:4.13-16: warning: empty character literal [-Wother] +input.y:4.14-15: error: invalid character after \-escape: A input.y:5.9-16: error: invalid character after \-escape: \t input.y:5.17: error: invalid character after \-escape: \f input.y:5.18: error: invalid character after \-escape: \0 @@ -2007,12 +2007,12 @@ AT_BISON_CHECK([[input.y]], [[1]], [[]], input.y:11.15-24: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated] input.y:12.15-24: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated] input.y:13.1-14: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated] -input.y:13.16-29: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated] input.y:13.11-21: error: %define variable 'parse.error' redefined input.y:13-6: previous definition -input.y:14.16-29: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated] +input.y:13.16-29: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated] input.y:14.11-21: error: %define variable 'parse.error' redefined input.y:13.11-21: previous definition +input.y:14.16-29: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated] ]]) AT_CLEANUP diff --git a/tests/reduce.at b/tests/reduce.at index 7e4977a0..c119e22b 100644 --- a/tests/reduce.at +++ b/tests/reduce.at @@ -88,8 +88,7 @@ exp: useful; ]]) AT_BISON_CHECK([[input.y]], 0, [], -[[input.y: warning: 9 nonterminals useless in grammar [-Wother] -input.y:4.8-15: warning: nonterminal useless in grammar: useless1 [-Wother] +[[input.y:4.8-15: warning: nonterminal useless in grammar: useless1 [-Wother] input.y:5.8-15: warning: nonterminal useless in grammar: useless2 [-Wother] input.y:6.8-15: warning: nonterminal useless in grammar: useless3 [-Wother] input.y:7.8-15: warning: nonterminal useless in grammar: useless4 [-Wother] @@ -98,6 +97,7 @@ input.y:9.8-15: warning: nonterminal useless in grammar: useless6 [-Wother] input.y:10.8-15: warning: nonterminal useless in grammar: useless7 [-Wother] input.y:11.8-15: warning: nonterminal useless in grammar: useless8 [-Wother] input.y:12.8-15: warning: nonterminal useless in grammar: useless9 [-Wother] +input.y: warning: 9 nonterminals useless in grammar [-Wother] ]]) AT_CHECK([[sed -n '/^Grammar/q;/^$/!p' input.output]], 0, @@ -143,62 +143,62 @@ useless9: '9'; ]]) AT_BISON_CHECK([[-fcaret input.y]], 0, [], -[[input.y: warning: 9 nonterminals useless in grammar [-Wother] -input.y: warning: 9 rules useless in grammar [-Wother] -input.y:6.1-8: warning: nonterminal useless in grammar: useless1 [-Wother] +[[input.y:6.1-8: warning: nonterminal useless in grammar: useless1 [-Wother] useless1: '1'; ^^^^^^^^ -input.y:7.1-8: warning: nonterminal useless in grammar: useless2 [-Wother] - useless2: '2'; - ^^^^^^^^ -input.y:8.1-8: warning: nonterminal useless in grammar: useless3 [-Wother] - useless3: '3'; - ^^^^^^^^ -input.y:9.1-8: warning: nonterminal useless in grammar: useless4 [-Wother] - useless4: '4'; - ^^^^^^^^ -input.y:10.1-8: warning: nonterminal useless in grammar: useless5 [-Wother] - useless5: '5'; - ^^^^^^^^ -input.y:11.1-8: warning: nonterminal useless in grammar: useless6 [-Wother] - useless6: '6'; - ^^^^^^^^ -input.y:12.1-8: warning: nonterminal useless in grammar: useless7 [-Wother] - useless7: '7'; - ^^^^^^^^ -input.y:13.1-8: warning: nonterminal useless in grammar: useless8 [-Wother] - useless8: '8'; - ^^^^^^^^ -input.y:14.1-8: warning: nonterminal useless in grammar: useless9 [-Wother] - useless9: '9'; - ^^^^^^^^ input.y:6.11-13: warning: rule useless in grammar [-Wother] useless1: '1'; ^^^ +input.y:7.1-8: warning: nonterminal useless in grammar: useless2 [-Wother] + useless2: '2'; + ^^^^^^^^ input.y:7.11-13: warning: rule useless in grammar [-Wother] useless2: '2'; ^^^ +input.y:8.1-8: warning: nonterminal useless in grammar: useless3 [-Wother] + useless3: '3'; + ^^^^^^^^ input.y:8.11-13: warning: rule useless in grammar [-Wother] useless3: '3'; ^^^ +input.y:9.1-8: warning: nonterminal useless in grammar: useless4 [-Wother] + useless4: '4'; + ^^^^^^^^ input.y:9.11-13: warning: rule useless in grammar [-Wother] useless4: '4'; ^^^ +input.y:10.1-8: warning: nonterminal useless in grammar: useless5 [-Wother] + useless5: '5'; + ^^^^^^^^ input.y:10.11-13: warning: rule useless in grammar [-Wother] useless5: '5'; ^^^ +input.y:11.1-8: warning: nonterminal useless in grammar: useless6 [-Wother] + useless6: '6'; + ^^^^^^^^ input.y:11.11-13: warning: rule useless in grammar [-Wother] useless6: '6'; ^^^ +input.y:12.1-8: warning: nonterminal useless in grammar: useless7 [-Wother] + useless7: '7'; + ^^^^^^^^ input.y:12.11-13: warning: rule useless in grammar [-Wother] useless7: '7'; ^^^ +input.y:13.1-8: warning: nonterminal useless in grammar: useless8 [-Wother] + useless8: '8'; + ^^^^^^^^ input.y:13.11-13: warning: rule useless in grammar [-Wother] useless8: '8'; ^^^ +input.y:14.1-8: warning: nonterminal useless in grammar: useless9 [-Wother] + useless9: '9'; + ^^^^^^^^ input.y:14.11-13: warning: rule useless in grammar [-Wother] useless9: '9'; ^^^ +input.y: warning: 9 nonterminals useless in grammar [-Wother] +input.y: warning: 9 rules useless in grammar [-Wother] ]]) @@ -276,23 +276,23 @@ non_productive: non_productive useless_token ]]) AT_BISON_CHECK([[-fcaret not-reduced.y]], 0, [], -[[not-reduced.y: warning: 2 nonterminals useless in grammar [-Wother] -not-reduced.y: warning: 3 rules useless in grammar [-Wother] -not-reduced.y:14.1-13: warning: nonterminal useless in grammar: not_reachable [-Wother] - not_reachable: useful { /* A not reachable action. */ } - ^^^^^^^^^^^^^ -not-reduced.y:11.6-19: warning: nonterminal useless in grammar: non_productive [-Wother] +[[not-reduced.y:11.6-19: warning: nonterminal useless in grammar: non_productive [-Wother] | non_productive { /* A non productive action. */ } ^^^^^^^^^^^^^^ not-reduced.y:11.6-57: warning: rule useless in grammar [-Wother] | non_productive { /* A non productive action. */ } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +not-reduced.y:14.1-13: warning: nonterminal useless in grammar: not_reachable [-Wother] + not_reachable: useful { /* A not reachable action. */ } + ^^^^^^^^^^^^^ not-reduced.y:14.16-56: warning: rule useless in grammar [-Wother] not_reachable: useful { /* A not reachable action. */ } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not-reduced.y:17.17-18.63: warning: rule useless in grammar [-Wother] non_productive: non_productive useless_token ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +not-reduced.y: warning: 2 nonterminals useless in grammar [-Wother] +not-reduced.y: warning: 3 rules useless in grammar [-Wother] ]]) AT_CHECK([[sed -n '/^Grammar/q;/^$/!p' not-reduced.output]], 0, @@ -361,13 +361,13 @@ indirection: underivable; ]]) AT_BISON_CHECK([[input.y]], 0, [], -[[input.y: warning: 2 nonterminals useless in grammar [-Wother] -input.y: warning: 3 rules useless in grammar [-Wother] -input.y:5.15-25: warning: nonterminal useless in grammar: underivable [-Wother] -input.y:6.14-24: warning: nonterminal useless in grammar: indirection [-Wother] +[[input.y:5.15-25: warning: nonterminal useless in grammar: underivable [-Wother] input.y:5.15-25: warning: rule useless in grammar [-Wother] +input.y:6.14-24: warning: nonterminal useless in grammar: indirection [-Wother] input.y:6.14-24: warning: rule useless in grammar [-Wother] input.y:7.14-24: warning: rule useless in grammar [-Wother] +input.y: warning: 2 nonterminals useless in grammar [-Wother] +input.y: warning: 3 rules useless in grammar [-Wother] ]]) AT_CHECK([[sed -n '/^Grammar/q;/^$/!p' input.output]], 0, @@ -397,9 +397,9 @@ exp: exp; ]]) AT_BISON_CHECK([[input.y]], 1, [], -[[input.y: warning: 2 nonterminals useless in grammar [-Wother] +[[input.y:3.1-3: fatal error: start symbol exp does not derive any sentence +input.y: warning: 2 nonterminals useless in grammar [-Wother] input.y: warning: 2 rules useless in grammar [-Wother] -input.y:3.1-3: fatal error: start symbol exp does not derive any sentence ]]) AT_CLEANUP diff --git a/tests/regression.at b/tests/regression.at index b9ca94c0..c1a1ad3f 100644 --- a/tests/regression.at +++ b/tests/regression.at @@ -1147,9 +1147,9 @@ sr_conflict: ]]) AT_BISON_CHECK([[-Wall -o input.c input.y]], [[0]],, -[[input.y:24.5-19: warning: rule useless in parser due to conflicts [-Wother] +[[input.y:18.1-5: warning: useless precedence and associativity for TK1 [-Wprecedence] +input.y:24.5-19: warning: rule useless in parser due to conflicts [-Wother] input.y:28.5-19: warning: rule useless in parser due to conflicts [-Wother] -input.y:18.1-5: warning: useless precedence and associativity for TK1 [-Wprecedence] ]]) AT_COMPILE([[input]]) AT_PARSER_CHECK([[./input]]) diff --git a/tests/skeletons.at b/tests/skeletons.at index 68a004ec..3850de63 100644 --- a/tests/skeletons.at +++ b/tests/skeletons.at @@ -186,10 +186,10 @@ start: ; ]]) AT_BISON_CHECK([[input1.y]], [[1]], [[]], -[[input1.y: warning: foow fubar [-Wother] +[[fooc.y:1.1-10.5: error: foocat fubar foow.y:2.3-5.3: warning: foowat fubar [-Wother] +input1.y: warning: foow fubar [-Wother] input1.y: error: fooc fubar -fooc.y:1.1-10.5: error: foocat fubar input1.y: fatal error: foof fubar ]]) @@ -276,8 +276,8 @@ start: ; ]]) AT_BISON_CHECK([[input2.y]], [[1]], [[]], -[[input2.y: warning: morning [-Wother] -foo.y:1.5-6: fatal error: M4 should exit immediately here +[[foo.y:1.5-6: fatal error: M4 should exit immediately here +input2.y: warning: morning [-Wother] ]]) AT_CLEANUP