eliminate warnings compiling libiberty/fibheap.c
Ben Elliston
bje@au1.ibm.com
Fri Dec 10 04:57:00 GMT 2004
After discussing this code with Kazu, I decided that this could be
refined to minimise the likelihood of a warning being emitted when
compiling libiberty with -pedantic.
Instead, the use of the `unsigned long bitfields' GNU C extension is
now only used when it's really needed: when the sizeof(int) < 4, thus
requiring a wider type in order to get a 31-bit bitfield.
Okay to commit?
[include]
2004-12-10 Ben Elliston <bje@au.ibm.com>
* fibheap.h (struct fibnode): Only use unsigned long bitfields
when __GNUC__ is defined and ints are less than 32-bits wide.
Index: fibheap.h
===================================================================
RCS file: /home/bje/src-cvs/src/include/fibheap.h,v
retrieving revision 1.6
diff -u -p -u -r1.6 fibheap.h
--- fibheap.h 19 Dec 2003 16:50:48 -0000 1.6
+++ fibheap.h 10 Dec 2004 04:55:11 -0000
@@ -59,7 +59,7 @@ typedef struct fibnode
struct fibnode *right;
fibheapkey_t key;
void *data;
-#ifdef __GNUC__
+#if defined (__GNUC__) && SIZEOF_INT < 4
__extension__ unsigned long int degree : 31;
__extension__ unsigned long int mark : 1;
#else
[libiberty]
2004-12-10 Ben Elliston <bje@au.ibm.com>
* configure.ac: Invoke AC_CHECK_SIZEOF for sizeof (int).
* configure: Regenerate.
* config.in: Likewise.
Index: configure.ac
===================================================================
RCS file: /home/bje/src-cvs/src/libiberty/configure.ac,v
retrieving revision 1.7
diff -u -p -u -r1.7 configure.ac
--- configure.ac 2 Sep 2004 07:04:53 -0000 1.7
+++ configure.ac 10 Dec 2004 04:55:47 -0000
@@ -165,6 +165,9 @@ AC_HEADER_TIME
libiberty_AC_DECLARE_ERRNO
+# Determine the size of an int for struct fibnode.
+AC_CHECK_SIZEOF([int])
+
AC_CHECK_TYPE(uintptr_t, unsigned long)
# Look for a 64-bit type.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20041210/d54ab39b/attachment.sig>
More information about the Gcc-patches
mailing list