Blame SOURCES/gcc32-obstack-lvalues.patch

4ac4fd
2003-10-22  Joseph S. Myers  <jsm@polyomino.org.uk>
4ac4fd
4ac4fd
	* obstack.h: Merge the following change from gnulib:
4ac4fd
	2003-10-21  Paul Eggert  <eggert@twinsun.com>
4ac4fd
	* obstack.h (obstack_1grow_fast): Properly parenthesize arg.
4ac4fd
	(obstack_ptr_grow_fast, obstack_int_grow_fast):
4ac4fd
	Don't use lvalue casts, as GCC plans to remove support for them
4ac4fd
	in GCC 3.5.  Reported by Joseph S. Myers.  This bug
4ac4fd
	was also present in the non-GCC version, indicating that this
4ac4fd
	code had always been buggy and had never been widely used.
4ac4fd
	(obstack_1grow, obstack_ptr_grow, obstack_int_grow, obstack_blank):
4ac4fd
	Use the fast variant of each macro, rather than copying the
4ac4fd
	definiens of the fast variant; that way, we'll be more likely to
4ac4fd
	catch future bugs in the fast variants.
4ac4fd
4ac4fd
--- include/obstack.h	14 Mar 2001 19:44:38 -0000	1.5
4ac4fd
+++ include/obstack.h	22 Oct 2003 22:28:20 -0000	1.6
4ac4fd
@@ -343,7 +343,7 @@ extern int obstack_exit_failure;
4ac4fd
 
4ac4fd
 #endif
4ac4fd
 
4ac4fd
-#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar)
4ac4fd
+#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = (achar))
4ac4fd
 
4ac4fd
 #define obstack_blank_fast(h,n) ((h)->next_free += (n))
4ac4fd
 
4ac4fd
@@ -411,7 +411,7 @@ __extension__								\
4ac4fd
 ({ struct obstack *__o = (OBSTACK);					\
4ac4fd
    if (__o->next_free + 1 > __o->chunk_limit)				\
4ac4fd
      _obstack_newchunk (__o, 1);					\
4ac4fd
-   *(__o->next_free)++ = (datum);					\
4ac4fd
+   obstack_1grow_fast (__o, datum);					\
4ac4fd
    (void) 0; })
4ac4fd
 
