HAVE_GCC_VERSION fix

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Wed Nov 10 10:18:00 GMT 1999


 > From: "Kaveh R. Ghazi" <ghazi@caip.rutgers.edu>
 > 
 > I added some verbosity to the comments in ansidecl.h and normalized
 > the tests so we were consistent in avoiding needless uses of `!'.
 > Let me know if there are any problems.
 >  
 >                 --Kaveh

Here's what I checked in.


Index: include/ChangeLog
===================================================================
RCS file: /cvs/gcc/egcs/include/ChangeLog,v
retrieving revision 1.26
diff -u -p -r1.26 ChangeLog
--- ChangeLog	1999/10/23 15:56:52	1.26
+++ ChangeLog	1999/11/10 17:48:10
@@ -1,3 +1,8 @@
+Wed Nov 10 12:43:21 1999  Philippe De Muyter  <phdm@macqel.be>
+                          Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+	* ansidecl.h: Define and test `GCC_VERSION', not `HAVE_GCC_VERSION'.
+	
 1999-10-23 08:51 -0700  Zack Weinberg  <zack@bitmover.com>
 
 	* hashtab.h: Give hash_table_t a struct tag.  Add prototypes
Index: include/ansidecl.h
===================================================================
RCS file: /cvs/gcc/egcs/include/ansidecl.h,v
retrieving revision 1.4
diff -u -p -r1.4 ansidecl.h
--- ansidecl.h	1999/10/10 13:02:40	1.4
+++ ansidecl.h	1999/11/10 17:48:13
@@ -160,27 +160,40 @@ Foundation, Inc., 59 Temple Place - Suit
 
 #endif	/* ANSI C.  */
 
-/* This macro will return true if we are using gcc, and it is of a
-   particular minimum version (both major & minor numbers are checked.)  */
-#ifndef HAVE_GCC_VERSION
+
+/* Using MACRO(x,y) in cpp #if conditionals does not work with some
+   older preprocessors.  Thus we can't define something like this:
+
 #define HAVE_GCC_VERSION(MAJOR, MINOR) \
   (__GNUC__ > (MAJOR) || (__GNUC__ == (MAJOR) && __GNUC_MINOR__ >= (MINOR)))
-#endif /* ! HAVE_GCC_VERSION */
+
+and then test "#if HAVE_GCC_VERSION(2,7)".
+
+So instead we use the macro below and test it against specific values.  */
+
+/* This macro simplifies testing whether we are using gcc, and if it
+   is of a particular minimum version. (Both major & minor numbers are
+   significant.)  This macro will evaluate to 0 if we are not using
+   gcc at all.  */
+#ifndef GCC_VERSION
+#define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
+#endif /* GCC_VERSION */
 
 /* Define macros for some gcc attributes.  This permits us to use the
    macros freely, and know that they will come into play for the
    version of gcc in which they are supported.  */
 
-#if ! HAVE_GCC_VERSION(2,7)
+#if (GCC_VERSION < 2007)
 # define __attribute__(x)
 #endif
 
+/* Attributes on labels were valid as of gcc 2.93. */
 #ifndef ATTRIBUTE_UNUSED_LABEL
-# if ! HAVE_GCC_VERSION(2,93)
-#  define ATTRIBUTE_UNUSED_LABEL
-# else
+# if (GCC_VERSION >= 2093)
 #  define ATTRIBUTE_UNUSED_LABEL ATTRIBUTE_UNUSED
-# endif /* GNUC < 2.93 */
+# else
+#  define ATTRIBUTE_UNUSED_LABEL
+# endif /* GNUC >= 2.93 */
 #endif /* ATTRIBUTE_UNUSED_LABEL */
 
 #ifndef ATTRIBUTE_UNUSED
Index: gcc/ChangeLog
===================================================================
RCS file: /cvs/gcc/egcs/gcc/ChangeLog,v
retrieving revision 1.4955
diff -u -p -r1.4955 ChangeLog
--- ChangeLog	1999/11/10 17:17:14	1.4955
+++ ChangeLog	1999/11/10 17:48:24
@@ -1,3 +1,24 @@
+Wed Nov 10 12:43:21 1999  Philippe De Muyter  <phdm@macqel.be>
+                          Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+	* cppinit.c: Test `GCC_VERSION', not `HAVE_GCC_VERSION'.
+
+	* gansidecl.h: Likewise.
+
+	* rtl.c: Likewise.
+
+	* rtl.h: Likewise.
+
+	* toplev.h: Likewise.
+
+	* tree.c: Likewise.
+
+	* tree.h: Likewise.
+
+	* varray.c: Likewise.
+
+	* varray.h: Likewise.
+
 Wed Nov 10 10:57:22 1999  Clinton Popetz  <cpopetz@cygnus.com>
 
 	* gcov.c (struct arcdata): Add hits and total, remove prob.
