This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

more -pedantic fixes


This patch:

- moves elimination of __extension__ for old gcc to ansidecl.h, as
  suggested by Kaveh.

- changes 'old gcc' from <2.95 to <2.8, again as suggested by Kaveh.

- adds __extension__ to the statement expressions in the
  tree/rtl/varray checking macros, silencing a few thousand warnings
  (when --enable-checking is used).

It survived a complete build and test with --enable-checking (=misc,tree,rtl)
on i686-linux.  I will send test failures separately.

I have _not_ committed this, because I had to hack up flow.c to get
the tree to build at all - see previous message to gcc-bugs.

zw

gcc:
	* cpphash.h: Remove conditional #define of __extension__.
	* rtl.h: Add __extension__ to RTL_CHECK1, RTL_CHECK2,
	RTL_CHECKC1, RTL_CHECKC2, and RTVEC_ELT macros
	(ENABLE_RTL_CHECKING only).
	* tree.h: Add __extension__ to TREE_CHECK, TREE_CLASS_CHECK,
	CST_OR_CONSTRUCTOR_CHECK, and EXPR_CHECK macros
	(ENABLE_TREE_CHECKING only).
	* varray.h: Add __extension__ to VARRAY_CHECK macro
	(ENABLE_CHECKING only).

include:
	* ansidecl.h: #define __extension__ to nothing if
	GCC_VERSION < 2008.


===================================================================
Index: gcc/cpphash.h
--- gcc/cpphash.h	2000/05/04 16:21:29	1.47
+++ gcc/cpphash.h	2000/05/04 23:44:21
@@ -25,13 +25,6 @@ Foundation, 59 Temple Place - Suite 330,
 typedef unsigned char U_CHAR;
 #define U (const U_CHAR *)  /* Intended use: U"string" */
 
-/* gcc 2.7.2 can't handle __extension__ const char array[] = { ... }.
-   I don't know when this was added - be conservative, assume it only
-   works in 2.95.  */
-#if GCC_VERSION < 2095
-#define __extension__
-#endif
-
 /* The structure of a node in the hash table.  The hash table
    has entries for all tokens defined by #define commands (type T_MACRO),
    plus some special tokens like __LINE__ (these each have their own
===================================================================
Index: gcc/rtl.h
--- gcc/rtl.h	2000/05/04 21:15:05	1.197
+++ gcc/rtl.h	2000/05/04 23:44:25
@@ -219,7 +219,7 @@ typedef struct rtvec_def{
 #if defined ENABLE_RTL_CHECKING && (GCC_VERSION >= 2007)
 /* The bit with a star outside the statement expr and an & inside is
    so that N can be evaluated only once.  */
-#define RTL_CHECK1(RTX, N, C1)						\
+#define RTL_CHECK1(RTX, N, C1) __extension__				\
 (*({ rtx _rtx = (RTX); int _n = (N);					\
      enum rtx_code _code = GET_CODE (_rtx);				\
      if (_n < 0 || _n >= GET_RTX_LENGTH (_code))			\
@@ -230,7 +230,7 @@ typedef struct rtvec_def{
 			       __PRETTY_FUNCTION__);			\
      &_rtx->fld[_n]; }))
 
-#define RTL_CHECK2(RTX, N, C1, C2)					\
+#define RTL_CHECK2(RTX, N, C1, C2) __extension__			\
 (*({ rtx _rtx = (RTX); int _n = (N);					\
      enum rtx_code _code = GET_CODE (_rtx);				\
      if (_n < 0 || _n >= GET_RTX_LENGTH (_code))			\
@@ -242,14 +242,14 @@ typedef struct rtvec_def{
 			       __PRETTY_FUNCTION__);			\
      &_rtx->fld[_n]; }))
 
-#define RTL_CHECKC1(RTX, N, C)						\
+#define RTL_CHECKC1(RTX, N, C) __extension__				\
 (*({ rtx _rtx = (RTX); int _n = (N);					\
      if (GET_CODE (_rtx) != C)						\
        rtl_check_failed_code1 (_rtx, C, __FILE__, __LINE__,		\
 			       __PRETTY_FUNCTION__);			\
      &_rtx->fld[_n]; }))
 
