Merge branch 'maint'

* origin/maint:
  NEWS: warnings with clang
  warnings: avoid warnings from clang
  tests: no longer disable -O compiler options
  yacc.c: initialize yylval in pure-parser mode
  skeletons: style changes
  lalr1.cc: document exception safety
  lalr1.cc: check exception safety of error handling
  lalr1.cc: check (and fix) %printer exception safety
  lalr1.cc: check (and fix) %initial-action exception safety
  lalr1.cc: fix exception safety
  lalr1.cc: check exception safety.
  lalr1.cc: indentation fixes.
  lalr1.cc: don't leave macros define to nothing
  tests: minor improvements
  tests: use $PERL instead of perl
  build: look for Perl in configure.
  tests: fix sed portability issues
  tests: diff -u is not portable

Conflicts:
	data/c.m4
	data/glr.c
	data/lalr1.cc
	data/yacc.c
	doc/Makefile.am
	tests/atlocal.in
	tests/calc.at
This commit is contained in:
Akim Demaille
2012-10-10 17:31:25 +02:00
18 changed files with 388 additions and 71 deletions

View File

@@ -202,7 +202,7 @@ m4_define([b4_table_value_equals],
[m4_if(m4_eval($3 < m4_indir([b4_]$1[_min])
|| m4_indir([b4_]$1[_max]) < $3), [1],
[[0]],
[[((]$2[) == (]$3[))]])])
[(!!(($2) == ($3)))])])
## ---------##

View File