Index: gcc/cppinit.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cppinit.c,v
retrieving revision 1.23
diff -u -p -r1.23 cppinit.c
--- cppinit.c	1999/10/29 04:31:13	1.23
+++ cppinit.c	1999/11/10 17:48:25
@@ -216,7 +216,7 @@ enum { QUOTE = 0, BRACKET, SYSTEM, AFTER
 #define CAT(a, b) a/**/b
 #endif
 
-#if HAVE_GCC_VERSION(2,7)
+#if (GCC_VERSION >= 2007)
 #define TABLE(id) static inline void CAT(init_, id) PARAMS ((void)) {} \
 unsigned char id[256] = {
 #define s(p, v) [p] = v,
Index: gcc/gansidecl.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/gansidecl.h,v
retrieving revision 1.20
diff -u -p -r1.20 gansidecl.h
--- gansidecl.h	1999/10/10 13:02:41	1.20
+++ gansidecl.h	1999/11/10 17:48:25
@@ -41,7 +41,7 @@ Boston, MA 02111-1307, USA.  */
    need to do this very early; i.e. before any systems header files or
    gcc header files in case they use these keywords.  Otherwise
    conflicts might occur. */
-#if HAVE_GCC_VERSION(2,7)
+#if (GCC_VERSION >= 2007)
 # undef const
 # undef inline
 # define inline __inline__  /* Modern gcc can use `__inline__' freely. */
Index: gcc/rtl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/rtl.c,v
retrieving revision 1.54
diff -u -p -r1.54 rtl.c
--- rtl.c	1999/11/04 21:35:22	1.54
+++ rtl.c	1999/11/10 17:48:26
@@ -1128,7 +1128,7 @@ read_rtx (infile)
   return return_rtx;
 }
 
-#if defined ENABLE_CHECKING && HAVE_GCC_VERSION(2,7)
+#if defined ENABLE_CHECKING && (GCC_VERSION >= 2007)
 void
 rtl_check_failed_bounds (r, n, file, line, func)
     rtx r;
Index: gcc/rtl.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/rtl.h,v
retrieving revision 1.154
diff -u -p -r1.154 rtl.h
--- rtl.h	1999/11/04 07:23:58	1.154
+++ rtl.h	1999/11/10 17:48:27
@@ -226,7 +226,7 @@ typedef struct rtvec_def{
 
 /* General accessor macros for accessing the fields of an rtx.  */
 
-#if defined ENABLE_CHECKING  && HAVE_GCC_VERSION(2,7)
+#if defined ENABLE_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)						\
@@ -1679,10 +1679,10 @@ extern int read_rtx_lineno;
 
 extern void fancy_abort PROTO((const char *, int, const char *))
     ATTRIBUTE_NORETURN;
-#if ! HAVE_GCC_VERSION(2,7)
-#define abort() fancy_abort (__FILE__, __LINE__, 0)
-#else
+#if (GCC_VERSION >= 2007)
 #define abort() fancy_abort (__FILE__, __LINE__, __PRETTY_FUNCTION__)
+#else
+#define abort() fancy_abort (__FILE__, __LINE__, 0)
 #endif
 
 /* In alias.c */
Index: gcc/toplev.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/toplev.h,v
retrieving revision 1.27
diff -u -p -r1.27 toplev.h
--- toplev.h	1999/10/10 13:02:41	1.27
+++ toplev.h	1999/11/10 17:48:27
@@ -51,7 +51,7 @@ extern void _fatal_insn			PROTO ((const 
 						const char *))
   ATTRIBUTE_NORETURN;
 
-#if HAVE_GCC_VERSION(2,7)
+#if (GCC_VERSION >= 2007)
 #define fatal_insn(msgid, insn) \
 	_fatal_insn (msgid, insn, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 #define fatal_insn_not_found(insn) \
Index: gcc/tree.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tree.c,v
retrieving revision 1.102
diff -u -p -r1.102 tree.c
--- tree.c	1999/11/08 15:27:56	1.102
+++ tree.c	1999/11/10 17:48:32
@@ -5136,7 +5136,7 @@ get_set_constructor_bytes (init, buffer,
   return non_const_bits;
 }
 
-#if defined ENABLE_CHECKING && HAVE_GCC_VERSION(2,7)
+#if defined ENABLE_CHECKING && (GCC_VERSION >= 2007)
 /* Complain that the tree code of NODE does not match the expected CODE.
    FILE, LINE, and FUNCTION are of the caller.  */
 void
Index: gcc/tree.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tree.h,v
retrieving revision 1.101
diff -u -p -r1.101 tree.h
--- tree.h	1999/11/08 15:27:56	1.101
+++ tree.h	1999/11/10 17:48:37
@@ -321,7 +321,7 @@ struct tree_common
 
 /* When checking is enabled, errors will be generated if a tree node
    is accessed incorrectly. The macros abort with a fatal error.  */
-#if defined ENABLE_CHECKING && HAVE_GCC_VERSION(2,7)
+#if defined ENABLE_CHECKING && (GCC_VERSION >= 2007)
 
 #define TREE_CHECK(t, code)						\
 ({  const tree __t = t;							\
@@ -2513,8 +2513,8 @@ extern void dwarf2out_end_epilogue	PROTO
 
 extern void fancy_abort PROTO((const char *, int, const char *))
     ATTRIBUTE_NORETURN;
-#if ! HAVE_GCC_VERSION(2,7)
-#define abort() fancy_abort (__FILE__, __LINE__, 0)
-#else
+#if (GCC_VERSION >= 2007)
 #define abort() fancy_abort (__FILE__, __LINE__, __PRETTY_FUNCTION__)
+#else
+#define abort() fancy_abort (__FILE__, __LINE__, 0)
 #endif
Index: gcc/varray.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/varray.c,v
retrieving revision 1.4
diff -u -p -r1.4 varray.c
--- varray.c	1999/10/10 13:02:41	1.4
+++ varray.c	1999/11/10 17:48:37
@@ -71,7 +71,7 @@ varray_grow (va, n)
 
 /* Check the bounds of a varray access.  */
 
-#if defined ENABLE_CHECKING && HAVE_GCC_VERSION(2,7)
+#if defined ENABLE_CHECKING && (GCC_VERSION >= 2007)
 
 extern void error PVPROTO ((const char *, ...))	ATTRIBUTE_PRINTF_1;
 
Index: gcc/varray.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/varray.h,v
retrieving revision 1.12
diff -u -p -r1.12 varray.h
--- varray.h	1999/10/10 13:02:41	1.12
+++ varray.h	1999/11/10 17:48:39
@@ -163,7 +163,7 @@ extern varray_type varray_grow	PROTO((va
 #define VARRAY_SIZE(VA)	((VA)->num_elements)
 
 /* Check for VARRAY_xxx macros being in bound.  */
-#if defined ENABLE_CHECKING && HAVE_GCC_VERSION(2,7)
+#if defined ENABLE_CHECKING && (GCC_VERSION >= 2007)
 extern void varray_check_failed PROTO ((varray_type, size_t,
 					const char *, int,
 					const char *)) ATTRIBUTE_NORETURN;
Index: gcc/f/ChangeLog
===================================================================
RCS file: /cvs/gcc/egcs/gcc/f/ChangeLog,v
retrieving revision 1.217
diff -u -p -r1.217 ChangeLog
--- ChangeLog	1999/10/26 08:34:46	1.217
+++ ChangeLog	1999/11/10 17:48:40
@@ -1,3 +1,8 @@
+Wed Nov 10 12:43:21 1999  Philippe De Muyter  <phdm@macqel.be>
+                          Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+	* proj.h: Test `GCC_VERSION', not `HAVE_GCC_VERSION'.
+
 Tue Oct 26 01:32:19 1999  Mark Mitchell  <mark@codesourcery.com>
 
 	* com.c (poplevel): Don't call remember_end_note.
Index: gcc/f/proj.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/f/proj.h,v
retrieving revision 1.12
diff -u -p -r1.12 proj.h
--- proj.h	1999/10/10 13:02:41	1.12
+++ proj.h	1999/11/10 17:48:40
@@ -31,7 +31,7 @@ the Free Software Foundation, 59 Temple 
 #endif
 #include "system.j"
 
-#if ! HAVE_GCC_VERSION(2,0)
+#if (GCC_VERSION < 2000)
 #error "You have to use gcc 2.x to build g77 (might be fixed in g77-0.6)."
 #endif
 
Index: gcc/cp/ChangeLog
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/ChangeLog,v
retrieving revision 1.1411
diff -u -p -r1.1411 ChangeLog
--- ChangeLog	1999/11/09 08:15:07	1.1411
+++ ChangeLog	1999/11/10 17:49:00
@@ -1,3 +1,8 @@
+Wed Nov 10 12:43:21 1999  Philippe De Muyter  <phdm@macqel.be>
+                          Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+	* cp-tree.h: Test `GCC_VERSION', not `HAVE_GCC_VERSION'.
+
 1999-11-09  Mark Mitchell  <mark@codesourcery.com>
 
 	* cp-tree.h (language_function): Remove x_last_dtor_insn and
Index: gcc/cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/cp-tree.h,v
retrieving revision 1.343
diff -u -p -r1.343 cp-tree.h
--- cp-tree.h	1999/11/09 08:15:07	1.343
+++ cp-tree.h	1999/11/10 17:49:06
@@ -124,7 +124,7 @@ Boston, MA 02111-1307, USA.  */
 
 /* Language-specific tree checkers. */
 
-#if defined ENABLE_CHECKING && HAVE_GCC_VERSION(2,7)
+#if defined ENABLE_CHECKING && (GCC_VERSION >= 2007)
 
 #define VAR_OR_FUNCTION_DECL_CHECK(NODE)			\
 ({  const tree __t = NODE;					\


More information about the Gcc-patches mailing list