This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[libiberty] trivial C++ fixes for libiberty
- From: Bernardo Innocenti <bernie at develer dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>, gdb-patches at sources dot redhat dot com, binutils at sources dot redhat dot com, Ian Lance Taylor <ian at wasabisystems dot com>,DJ Delorie <dj at redhat dot com>
- Date: Mon, 12 Jul 2004 01:49:42 +0200
- Subject: [libiberty] trivial C++ fixes for libiberty
- Organization: Develer S.r.l.
Hello,
this patch adds a few missing casts that C++ complains about.
PING: the XNEW/XDELETE patch is still pending as the
discussion halted before reaching consensus:
http://gcc.gnu.org/ml/gcc-patches/2004-07/msg00039.html
This version addresses most (not all) of the issues raised
along the thread. I already had an earlier version approved,
but I'd prefer to get it explicitly approved again with the
discussed changes.
include/
2004-07-11 Bernardo Innocenti <bernie@develer.com>
* libiberty.h (ASTRDUP, obstack_free): Add casts required for stricter
type conversion rules of C++.
diff -u -p -r1.35 libiberty.h
--- libiberty.h 15 May 2003 19:02:12 -0000 1.35
+++ libiberty.h 11 Jul 2004 23:13:02 -0000
@@ -309,7 +340,7 @@ extern PTR C_alloca PARAMS ((size_t)) AT
# define ASTRDUP(X) \
(__extension__ ({ const char *const libiberty_optr = (X); \
const unsigned long libiberty_len = strlen (libiberty_optr) + 1; \
- char *const libiberty_nptr = alloca (libiberty_len); \
+ char *const libiberty_nptr = (char *const) alloca (libiberty_len); \
(char *) memcpy (libiberty_nptr, libiberty_optr, libiberty_len); }))
#else
# define alloca(x) C_alloca(x)
@@ -323,7 +354,7 @@ extern unsigned long libiberty_len;
# define ASTRDUP(X) \
(libiberty_optr = (X), \
libiberty_len = strlen (libiberty_optr) + 1, \
- libiberty_nptr = alloca (libiberty_len), \
+ libiberty_nptr = (char *) alloca (libiberty_len), \
(char *) memcpy (libiberty_nptr, libiberty_optr, libiberty_len))
#endif
diff -u -p -r1.6 obstack.h
--- obstack.h 22 Oct 2003 22:28:20 -0000 1.6
+++ obstack.h 11 Jul 2004 23:13:03 -0000
@@ -494,9 +494,9 @@ __extension__ \
# define obstack_free(OBSTACK, OBJ) \
__extension__ \
({ struct obstack *__o = (OBSTACK); \
- void *__obj = (OBJ); \
+ void *__obj = (void *) (OBJ); \
if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \
- __o->next_free = __o->object_base = __obj; \
+ __o->next_free = __o->object_base = (char *) __obj; \
else (obstack_free) (__o, __obj); })
#else /* not __GNUC__ or not __STDC__ */
--
// Bernardo Innocenti - Develer S.r.l., R&D dept.
\X/ http://www.develer.com/