@@ -250,19 +250,19 @@ b4_percent_code_get[]dnl
# if defined YYENABLE_NLS && YYENABLE_NLS
# if ENABLE_NLS
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
# define YY_(msgid) dgettext ("bison-runtime", msgid)
# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
# endif
# endif
# ifndef YY_
# define YY_(msgid) msgid
# define YY_(Msgid) Msgid
# endif
#endif
/* Suppress unused-variable warnings by "using" E. */
#ifdef __GNUC__
# define YYUSE(e) ((void) (e))
# define YYUSE(E) ((void) (E))
#else
# define YYUSE(e) /* empty */
# define YYUSE(E) /* empty */
#endif
#ifndef YYFREE
@@ -288,8 +288,9 @@ b4_percent_code_get[]dnl
#ifndef YYSETJMP
# include <setjmp.h>
# define YYJMP_BUF jmp_buf
# define YYSETJMP(env) setjmp (env)
# define YYLONGJMP(env, val) longjmp (env, val)
# define YYSETJMP(Env) setjmp (Env)
// Pacify clang.
# define YYLONGJMP(Env, Val) (longjmp (Env, Val), YYASSERT (0))
#endif
/*-----------------.
@@ -312,7 +313,7 @@ b4_percent_code_get[]dnl
#endif])[
#ifndef YYASSERT
# define YYASSERT(condition) ((void) ((condition) || (abort (), 0)))
# define YYASSERT(Condition) ((void) ((Condition) || (abort (), 0)))
#endif
/* YYFINAL -- State number of the termination state. */
@@ -406,7 +407,7 @@ dnl We probably ought to introduce a type for confl.
{
]b4_conflicting_rules[
};
/* Error token number */
#define YYTERROR 1
@@ -913,8 +914,8 @@ yylhsNonterm (yyRuleNum yyrule)
return yyr1[yyrule];
}
#define yypact_value_is_default(yystate) \
]b4_table_value_equals([[pact]], [[yystate]], [b4_pact_ninf])[
#define yypact_value_is_default(Yystate) \
]b4_table_value_equals([[pact]], [[Yystate]], [b4_pact_ninf])[
/** True iff LR state YYSTATE has only a default reduction (regardless
* of token). */
@@ -931,8 +932,8 @@ yydefaultAction (yyStateNum yystate)
return yydefact[yystate];
}
#define yytable_value_is_error(yytable_value) \
]b4_table_value_equals([[table]], [[yytable_value]], [b4_table_ninf])[
#define yytable_value_is_error(Yytable_value) \
]b4_table_value_equals([[table]], [[Yytable_value]], [b4_table_ninf])[
/** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN.
* Result R means

View File

@@ -683,6 +683,10 @@ m4_if(b4_prefix, [yy], [],
/// The return value of parse ().
int yyresult;
// FIXME: This shoud be completely indented. It is not yet to
// avoid gratuitous conflicts when merging into the master branch.
try
{
YYCDEBUG << "Starting parse" << std::endl;
]m4_ifdef([b4_initial_action], [
@@ -955,7 +959,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
/* Do not reclaim the symbols of the rule which action triggered
this YYABORT or YYACCEPT. */
yypop_ (yylen);
while (yystack_.size () != 1)
while (1 < yystack_.size ())
{
yy_destroy_ ("Cleanup: popping", yystack_[0]);
yypop_ ();
@@ -963,6 +967,23 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
return yyresult;
}
catch (...)
{
YYCDEBUG << "Exception caught: cleaning lookahead and stack"
<< std::endl;
// Do not try to display the values of the reclaimed symbols,
// as their printer might throw an exception.
if (!yyempty)
yy_destroy_ (YY_NULL, yyla);
while (1 < yystack_.size ())
{
yy_destroy_ (YY_NULL, yystack_[0]);
yypop_ ();
}
throw;
}
}
void
]b4_parser_class_name[::error (const syntax_error& yyexc)

View File

@@ -172,6 +172,28 @@ m4_define([b4_declare_scanner_communication_variables], [[
/* The lookahead symbol. */
int yychar;
]b4_pure_if([[
#if defined __GNUC__ && (4 < __GNUC__ + (6 <= __GNUC_MINOR__))
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
_Pragma ("GCC diagnostic pop")
#else
/* Default value used for initialization, for pacifying older GCCs
or non-GCC compilers. */
static YYSTYPE yyval_default;
# define YYLVAL_INITIALIZE() (yylval = yyval_default)
#endif]])[
#ifndef YYLVAL_INITIALIZE
# define YYLVAL_INITIALIZE()
#endif
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
#endif
/* The semantic value of the lookahead symbol. */
YYSTYPE yylval;]b4_locations_if([[
@@ -397,19 +419,19 @@ typedef short int yytype_int16;
# if defined YYENABLE_NLS && YYENABLE_NLS
# if ENABLE_NLS
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
# define YY_(msgid) dgettext ("bison-runtime", msgid)
# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
# endif
# endif
# ifndef YY_
# define YY_(msgid) msgid
# define YY_(Msgid) Msgid
# endif
#endif
/* Suppress unused-variable warnings by "using" E. */
#ifdef __GNUC__
# define YYUSE(e) ((void) (e))
# define YYUSE(E) ((void) (E))
#else
# define YYUSE(e) /* empty */
# define YYUSE(E) /* empty */
#endif
#if ]b4_lac_if([[1]], [[! defined yyoverflow || YYERROR_VERBOSE]])[
@@ -602,13 +624,13 @@ static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
#define YYPACT_NINF ]b4_pact_ninf[
#define yypact_value_is_default(yystate) \
]b4_table_value_equals([[pact]], [[yystate]], [b4_pact_ninf])[
#define yypact_value_is_default(Yystate) \
]b4_table_value_equals([[pact]], [[Yystate]], [b4_pact_ninf])[
#define YYTABLE_NINF ]b4_table_ninf[
#define yytable_value_is_error(yytable_value) \
]b4_table_value_equals([[table]], [[yytable_value]], [b4_table_ninf])[
#define yytable_value_is_error(Yytable_value) \
]b4_table_value_equals([[table]], [[Yytable_value]], [b4_table_ninf])[
]b4_parser_tables_define[
@@ -1454,8 +1476,9 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[
The wasted elements are never initialized. */
yyssp = yyss;
yyvsp = yyvs;]b4_locations_if([[
yylsp = yyls;
yylsp = yyls;]])[
YYLVAL_INITIALIZE ();]b4_locations_if([[
#if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
/* Initialize the default location before parsing starts. */
yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[;
@@ -1641,7 +1664,9 @@ yyread_pushed_token:]])[
YY_LAC_DISCARD ("shift");]])[
yystate = yyn;
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
]b4_locations_if([ *++yylsp = yylloc;])[
goto yynewstate;
@@ -1861,7 +1886,9 @@ yyerrlab1:
current lookahead token, the shift below will for sure. */
YY_LAC_DISCARD ("error recovery");]])[
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
]b4_locations_if([[
yyerror_range[2] = yylloc;
/* Using YYLLOC is tempting, but would change the location of