>From cbfe33545514c0c6b837fb57ad5d4f1c094771ab Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 17 Oct 2019 11:28:38 -0700 Subject: [PATCH 04/11] c: port YY_ATTRIBUTE_UNUSED to Sun C 5.12 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sun C 5.12 defines __SUNPRO_C to 0x5120 but diagnoses ‘__attribute__ ((__unused__))’. Change the ifdefs to use the same method as Gnulib in this area. * data/skeletons/c.m4 (YY_ATTRIBUTE): Remove, since not all attributes were added in the same compiler version. (YY_ATTRIBUTE_PURE, YY_ATTRIBUTE_UNUSED): Use specific GCC version for each attribute. Pay no attention to __SUNPRO_C. * tests/headers.at (Several parsers): Tighten tests accordingly. --- data/skeletons/c.m4 | 20 +++++++++----------- tests/headers.at | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/data/skeletons/c.m4 b/data/skeletons/c.m4 index 4580fd75..a1d55d47 100644 --- a/data/skeletons/c.m4 +++ b/data/skeletons/c.m4 @@ -282,22 +282,20 @@ m4_define([b4_table_value_equals], # Provide portable compiler "attributes". If "noreturn" is passed, define # _Noreturn. m4_define([b4_attribute_define], -[[#ifndef YY_ATTRIBUTE -# if (defined __GNUC__ \ - && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ - || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C -# define YY_ATTRIBUTE(Spec) __attribute__(Spec) +[[#ifndef YY_ATTRIBUTE_PURE +# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) # else -# define YY_ATTRIBUTE(Spec) /* empty */ +# define YY_ATTRIBUTE_PURE # endif #endif -#ifndef YY_ATTRIBUTE_PURE -# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) -#endif - #ifndef YY_ATTRIBUTE_UNUSED -# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) +# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) +# else +# define YY_ATTRIBUTE_UNUSED +# endif #endif ]m4_bmatch([$1], [\bnoreturn\b], [[/* The _Noreturn keyword of C11. */ diff --git a/tests/headers.at b/tests/headers.at index d1e75bf8..390dfa4c 100644 --- a/tests/headers.at +++ b/tests/headers.at @@ -321,7 +321,7 @@ AT_PERL_CHECK([[-n -0777 -e ' |YYChar |YYPUSH_MORE(?:_DEFINED)? |YYUSE - |YY_ATTRIBUTE(?:_PURE|_UNUSED)? + |YY_ATTRIBUTE(?:_PURE|_UNUSED) |YY_CONSTEXPR |YY_COPY |YY_CPLUSPLUS -- 2.21.0