summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorgeoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4>2000-08-12 22:45:05 +0000
committergeoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4>2000-08-12 22:45:05 +0000
commitb4bb829f793b76c7dbdc7bdb91972964a715c65a (patch)
treefa69ec89bc345170fcb966cb78d9c60d962957d3 /gcc
parent2968054bf6e59f61e39c532c2a54f3037d8b4ff8 (diff)
downloadgcc-b4bb829f793b76c7dbdc7bdb91972964a715c65a.tar.gz
* tree.h (DECL_OFFSET_ALIGN): Make the off_align field of
the tree structure an exponent rather than an explicit alignment so it doesn't overflow. (SET_DECL_OFFSET_ALIGN): New macro. * stor-layout.c (place_union_field): Use SET_DECL_OFFSET_ALIGN rather than DECL_OFFSET_ALIGN. (place_field): Likewise. * expmed.c (store_bit_field): Abort on align==0 to avoid antisocial machine behaviour. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@35659 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog12
-rw-r--r--gcc/expmed.c5
-rw-r--r--gcc/stor-layout.c4
-rw-r--r--gcc/tree.h11
4 files changed, 28 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 402fe228aec..cc284f2e39e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,15 @@
+2000-05-13 Geoffrey Keating <geoffk@cygnus.com>
+
+ * tree.h (DECL_OFFSET_ALIGN): Make the off_align field of
+ the tree structure an exponent rather than an explicit alignment
+ so it doesn't overflow.
+ (SET_DECL_OFFSET_ALIGN): New macro.
+ * stor-layout.c (place_union_field): Use SET_DECL_OFFSET_ALIGN
+ rather than DECL_OFFSET_ALIGN.
+ (place_field): Likewise.
+ * expmed.c (store_bit_field): Abort on align==0 to avoid
+ antisocial machine behaviour.
+
2000-08-12 Richard Henderson <rth@cygnus.com>
* sibcall.c (uses_addressof): Accept both addressof and
diff --git a/gcc/expmed.c b/gcc/expmed.c
index e9210a680a3..606333fdbe3 100644
--- a/gcc/expmed.c
+++ b/gcc/expmed.c
@@ -245,6 +245,11 @@ store_bit_field (str_rtx, bitsize, bitnum, fieldmode, value, align, total_size)
insv_bitsize = GET_MODE_BITSIZE (op_mode);
#endif
+ /* It is wrong to have align==0, since every object is aligned at
+ least at a bit boundary. This usually means a bug elsewhere. */
+ if (align == 0)
+ abort ();
+
/* Discount the part of the structure before the desired byte.
We need to know how many bytes are safe to reference after it. */
if (total_size >= 0)
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index 12162e7f14b..159e2a8551f 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -584,7 +584,7 @@ place_union_field (rli, field)
DECL_FIELD_OFFSET (field) = size_zero_node;
DECL_FIELD_BIT_OFFSET (field) = bitsize_zero_node;
- DECL_OFFSET_ALIGN (field) = BIGGEST_ALIGNMENT;
+ SET_DECL_OFFSET_ALIGN (field, BIGGEST_ALIGNMENT);
desired_align = DECL_ALIGN (field);
@@ -859,7 +859,7 @@ place_field (rli, field)
normalize_rli (rli);
DECL_FIELD_OFFSET (field) = rli->offset;
DECL_FIELD_BIT_OFFSET (field) = rli->bitpos;
- DECL_OFFSET_ALIGN (field) = rli->offset_align;
+ SET_DECL_OFFSET_ALIGN (field, rli->offset_align);
/* If this field ended up more aligned than we thought it would be (we
approximate this by seeing if its position changed), lay out the field
diff --git a/gcc/tree.h b/gcc/tree.h
index 781ef436fc0..e428a8a3864 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -1308,8 +1308,15 @@ struct tree_type
#define DECL_SIZE_UNIT(NODE) (DECL_CHECK (NODE)->decl.size_unit)
/* Holds the alignment required for the datum. */
#define DECL_ALIGN(NODE) (DECL_CHECK (NODE)->decl.u1.a.align)
-/* For FIELD_DECLs, holds the alignment that DECL_FIELD_OFFSET has. */
-#define DECL_OFFSET_ALIGN(NODE) (FIELD_DECL_CHECK (NODE)->decl.u1.a.off_align)
+/* For FIELD_DECLs, off_align holds the number of low-order bits of
+ DECL_FIELD_OFFSET which are known to be always zero.
+ DECL_OFFSET_ALIGN thus returns the alignment that DECL_FIELD_OFFSET
+ has. */
+#define DECL_OFFSET_ALIGN(NODE) \
+ (((unsigned HOST_WIDE_INT)1) << FIELD_DECL_CHECK (NODE)->decl.u1.a.off_align)
+/* Specify that DECL_ALIGN(NODE) is a multiple of X. */
+#define SET_DECL_OFFSET_ALIGN(NODE, X) \
+ (FIELD_DECL_CHECK (NODE)->decl.u1.a.off_align = exact_log2 ((X) & -(X)))
/* 1 if the alignment for this type was requested by "aligned" attribute,
0 if it is the default for this type. */
#define DECL_USER_ALIGN(NODE) (DECL_CHECK (NODE)->decl.user_align)