diff mbox

three problems with stor-layout.c.

Message ID 528EC052.7050604@naturalbridge.com
State New
Headers show

Commit Message

Kenneth Zadeck Nov. 22, 2013, 2:24 a.m. UTC
Richi,

Here is the patch.   As you can see, i chose the unsigned option.
It was bootstrapped and tested on x86 with all languages including ada.
Ok to commit?

kenny

2013-11-21  zadeck@naturalbridge.com
     * store-layout.c
     (place-field): Fix hwi test and accessor mismatch.




On 11/21/2013 11:07 AM, Eric Botcazou wrote:
>> I think most of these are because in the past (yes I have fixed that!!)
>> all 'sizetype' constants were sign-extended (and the signedness,
>> that is, TYPE_UNSIGNED (sizetype), was frontend dependend (ugh) and
>> then later true, thus unsigned).
>>
>> So I think all _SIZE stuff should check fits_uhwi_p and be used as
>> uhwi.  But that may have ripple-down effects, so consistently
>> using fits_shwi_p and using as shwi is also fine (it just restricts
>> the maximum values we accept(?)).
> And please make sure to test Ada if you're tweaking this, it's fragile stuff.
>

Comments

Richard Biener Nov. 22, 2013, 8:58 a.m. UTC | #1
On Thu, 21 Nov 2013, Kenneth Zadeck wrote:

> Richi,
> 
> Here is the patch.   As you can see, i chose the unsigned option.
> It was bootstrapped and tested on x86 with all languages including ada.
> Ok to commit?

Ok.

Thanks,
Richard.

> kenny
> 
> 2013-11-21  zadeck@naturalbridge.com
>     * store-layout.c
>     (place-field): Fix hwi test and accessor mismatch.
> 
> 
> 
> 
> On 11/21/2013 11:07 AM, Eric Botcazou wrote:
> > > I think most of these are because in the past (yes I have fixed that!!)
> > > all 'sizetype' constants were sign-extended (and the signedness,
> > > that is, TYPE_UNSIGNED (sizetype), was frontend dependend (ugh) and
> > > then later true, thus unsigned).
> > > 
> > > So I think all _SIZE stuff should check fits_uhwi_p and be used as
> > > uhwi.  But that may have ripple-down effects, so consistently
> > > using fits_shwi_p and using as shwi is also fine (it just restricts
> > > the maximum values we accept(?)).
> > And please make sure to test Ada if you're tweaking this, it's fragile
> > stuff.
> >
diff mbox

Patch

Index: gcc/stor-layout.c
===================================================================
--- gcc/stor-layout.c	(revision 205220)
+++ gcc/stor-layout.c	(working copy)
@@ -1204,7 +1204,7 @@  place_field (record_layout_info rli, tre
       unsigned int type_align = TYPE_ALIGN (type);
       tree dsize = DECL_SIZE (field);
       HOST_WIDE_INT field_size = tree_to_uhwi (dsize);
-      HOST_WIDE_INT offset = tree_to_shwi (rli->offset);
+      HOST_WIDE_INT offset = tree_to_uhwi (rli->offset);
       HOST_WIDE_INT bit_offset = tree_to_shwi (rli->bitpos);
 
 #ifdef ADJUST_FIELD_ALIGN
@@ -1248,7 +1248,7 @@  place_field (record_layout_info rli, tre
       unsigned int type_align = TYPE_ALIGN (type);
       tree dsize = DECL_SIZE (field);
       HOST_WIDE_INT field_size = tree_to_uhwi (dsize);
-      HOST_WIDE_INT offset = tree_to_shwi (rli->offset);
+      HOST_WIDE_INT offset = tree_to_uhwi (rli->offset);
       HOST_WIDE_INT bit_offset = tree_to_shwi (rli->bitpos);
 
 #ifdef ADJUST_FIELD_ALIGN
@@ -1304,7 +1304,7 @@  place_field (record_layout_info rli, tre
 	      && !integer_zerop (DECL_SIZE (field))
 	      && !integer_zerop (DECL_SIZE (rli->prev_field))
 	      && tree_fits_shwi_p (DECL_SIZE (rli->prev_field))
-	      && tree_fits_shwi_p (TYPE_SIZE (type))
+	      && tree_fits_uhwi_p (TYPE_SIZE (type))
 	      && simple_cst_equal (TYPE_SIZE (type), TYPE_SIZE (prev_type)))
 	    {
 	      /* We're in the middle of a run of equal type size fields; make