c++: use nullptr for C++11.

C++11 introduces "nullptr" which plays the role of C's NULL, in
replacement of "0".  Fix the C++ skeletons to avoid warnings about
uses of "0" in place of "nullptr", and improve C skeletons to also use
this "nullptr" when compiled with a C++11 compiler.

* configure.ac: More C++ warnings.
* NEWS (2.5.1): Document this.
* data/c++.m4, data/c.m4 (b4_null_define): New.
(b4_null): Use YY_NULL instead of 0.
* data/glr.c, data/lalr1.cc, data/location.cc, data/yacc.c:
Call b4_null_define/b4_null where appropriate.
Use YY_NULL instead of NULL.
* data/location.cc (initialize): Accept a default argument,
YY_NULL.
* tests/actions.at, tests/calc.at: Adjust.

* data/glr.c, lib/libiberty.h, src/system.h (__attribute__):
Do not disable it when __STRICT_ANSI__ is defined, as, for
instance, it disables the __attribute__((unused)) which
protects us from some compiler warnings.
This was already done elsewhere in Bison, in 2001, see
4a0d893695.
* tests/regression.at: Adjust output.
This commit is contained in:
Akim Demaille
2012-03-30 15:50:45 +02:00
parent e85056ef5f
commit ef51bfa744
13 changed files with 105 additions and 73 deletions

View File

@@ -20,7 +20,7 @@ m4_changecom()
m4_divert_push(0)dnl
@output(b4_dir_prefix[]position.hh@)@
b4_copyright([Positions for Bison parsers in C++],
[2002-2007, 2009-2011])[
[2002-2007, 2009-2012])[
/**
** \file position.hh
@@ -34,6 +34,8 @@ b4_copyright([Positions for Bison parsers in C++],
# include <string>
# include <algorithm>
]b4_null_define[
]b4_namespace_open[
/// Abstract a position.
class position
@@ -42,13 +44,13 @@ b4_copyright([Positions for Bison parsers in C++],
]m4_ifdef([b4_location_constructors], [
/// Construct a position.
position ()
: filename (0), line (]b4_location_initial_line[), column (]b4_location_initial_column[)
: filename (YY_NULL), line (]b4_location_initial_line[), column (]b4_location_initial_column[)
{
}
])[
/// Initialization.
inline void initialize (]b4_percent_define_get([[filename_type]])[* fn)
inline void initialize (]b4_percent_define_get([[filename_type]])[* fn = YY_NULL)
{
filename = fn;
line = ]b4_location_initial_line[;
@@ -174,7 +176,7 @@ b4_copyright([Locations for Bison parsers in C++],
])[
/// Initialization.
inline void initialize (]b4_percent_define_get([[filename_type]])[* fn)
inline void initialize (]b4_percent_define_get([[filename_type]])[* fn = YY_NULL)
{
begin.initialize (fn);
end = begin;