4ac4fd
 /* These assume that the obstack alignment is good enough for pointers or ints,
4ac4fd
@@ -423,19 +423,28 @@ __extension__								\
4ac4fd
 ({ struct obstack *__o = (OBSTACK);					\
4ac4fd
    if (__o->next_free + sizeof (void *) > __o->chunk_limit)		\
4ac4fd
      _obstack_newchunk (__o, sizeof (void *));				\
4ac4fd
-   *((void **)__o->next_free)++ = ((void *)datum);			\
4ac4fd
-   (void) 0; })
4ac4fd
+   obstack_ptr_grow_fast (__o, datum); })
4ac4fd
 
4ac4fd
 # define obstack_int_grow(OBSTACK,datum)				\
4ac4fd
 __extension__								\
4ac4fd
 ({ struct obstack *__o = (OBSTACK);					\
4ac4fd
    if (__o->next_free + sizeof (int) > __o->chunk_limit)		\
4ac4fd
      _obstack_newchunk (__o, sizeof (int));				\
4ac4fd
-   *((int *)__o->next_free)++ = ((int)datum);				\
4ac4fd
+   obstack_int_grow_fast (__o, datum); })
4ac4fd
+
4ac4fd
+# define obstack_ptr_grow_fast(OBSTACK,aptr)				\
4ac4fd
+__extension__								\
4ac4fd
+({ struct obstack *__o1 = (OBSTACK);					\
4ac4fd
+   *(const void **) __o1->next_free = (aptr);				\
4ac4fd
+   __o1->next_free += sizeof (const void *);				\
4ac4fd
    (void) 0; })
4ac4fd
 
4ac4fd
-# define obstack_ptr_grow_fast(h,aptr) (*((void **) (h)->next_free)++ = (void *)aptr)
4ac4fd
-# define obstack_int_grow_fast(h,aint) (*((int *) (h)->next_free)++ = (int) aint)
4ac4fd
+# define obstack_int_grow_fast(OBSTACK,aint)				\
4ac4fd
+__extension__								\
4ac4fd
+({ struct obstack *__o1 = (OBSTACK);					\
4ac4fd
+   *(int *) __o1->next_free = (aint);					\
4ac4fd
+   __o1->next_free += sizeof (int);					\
4ac4fd
+   (void) 0; })
4ac4fd
 
4ac4fd
 # define obstack_blank(OBSTACK,length)					\
4ac4fd
 __extension__								\
4ac4fd
@@ -443,7 +452,7 @@ __extension__								\
4ac4fd
    int __len = (length);						\
4ac4fd
    if (__o->chunk_limit - __o->next_free < __len)			\
4ac4fd
      _obstack_newchunk (__o, __len);					\
4ac4fd
-   __o->next_free += __len;						\
4ac4fd
+   obstack_blank_fast (__o, __len);					\
4ac4fd
    (void) 0; })
4ac4fd
 
4ac4fd
 # define obstack_alloc(OBSTACK,length)					\
4ac4fd
@@ -530,26 +539,29 @@ __extension__								\
4ac4fd
 # define obstack_1grow(h,datum)						\
4ac4fd
 ( (((h)->next_free + 1 > (h)->chunk_limit)				\
4ac4fd
    ? (_obstack_newchunk ((h), 1), 0) : 0),				\
4ac4fd
-  (*((h)->next_free)++ = (datum)))
4ac4fd
+  obstack_1grow_fast (h, datum))
4ac4fd
 
4ac4fd
 # define obstack_ptr_grow(h,datum)					\
4ac4fd
 ( (((h)->next_free + sizeof (char *) > (h)->chunk_limit)		\
4ac4fd
    ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0),		\
4ac4fd
-  (*((char **) (((h)->next_free+=sizeof(char *))-sizeof(char *))) = ((char *) datum)))
4ac4fd
+  obstack_ptr_grow_fast (h, datum))
4ac4fd
 
4ac4fd
 # define obstack_int_grow(h,datum)					\
4ac4fd
 ( (((h)->next_free + sizeof (int) > (h)->chunk_limit)			\
4ac4fd
    ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0),			\
4ac4fd
-  (*((int *) (((h)->next_free+=sizeof(int))-sizeof(int))) = ((int) datum)))
4ac4fd
+  obstack_int_grow_fast (h, datum))
4ac4fd
+
4ac4fd
+# define obstack_ptr_grow_fast(h,aptr)					\
4ac4fd
+  (((const void **) ((h)->next_free += sizeof (void *)))[-1] = (aptr))
4ac4fd
 
4ac4fd
-# define obstack_ptr_grow_fast(h,aptr) (*((char **) (h)->next_free)++ = (char *) aptr)
4ac4fd
-# define obstack_int_grow_fast(h,aint) (*((int *) (h)->next_free)++ = (int) aint)
4ac4fd
+# define obstack_int_grow_fast(h,aint)					\
4ac4fd
+  (((int *) ((h)->next_free += sizeof (int)))[-1] = (aptr))
4ac4fd
 
4ac4fd
 # define obstack_blank(h,length)					\
4ac4fd
 ( (h)->temp = (length),							\
4ac4fd
   (((h)->chunk_limit - (h)->next_free < (h)->temp)			\
4ac4fd
    ? (_obstack_newchunk ((h), (h)->temp), 0) : 0),			\
4ac4fd
-  ((h)->next_free += (h)->temp))
4ac4fd
+  obstack_blank_fast (h, (h)->temp))
4ac4fd
 
4ac4fd
 # define obstack_alloc(h,length)					\
4ac4fd
  (obstack_blank ((h), (length)), obstack_finish ((h)))