-#define RTL_CHECKC2(RTX, N, C1, C2)					\
+#define RTL_CHECKC2(RTX, N, C1, C2) __extension__			\
 (*({ rtx _rtx = (RTX); int _n = (N);					\
      enum rtx_code _code = GET_CODE (_rtx);				\
      if (_code != C1 && _code != C2)					\
@@ -257,7 +257,7 @@ typedef struct rtvec_def{
 			       __PRETTY_FUNCTION__);			\
      &_rtx->fld[_n]; }))
 
-#define RTVEC_ELT(RTVEC, I)						\
+#define RTVEC_ELT(RTVEC, I) __extension__				\
 (*({ rtvec _rtvec = (RTVEC); int _i = (I);				\
      if (_i < 0 || _i >= GET_NUM_ELEM (_rtvec))				\
        rtvec_check_failed_bounds (_rtvec, _i, __FILE__, __LINE__,	\
===================================================================
Index: gcc/tree.h
--- gcc/tree.h	2000/05/04 21:15:04	1.168
+++ gcc/tree.h	2000/05/04 23:44:26
@@ -277,13 +277,13 @@ struct tree_common
    is accessed incorrectly. The macros abort with a fatal error.  */
 #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
 
-#define TREE_CHECK(t, code)						\
+#define TREE_CHECK(t, code) __extension__				\
 ({  const tree __t = t;							\
     if (TREE_CODE(__t) != (code))					\
       tree_check_failed (__t, code, __FILE__,				\
 			 __LINE__, __PRETTY_FUNCTION__);		\
     __t; })
-#define TREE_CLASS_CHECK(t, class)					\
+#define TREE_CLASS_CHECK(t, class) __extension__			\
 ({  const tree __t = t;							\
     if (TREE_CODE_CLASS(TREE_CODE(__t)) != (class))			\
       tree_class_check_failed (__t, class, __FILE__,			\
@@ -291,14 +291,14 @@ struct tree_common
     __t; })
 
 /* These checks have to be special cased.  */
-#define CST_OR_CONSTRUCTOR_CHECK(t)					\
+#define CST_OR_CONSTRUCTOR_CHECK(t) __extension__			\
 ({  const tree __t = t;							\
     enum tree_code __c = TREE_CODE(__t);				\
     if (__c != CONSTRUCTOR && TREE_CODE_CLASS(__c) != 'c')		\
       tree_check_failed (__t, CONSTRUCTOR, __FILE__,			\
 			 __LINE__, __PRETTY_FUNCTION__);		\
     __t; })
-#define EXPR_CHECK(t)							\
+#define EXPR_CHECK(t) __extension__					\
 ({  const tree __t = t;							\
     char __c = TREE_CODE_CLASS(TREE_CODE(__t));				\
     if (__c != 'r' && __c != 's' && __c != '<'				\
===================================================================
Index: gcc/varray.h
--- gcc/varray.h	2000/04/07 09:24:06	1.18
+++ gcc/varray.h	2000/05/04 23:44:26
@@ -176,7 +176,7 @@ extern varray_type varray_grow	PARAMS ((
 extern void varray_check_failed PARAMS ((varray_type, size_t,
 					const char *, int,
 					const char *)) ATTRIBUTE_NORETURN;
-#define VARRAY_CHECK(VA, N, T)					\
+#define VARRAY_CHECK(VA, N, T) __extension__			\
 (*({ varray_type _va = VA;					\
      size_t _n = N; 						\
      if (_n >= _va->num_elements)				\
===================================================================
Index: include/ansidecl.h
--- include/ansidecl.h	1999/11/30 23:56:52	1.6
+++ include/ansidecl.h	2000/05/04 23:44:32
@@ -222,4 +222,11 @@ So instead we use the macro below and te
 #define ATTRIBUTE_PRINTF_5 ATTRIBUTE_PRINTF(5, 6)
 #endif /* ATTRIBUTE_PRINTF */
 
+/* We use __extension__ in some places to suppress -pedantic warnings
+   about GCC extensions.  This feature didn't work properly before
+   gcc 2.8.  */
+#if GCC_VERSION < 2008
+#define __extension__
+#endif
+
 #endif	/* ansidecl.h	*/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]