[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 02/10] yacc.c: do not use __attribute__ unprotected
From: |
Akim Demaille |
Subject: |
[PATCH 02/10] yacc.c: do not use __attribute__ unprotected |
Date: |
Mon, 8 Apr 2013 20:35:48 +0200 |
Reported by Victor Khomenko.
http://lists.gnu.org/archive/html/bug-bison/2013-04/msg00001.html
* data/glr.c (YYUSE, __attribute__): Fuse their definition into...
* data/c.m4 (b4_attribute_define): this new macro.
* data/yacc.c, data/glr.c: Use it.
---
NEWS | 5 +++++
THANKS | 1 +
data/c.m4 | 28 ++++++++++++++++++++++++----
data/glr.c | 19 +------------------
data/yacc.c | 7 +------
5 files changed, 32 insertions(+), 28 deletions(-)
diff --git a/NEWS b/NEWS
index 8da9cf9..b499cc1 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,11 @@ GNU Bison NEWS
* Noteworthy changes in release ?.? (????-??-??) [?]
+** Bug fixes
+
+*** Fix compiler attribute portability (yacc.c)
+
+ With locations enabled, __attribute__ was used unprotected.
* Noteworthy changes in release 2.7 (2012-12-12) [stable]
diff --git a/THANKS b/THANKS
index ed978d3..9b24974 100644
--- a/THANKS
+++ b/THANKS
@@ -121,6 +121,7 @@ Tom Tromey address@hidden
Tommy Nordgren address@hidden
Troy A. Johnson address@hidden
Tys Lefering address@hidden
+Victor Khomenko address@hidden
Vin Shelton address@hidden
W.C.A. Wijngaards address@hidden
Wayne Green address@hidden
diff --git a/data/c.m4 b/data/c.m4
index dc3d303..a1dc2c5 100644
--- a/data/c.m4
+++ b/data/c.m4
@@ -187,9 +187,29 @@ m4_define([b4_table_value_equals],
[(!!(($2) == ($3)))])])
-## ---------##
-## Values. ##
-## ---------##
+## ----------------- ##
+## Compiler issues. ##
+## ----------------- ##
+
+# b4_attribute_define
+# -------------------
+# Provide portability for __attribute__.
+m4_define([b4_attribute_define],
+[#ifndef __attribute__
+/* This feature is available in gcc versions 2.5 and later. */
+# if (! defined __GNUC__ || __GNUC__ < 2 \
+ || (__GNUC__ == 2 && __GNUC_MINOR__ < 5))
+# define __attribute__(Spec) /* empty */
+# endif
+#endif
+
+/* Suppress unused-variable warnings by "using" E. */
+#if ! defined lint || defined __GNUC__
+# define YYUSE(E) ((void) (E))
+#else
+# define YYUSE(E) /* empty */
+#endif
+])
# b4_null_define
@@ -405,7 +425,7 @@ m4_define([b4_c_arg],
## ----------- ##
# b4_sync_start(LINE, FILE)
-# -----------------------
+# -------------------------
m4_define([b4_sync_start], [[#]line $1 $2])
diff --git a/data/glr.c b/data/glr.c
index 02a76c2..958b040 100644
--- a/data/glr.c
+++ b/data/glr.c
@@ -246,13 +246,6 @@ b4_percent_code_get[]dnl
# endif
#endif
-/* Suppress unused-variable warnings by "using" E. */
-#if ! defined lint || defined __GNUC__
-# define YYUSE(E) ((void) (E))
-#else
-# define YYUSE(E) /* empty */
-#endif
-
/* Identity function, used to suppress warnings about constant conditions. */
#ifndef lint
# define YYID(N) (N)
@@ -291,17 +284,7 @@ b4_percent_code_get[]dnl
# define YYLONGJMP(Env, Val) (longjmp (Env, Val), YYASSERT (0))
#endif
-/*-----------------.
-| GCC extensions. |
-`-----------------*/
-
-#ifndef __attribute__
-/* This feature is available in gcc versions 2.5 and later. */
-# if (! defined __GNUC__ || __GNUC__ < 2 \
- || (__GNUC__ == 2 && __GNUC_MINOR__ < 5))
-# define __attribute__(Spec) /* empty */
-# endif
-#endif
+]b4_attribute_define[
#ifndef YYASSERT
# define YYASSERT(Condition) ((void) ((Condition) || (abort (), 0)))
diff --git a/data/yacc.c b/data/yacc.c
index b34549f..abc949b 100644
--- a/data/yacc.c
+++ b/data/yacc.c
@@ -447,12 +447,7 @@ typedef short int yytype_int16;
# endif
#endif
-/* Suppress unused-variable warnings by "using" E. */
-#if ! defined lint || defined __GNUC__
-# define YYUSE(E) ((void) (E))
-#else
-# define YYUSE(E) /* empty */
-#endif
+]b4_attribute_define[
/* Identity function, used to suppress warnings about constant conditions. */
#ifndef lint
--
1.8.2
- [PATCH 00/10] {maint} Prepare 2.7.1, Akim Demaille, 2013/04/09
- [PATCH 03/10] lalr1.cc: fix compiler warnings, Akim Demaille, 2013/04/09
- [PATCH 08/10] build: fix VPATH issue, Akim Demaille, 2013/04/09
- [PATCH 06/10] tests: please clang and use ".cc", not ".c", for C++ input, Akim Demaille, 2013/04/09
- [PATCH 07/10] build: avoid clang's colored diagnostics in the test suite, Akim Demaille, 2013/04/09
- [PATCH 01/10] tests: style changes, Akim Demaille, 2013/04/09
- [PATCH 04/10] skeletons: avoid empty switch constructs, Akim Demaille, 2013/04/09
- [PATCH 10/10] glr.cc: fix a clang warning, Akim Demaille, 2013/04/09
- [PATCH 02/10] yacc.c: do not use __attribute__ unprotected,
Akim Demaille <=
- [PATCH 05/10] gnulib: update, Akim Demaille, 2013/04/09
- [PATCH 09/10] maint: update copyright years, Akim Demaille, 2013/04/09