Commit Graph

5242 Commits

Author SHA1 Message Date
Akim Demaille
5ae8eb3202 tests: fix failures with G++ 4.8 in Flex scanner
* configure.ac (WARN_NO_NULL_CONVERSION_CXXFLAGS): Rename as...
(FLEX_SCANNER_CXXFLAGS): this.
Pass -Wno-zero-as-null-pointer-constant to G++ if it supports it.
* examples/calc++/local.mk: Adjust.
2013-02-19 17:42:33 +01:00
Akim Demaille
bbed3fdef6 regen 2013-02-19 10:07:37 +01:00
Akim Demaille
42fef01256 gnulib: update 2013-02-19 09:51:38 +01:00
Akim Demaille
29248b4c13 style: rename variant private members
* data/variant.hh (buffer, tname, as_, raw, align_me): Rename as...
(yybuffer_, yytname_,yyas_, yyraw, yyalign_me): these.
2013-02-19 09:51:38 +01:00
Akim Demaille
361444e419 style: space changes
* data/variant.hh: Be sure to leave a space before arguments in function
calls.
2013-02-19 09:51:38 +01:00
Akim Demaille
85bc7f5466 variant: fix G++ 4.4 warnings
The changes by Théophile Ranquet about type punning issues need
to be extend to in-place new to please G++ 4.4.7.

* data/variant.hh (variant::as_): New, factors the casts that avoid
compiler warnings.
(as, build): Use them.
2013-02-19 09:51:38 +01:00
Akim Demaille
1282c12476 news: spell fixes
* NEWS: here.
2013-02-18 14:30:19 +01:00
Akim Demaille
0fe5a72a26 diagnostics: factor and enhance messages about duplicate rule directives
When reporting a duplicate directive on a rule, point to its first
occurrence:

one.y:11.10-15: error: only one %empty allowed per rule
   %empty {} %empty
             ^^^^^^
one.y:11.3-8: previous declaration
   %empty {} %empty
   ^^^^^^

And consistently discard the second one.

