Patchwork non-GNU C++ compilers

login
register
mail settings
Submitter Marc Glisse
Date Aug. 8, 2011, 12:30 p.m.
Message ID <alpine.DEB.2.02.1108081332500.3776@stedding.saclay.inria.fr>
Download mbox | patch
Permalink /patch/108903/
State New
Headers show

Comments

Marc Glisse - Aug. 8, 2011, 12:30 p.m.
Hello,

this helps C++ compilers that do not define __GNUC__ compile gcc.

Bootstrapped:
1) CC=gcc with --disable-build-poststage1-with-cxx
2) CC=suncc

The second one required a fix for PR49907. I didn't build with sunCC 
simply because it requires several more patches.

Issues were discussed there:
http://gcc.gnu.org/ml/gcc/2011-07/msg00523.html
http://gcc.gnu.org/ml/gcc/2011-08/msg00006.html

Note that I can't commit.

2011-08-08  Marc Glisse  <marc.glisse@inria.fr>

 	* include/ansidecl.h (ENUM_BITFIELD): Always use enum in C++
 	* include/obstack.h (obstack_free): Cast to char* instead of int
Joseph S. Myers - Aug. 8, 2011, 8:56 p.m.
On Mon, 8 Aug 2011, Marc Glisse wrote:

> 	* include/obstack.h (obstack_free): Cast to char* instead of int

This header comes from glibc/gnulib.  Although some local changes have 
been made to it in the past, sending any fixes to upstream glibc is still 
a good idea.

(ansidecl.h *claims* to come from glibc but the glibc copy was removed in 
1997.  obstack.h really does still come from glibc.)
Marc Glisse - Aug. 8, 2011, 10:13 p.m.
On Mon, 8 Aug 2011, Joseph S. Myers wrote:

> On Mon, 8 Aug 2011, Marc Glisse wrote:
>
>> 	* include/obstack.h (obstack_free): Cast to char* instead of int
>
> This header comes from glibc/gnulib.  Although some local changes have
> been made to it in the past, sending any fixes to upstream glibc is still
> a good idea.
>
> (ansidecl.h *claims* to come from glibc but the glibc copy was removed in
> 1997.  obstack.h really does still come from glibc.)

Ah, ok, thanks, that's confusing indeed.

/me takes a look at malloc/obstack.h in glibc.

Er, the 2 seem to have diverged quite a bit. I will send a similar patch 
to glibc (not quite the same as obstack_free already looks different), but 
it looks like gcc still needs patching independently.
Marc Glisse - Aug. 20, 2011, 4:40 p.m.
On Mon, 8 Aug 2011, Joseph S. Myers wrote:

> On Mon, 8 Aug 2011, Marc Glisse wrote:
>
>> 	* include/obstack.h (obstack_free): Cast to char* instead of int
>
> This header comes from glibc/gnulib.  Although some local changes have
> been made to it in the past, sending any fixes to upstream glibc is still
> a good idea.

http://sourceware.org/bugzilla/show_bug.cgi?id=13067

(doesn't help gcc much, but it is in glibc's bugzilla now)

Patch

Index: include/ansidecl.h

===================================================================
--- include/ansidecl.h	(revision 177557)

+++ include/ansidecl.h	(working copy)

@@ -416,10 +416,12 @@ 

 #define EXPORTED_CONST const
 #endif
 
-/* Be conservative and only use enum bitfields with GCC.

+/* Be conservative and only use enum bitfields with C++ or GCC.

    FIXME: provide a complete autoconf test for buggy enum bitfields.  */
 
-#if (GCC_VERSION > 2000)

+#ifdef __cplusplus

+#define ENUM_BITFIELD(TYPE) enum TYPE

+#elif (GCC_VERSION > 2000)

 #define ENUM_BITFIELD(TYPE) __extension__ enum TYPE
 #else
 #define ENUM_BITFIELD(TYPE) unsigned int
Index: include/obstack.h

===================================================================
--- include/obstack.h	(revision 177557)

+++ include/obstack.h	(working copy)

@@ -532,9 +532,9 @@ 

 # define obstack_free(h,obj)						\
 ( (h)->temp = (char *) (obj) - (char *) (h)->chunk,			\
   (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
-   ? (int) ((h)->next_free = (h)->object_base				\

+   ? ((h)->next_free = (h)->object_base					\

 	    = (h)->temp + (char *) (h)->chunk)				\
-   : (((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0), 0)))

+   : ((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), (char*)0)))

 
 #endif /* not __GNUC__ or not __STDC__ */