diff --git a/data/skeletons/glr.cc b/data/skeletons/glr.cc index 56279f42..35cbd4cf 100644 --- a/data/skeletons/glr.cc +++ b/data/skeletons/glr.cc @@ -221,7 +221,25 @@ m4_define([b4_define_symbol_kind], # Setup redirections for glr.c: Map the names used in c.m4 to the ones used # in c++.m4. m4_define([b4_glr_cc_setup], -[[#undef ]b4_symbol(-2, [id])[ +[[]b4_attribute_define[ +]b4_null_define[ + +// This skeleton is based on C, yet compiles it as C++. +// So expect warnings about C style casts. +#if defined __clang__ && 306 <= __clang_major__ * 100 + __clang_minor__ +# pragma clang diagnostic ignored "-Wold-style-cast" +#elif defined __GNUC__ && 406 <= __GNUC__ * 100 + __GNUC_MINOR__ +# pragma GCC diagnostic ignored "-Wold-style-cast" +#endif + +// On MacOS, PTRDIFF_MAX is defined as long long, which Clang's +// -pedantic reports as being a C++11 extension. +#if defined __APPLE__ && YY_CPLUSPLUS < 201103L \ + && defined __clang__ && 4 <= __clang_major__ +# pragma clang diagnostic ignored "-Wc++11-long-long" +#endif + +#undef ]b4_symbol(-2, [id])[ #define ]b4_symbol(-2, [id])[ ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(-2, [id])[ #undef ]b4_symbol(0, [id])[ #define ]b4_symbol(0, [id])[ ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(0, [id])[ @@ -277,24 +295,6 @@ b4_percent_code_get([[requires]])[ [[# include ]b4_location_include])[ ]b4_variant_if([b4_variant_includes])[ -]b4_attribute_define[ -]b4_null_define[ - -// This skeleton is based on C, yet compiles it as C++. -// So expect warnings about C style casts. -#if defined __clang__ && 306 <= __clang_major__ * 100 + __clang_minor__ -# pragma clang diagnostic ignored "-Wold-style-cast" -#elif defined __GNUC__ && 406 <= __GNUC__ * 100 + __GNUC_MINOR__ -# pragma GCC diagnostic ignored "-Wold-style-cast" -#endif - -// On MacOS, PTRDIFF_MAX is defined as long long, which Clang's -// -pedantic reports as being a C++11 extension. -#if defined __APPLE__ && YY_CPLUSPLUS < 201103L \ - && defined __clang__ && 4 <= __clang_major__ -# pragma clang diagnostic ignored "-Wc++11-long-long" -#endif - // Whether we are compiled with exception support. #ifndef YY_EXCEPTIONS # if defined __GNUC__ && !defined __EXCEPTIONS diff --git a/data/skeletons/glr2.cc b/data/skeletons/glr2.cc index e463ffb3..5f6a5c95 100644 --- a/data/skeletons/glr2.cc +++ b/data/skeletons/glr2.cc @@ -122,21 +122,6 @@ b4_percent_code_get([[requires]])[ [[# include ]b4_location_include])[ ]b4_variant_if([b4_variant_includes])[ -]b4_attribute_define[ -]b4_cast_define[ -]b4_null_define[ - -#if defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__ && __GNUC__ <= 9 -# define YY_IGNORE_NULL_DEREFERENCE_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wnull-dereference\"") -# define YY_IGNORE_NULL_DEREFERENCE_END \ - _Pragma ("GCC diagnostic pop") -#else -# define YY_IGNORE_NULL_DEREFERENCE_BEGIN -# define YY_IGNORE_NULL_DEREFERENCE_END -#endif - // Whether we are compiled with exception support. #ifndef YY_EXCEPTIONS # if defined __GNUC__ && !defined __EXCEPTIONS @@ -567,6 +552,20 @@ static YYLTYPE yyloc_default][]b4_yyloc_default;])[ ]b4_attribute_define([noreturn])[ +#if defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__ && __GNUC__ <= 9 +# define YY_IGNORE_NULL_DEREFERENCE_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wnull-dereference\"") +# define YY_IGNORE_NULL_DEREFERENCE_END \ + _Pragma ("GCC diagnostic pop") +#else +# define YY_IGNORE_NULL_DEREFERENCE_BEGIN +# define YY_IGNORE_NULL_DEREFERENCE_END +#endif + +]b4_null_define[ +]b4_cast_define[ + #ifndef YYASSERT # define YYASSERT(Condition) ((void) ((Condition) || (abort (), 0))) #endif diff --git a/tests/regression.at b/tests/regression.at index 6efeb1cc..9e288b61 100644 --- a/tests/regression.at +++ b/tests/regression.at @@ -1505,7 +1505,8 @@ m4_pushdef([AT_TEST], AT_BISON_OPTION_PUSHDEFS([%locations %skeleton "$1" %parse-param { int x } %parse-param { int y }]) AT_DATA_GRAMMAR([input.y], -[[%locations +[[%defines +%locations %skeleton "$1" %union { int ival; } %parse-param { int x }