* src/complain.h, src/complain.c (duplicate_directive): New.
* src/reader.c: Use it where appropriate.
* src/symlist.h, src/symlist.c (symbol_list): Add a dprec_location member.
* tests/actions.at: Adjust expected output.
2013-02-18 10:01:29 +01:00
Akim Demaille
4c9b8f1318 style: no longer use backquotes
* tests/actions.at, tests/atlocal.in, tests/c++.at, tests/calc.at,
* tests/conflicts.at, tests/existing.at, tests/glr-regression.at,
* tests/input.at, tests/java.at, tests/local.at, tests/sets.at,
* tests/synclines.at, doc/bison.texi, lib/libiberty.h, lib/timevar.h:
Use single quotes.
2013-02-18 10:01:28 +01:00
Akim Demaille
45eebca42d style: no longer use backquotes
* README, REFERENCES, TODO, configure.ac, data/README, data/bison.m4,
* data/c++.m4, data/c.m4, data/java.m4, data/lalr1.cc,
* data/lalr1.java, data/yacc.c, doc/local.mk, etc/bench.pl.in,
* src/conflicts.c, src/files.c, src/getargs.c, src/gram.h, src/lalr.c,
* src/location.c, src/location.h, src/muscle-tab.c, src/muscle-tab.h,
* src/output.c, src/parse-gram.c, src/parse-gram.y, src/print-xml.c,
* src/print.c, src/reader.c, src/reduce.c, src/scan-skel.l,
* src/symtab.h, src/system.h, src/tables.c:
Use single quotes, as currently recommended by the GNU Coding Standards.
2013-02-18 10:01:28 +01:00
Akim Demaille
d49751602c style: no longer use backquotes in messages
* src/getargs.c (usage): Use single quotes.
2013-02-18 10:01:28 +01:00
Akim Demaille
6240346aa0 doc: use %empty instead of /* empty */
* doc/bison.texi: Change the comments into explicit %empty.
2013-02-18 10:01:28 +01:00
Akim Demaille
09add9c24f doc: introduce %empty and -Wempty-rule
* doc/bison.texi (Grammar Rules): Make it a @section which
contains...
(Rules Syntax): this new subsection (with the previous contents of
"Grammar Rules".
(Empty Rules): New subsection, extracted from the former
"Grammar Rules".
Document %empty.
(Recursion): New a subsection of "Grammar Rules".
Complete a few index entries.
(Bison Options): Document -Wempty-rule.
2013-02-18 10:01:28 +01:00
Akim Demaille
8b807f1177 report: use %empty to denote empty rules
* src/gram.c (rule_rhs_print): Use %empty for empty rules.
* tests/conflicts.at, tests/regression.at, tests/sets.at: Adjust.
2013-02-18 10:01:28 +01:00
Akim Demaille
42d101da8d diagnostics: %empty enables -Wempty-rule
* src/complain.h, src/complain.c (warning_is_unset): New.
* src/reader.c (grammar_current_rule_empty_set): If enabled -Wempty-rule,
if not disabled.
* tests/actions.at (Implicitly empty rule): Check this feature.
Also check that -Wno-empty-rule does disable this warning.
2013-02-18 10:01:28 +01:00
Akim Demaille
f68a49ed49 -Wempty-rule: diagnose empty rules without %empty
* src/complain.h, src/complain.c (warning_empty_rule, Wempty_rule):
New warning category.
(warnings_args, warnings_types): Adjust.
* src/reader.c (grammar_rule_check): Check the empty rules are
flagged by %empty.
* tests/actions.at (Implicitly empty rule): New.
* tests/existing.at: Add expected warnings.
2013-02-18 10:01:27 +01:00
Akim Demaille
684083f065 tests: use %empty
* tests/actions.at, tests/input.at, tests/reduce.at,
* tests/regression.at:
here.
2013-02-18 10:01:27 +01:00
Akim Demaille
8ecac08f2d regen 2013-02-18 10:01:27 +01:00
Akim Demaille
fd003416d5 parser: use %empty
Avoid that Bison's own use of "bison -Wall" trigger warnings.

* src/parse-gram.y: Use %empty for every empty rule.
2013-02-18 10:01:27 +01:00
Akim Demaille
ae2b48f5c0 grammar: introduce %empty
Provide a means to explicitly denote empty right-hand sides of rules:
instead of

  exp:  { ... }

allow

  exp: %empty { ... }

Make sure that %empty is properly used.

With help from Joel E. Denny and Gabriel Rassoul.
http://lists.gnu.org/archive/html/bison-patches/2013-01/msg00142.html

* src/reader.h, src/reader.c (grammar_current_rule_empty_set): New.
* src/parse-gram.y (%empty): New token.
Use it.
* src/scan-gram.l (%empty): Scan it.
* src/reader.c (grammar_rule_check): Check that %empty is properly used.
* tests/actions.at (Invalid uses of %empty, Valid uses of %empty): New.
2013-02-18 10:01:27 +01:00
Akim Demaille
9e4917b2a1 getargs: minor simplification
* src/getargs.c (flag_argmatch): Simplify the handling of "none".
2013-02-16 07:45:14 +01:00
Akim Demaille
12bc1c9e47 style: move argument handling of -W into the diagnostics module
This allows to reduce the number of public interfaces.

* src/getargs.c (--yacc): Use warning_argmatch instead of tweaking
directly warnings_flag (which will be private).
(warning_argmatch, warnings_argmatch): Move to...
* src/complain.h, src/complain.c: here.

* src/getargs.h, src/getargs.c (warnings_args, warnings_types): Move to...
* src/complain.c: here, now private.

* src/complain.h (severity, warnings_flag): Move to...
* src/complain.c: here, now private.
2013-02-16 07:45:07 +01:00
Akim Demaille
808e523db4 diagnostics: revamp the handling of -Werror
Recent discussions with Joel E. Denny
(http://lists.gnu.org/archive/html/bison-patches/2013-02/msg00026.html)
show that it is desirable to tell the difference between an option
that was explicitly disabled with -Wno-foo, as opposed to be left
unset.  The current framework does not allow this.

Instead of having a first int to store which options are enabled, and
another to store which are turned into errors, use an array that for
each warning category tells its status: disabled, unset, warning,
error.

* src/complain.h, src/complain.c (warning_bit): New enum.
(warnings): Use it.
(severity): New enum.
(warnings_flag): Now an array of severity.
(errors_flag): Remove, now done by warnings_flag.
(complain_init): New function, to initialie warnings_flag.
(warnings_are_errors): New Boolean, for -Werror.
* src/complain.c (warning_severity): New.
(warnings_print_categories, complains): Use it.
* src/getargs.c (warning_argmatch): Adjust to use warnings_flag.
(warnings_argmatch): Ditto.
Handle -Werror and -Wno-error here.
(getargs): Adjust.
* src/main.c (main): Call complain_init.
* tests/input.at (Invalid options): Add more corner cases.
2013-02-16 07:45:06 +01:00
Akim Demaille
4a3c55cf1a options: simplify the handling of -W
* src/getargs.c (warnings_argmatch, warning_argmatch): Simplify by
replacing function arguments with their actual values.
(WARNING_ARGMATCH): Remove, useless.
Adjust callers.
2013-02-14 15:00:52 +01:00
Akim Demaille
c017f88fde options: don't accept "error=" for -f and -r
* src/getargs.c (warning_argmatch, warnings_argmatch, WARNINGS_ARGMATCH):
New.
Use them for -W/--warning.
They are copied from...
(flag_argmatch, flags_argmatch, FLAGS_ARGMATCH): these.
Simplify by removing the support for "error".
* tests/input.at (Invalid options): New.
* TODO (Laxism in Bison invocation arguments): Remove.
2013-02-14 15:00:51 +01:00
Akim Demaille
219458e22f diagnostics: factor the list of warning names
* src/getargs.h, src/getargs.c (warnings_args, warnings_types): Make
them public.
* src/complain.h, src/complain.c (warnings_print_categories): Its
only use outside complain.c was removed in a recent commit, so
make it static.
Simplify its implementation.
Use warnings_args and warnings_types.
* src/muscle-tab.c (muscle_percent_define_check_values): Make it
silent.
2013-02-14 15:00:51 +01:00
Akim Demaille
fec5f3c0cc diagnostics: no longer pretty-print rules in error messages, carets suffice
* src/gram.c (grammar_rules_useless_report): Let -fcaret handle the
pretty-printing of the guilty rules.
(rule_print): Inline in its only use.
* tests/conflicts.at, tests/existing.at, tests/reduce.at,
* tests/regression.at: Adjust.
* NEWS: Document.
2013-02-14 15:00:51 +01:00
Akim Demaille
9a9130f26d options: no longer document warnings when diagnosing an invalid -W
The argmatch functions accept prefixes of the alternatives (like
getopt does for long options).  Bison uses this to document the
warning categories.  This is troublesome: it duplicates the --help
documentation, it is not gettextized, it is displayed with ugly quotes
(because argmatch uses it to display the list of possible answers),
and it prevents straighforward uses of the tables of valid warning
categories (for instance so that warning diagnostics end with the name
of the warning).

The "hidden" option --trace uses the same trick, but it does not need
to be translated, nor to be described in --help.

* src/getargs.c (warnings_args): Remove pseudo documentation.
Comment changes.
2013-02-14 15:00:44 +01:00
Akim Demaille
312d0d654f tests: enlarge the allowed duration for calc tests
Hydra "often" fails on this test:

252. calc.at:658: 252. Calculator %glr-parser api.pure
parse.error=verbose %debug %locations %defines api.prefix="calc"
%verbose %yacc %parse-param {semantic_value *result}
%parse-param {int *count} (calc.at:658): FAILED

* tests/calc.at: Give 200s instead of 100s.
Use AT_DEBUG_IF.
2013-02-11 09:07:25 +01:00
Akim Demaille
848bcc288d debug: improve the display of symbol lists
* src/symtab.c (symbol_print): Remove useless quotes (the symbol already
has quotes).
Prefer fputs.
* src/symlist.c (symbol_list_syms_print): Likewise.
Fix separators.
2013-02-11 09:04:17 +01:00
Akim Demaille
ec6dc4375e style: minor changes
* src/complain.c: Space changes.
* src/reader.c: Comment changes.
Avoid && in assertions.
* src/location.c: Move comments to...
* src/location.h: here.
* src/symlist.h, src/symlist.c: Create a pseudo section for members
that apply to the rule.
2013-02-09 18:35:28 +01:00
Akim Demaille
c21e515e05 news: restructure, document variants for C++
* NEWS: here.
2013-02-08 17:28:06 +01:00
Akim Demaille
1dce289a00 c++: api.token.constructor requires api.value.type=variant
Eventually it should also support "union".

* data/glr.cc: Move this check to...
* data/c++.m4: here, as lalr1.cc is affected too.
2013-02-08 17:28:02 +01:00
Akim Demaille
66c209cf43 build: restore C90 compatibility
* src/parse-gram.y, src/parse-gram.c: Don't use // comments.
2013-02-05 14:37:55 +01:00
Akim Demaille
efbc95a7e4 doc: use @group to improve page breaking
* doc/bison.texi: here.
2013-02-05 11:44:12 +01:00
Akim Demaille
c5dbd909d0 style: rename internal "stype" as "union_members" for clarity
"stype" is quite unclear, and it also collides with the former %define
variable that had the same name (replaced by api.value.type).

* src/parse-gram.y (stype): Rename as...
(union_members): this.
* data/bison.m4: Adjust.
(b4_user_stype): Rename as...
(b4_user_union_members): this.
* data/c++.m4, data/c.m4: Adjust.
* src/parse-gram.c: regen.
2013-02-04 18:45:21 +01:00
Akim Demaille
6112cb1802 tests: improve the language independance layer
* tests/local.at (_AT_LANG_DISPATCH): New, shamelessly stolen from
Autoconf's _AT_LANG_DISPATCH.
(AT_LANG_DISPATCH): New.
(AT_YYERROR_FORMALS, AT_YYERROR_PROTOTYPE, AT_YYERROR_DECLARE_EXTERN)
(AT_YYERROR_DECLARE, AT_YYERROR_DEFINE, AT_MAIN_DEFINE, AT_COMPILE)
(AT_FULL_COMPILE):
Use AT_LANG_DISPATCH instead of an ad hoc m4_case.
2013-02-04 16:49:10 +01:00
Akim Demaille
246ff8c1d3 regen 2013-02-04 16:49:10 +01:00
Akim Demaille
f50fa14529 style: space changes in the parser
* src/parse-gram.y: Fix spaces.
2013-02-04 16:49:09 +01:00
Akim Demaille
2c056d696d parser: use api.pure full
* src/parse-gram.y: Use api.pure full instead of silly macro tricks.
2013-02-04 16:49:09 +01:00
Akim Demaille
06505b0c69 style: use a for loop instead of a while loop, and scope reduction
* src/reader.c (packgram): Improve readability.
The parser calls grammar_current_rule_end at the end of every rhs,
which adds a NULL to separate the rules.  So there is no need to
check whether "p" is non-null before proceeding.
2013-02-04 16:46:54 +01:00
Theophile Ranquet
e96415a54b variants: stylistic change
* data/variant.hh (tname): Respect the GNU Coding Standards for this
pointer's declaration.
2013-02-01 15:09:54 +01:00
Theophile Ranquet
f038e56cdc grammar: free the association tracking graph
The graph introduced by Valentin wasn't free'd after use.

* src/symtab.c (assoc_free): New, clear the array of linked lists with...
(linkedlist_free): This, new.
(print_precedence_warnings): Call assoc_free when done.
(print_assoc_warnings): Free used_assoc after use.
2013-02-01 15:06:26 +01:00
Theophile Ranquet
f2e1d4090d tests: use AT_FULL_COMPILE where possible
* tests/c++.at (C++ Variant-based Symbol, Variants): Here.  Rename the
generated input files to use .y instead of .yy, as a requirement for using
AT_FULL_COMPILE instead of a combination of AT_BISON_CHECK and
AT_BISON_COMPILE_CXX.
2013-02-01 15:06:26 +01:00
Theophile Ranquet
be6fa942ac variants: avoid type punning issue
This is based on what is recommended by both Scott Meyers, in 'Effective
C++', and Andrei Alexandrescu and Herb Sutter in 'C++ Coding Standards'.

Use a static_cast on void* rather than directly use a reinterpret_cast,
which can have nefarious effects on objects.  However, even though following
this guideline is good practice in general, I am not quite sure how relevant
it is when applied to conversions from POD to objects.  Actually, it might
very well be the opposite: isn't this exactly what reinterpret_cast is for?
What we really want *is* to transmit the memory map as a series of bytes,
which, if I am correct, falls into the kind of "low level" hack for which
this cast is meant.

In any case, this silences the warning, which will be greatly appreciated by
anyone using variants with a compiler supporting -fstrict-aliasing.

* data/variant.hh (as): Here.
* tests/c++.at (Exception safety, C++ Variant-based Symbols, Variants):
Don't use NO_STRICT_ALIAS_CXXFLAGS (revert commit ddb9db15), as type punning
is no longer an issue.
* tests/atlocal.in, configure.ac (NO_STRICT_ALIAS_CXXFLAGS): Remove
definition.
* examples/local.mk (NO_STRICT_ALIAS_CXXFLAGS): Remove from AM_CXXFLAGS.
* doc/bison.texi: Don't mention type punning issues.
2013-02-01 15:06:20 +01:00
Theophile Ranquet
f29f8af3ed todo: update
Reformulate and give more details on my thoughts concerning the graphical
visualization, and add an entry about a bug in the options processing for
warnings as errors.

* TODO: Here.
2013-02-01 14:44:23 +01:00
Akim Demaille
74ce3cfbf6 regen 2013-02-01 14:26:29 +01:00
Akim Demaille
b805eca764 location: pass the location first
* src/location.h, src/location.c (location_print): For consistency
with other data structures and other location_* routines, pass the
location argument first.
* src/complain.c: Adjust.
(location_caret): Likewise.
* src/parse-gram.y: Adjust.
2013-02-01 14:24:48 +01:00
Akim Demaille
e6c25014bb symlist: use the right stream
* src/symlist.c (symbol_list_syms_print): Use "f", not stderr.
2013-02-01 14:23:49 +01:00
Akim Demaille
97ad789d10 tests: put two related tests together
* tests/conflicts.at (Useless associativity warning): Move next
to "Useless precedence warning".
2013-01-30 21:41:41 +01:00