mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
In C++ pre C++11 it is standard practice to use 0 for the null pointer. But GCC pre 8 -std=c++98 with -Wzero-as-null-pointer-constant warns about this. So disable -Wzero-as-null-pointer-constant when compiling C++ pre 11. Let's do this in AT_DATA_SOURCE_PROLOGUE (which is pasted on top of all the test grammar files). Unfortunately, that shifts all the locations in the expected error messages, which would be too noisy. Instead, let's introduce testsuite.h, which can vary in length, and include it in AT_DATA_SOURCE_PROLOGUE. * tests/testsuite.h: New. Disable -Wzero-as-null-pointer-constant's warning with GCC pre 8, C++ pre 11. * tests/local.at (AT_DATA_SOURCE_PROLOGUE): Use it. * tests/atlocal.in (CPPFLAGS): Find it. * tests/local.mk: Ship it. * data/c.m4 (YY_NULLPTR): Prefer ((void*)0) to 0 in C.
15 lines
528 B
C
15 lines
528 B
C
#include <config.h>
|
|
/* We don't need perfect functions for these tests. */
|
|
#undef malloc
|
|
#undef memcmp
|
|
#undef realloc
|
|
|
|
/* In C++ pre C++11 it is standard practice to use 0 for the null
|
|
pointer. But GCC -std=c++98 with -Wzero-as-null-pointer-constant
|
|
warns about this. Warning introduced in GCC 4.7. */
|
|
#if defined __cplusplus && __cplusplus < 201103L
|
|
# if defined __GNUC__ && ! defined __clang__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
|
|
# pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
|
|
# endif
|
|
#endif
|