diff mbox

Use "unsigned int" instead of "int" to hold alignment in emit_local function.

Message ID 5570310E.9070201@arm.com
State New
Headers show

Commit Message

Renlin Li June 4, 2015, 11:05 a.m. UTC
Hi all,

This is a simple patch to change the align variable (used in 
emit_local()) from type "int" to type "unsigned int".

It should be defined as "unsigned int" which is the same data type 
returned by symtab_node::get (decl)->definition_alignment ()
For the maximum alignment allowed by GCC(without producing "error: 
requested alignment is too large"), "int" will overflow.

Okay to Commit on the trunk and backport to branch 5.0?

Regards,
Renlin Li

gcc/ChangeLog:

2015-06-04  Renlin Li  <renlin.li@arm.com>

     * varasm.c (emit_local): Use unsigned int for align variable.

Comments

Renlin Li June 16, 2015, 3:05 p.m. UTC | #1
Ping~

Thank you!
Renlin Li

On 04/06/15 12:05, Renlin Li wrote:
> Hi all,
>
> This is a simple patch to change the align variable (used in 
> emit_local()) from type "int" to type "unsigned int".
>
> It should be defined as "unsigned int" which is the same data type 
> returned by symtab_node::get (decl)->definition_alignment ()
> For the maximum alignment allowed by GCC(without producing "error: 
> requested alignment is too large"), "int" will overflow.
>
> Okay to Commit on the trunk and backport to branch 5.0?
>
> Regards,
> Renlin Li
>
> gcc/ChangeLog:
>
> 2015-06-04  Renlin Li  <renlin.li@arm.com>
>
>     * varasm.c (emit_local): Use unsigned int for align variable.
Jeff Law June 24, 2015, 4:38 a.m. UTC | #2
On 06/04/2015 05:05 AM, Renlin Li wrote:
> Hi all,
>
> This is a simple patch to change the align variable (used in
> emit_local()) from type "int" to type "unsigned int".
>
> It should be defined as "unsigned int" which is the same data type
> returned by symtab_node::get (decl)->definition_alignment ()
> For the maximum alignment allowed by GCC(without producing "error:
> requested alignment is too large"), "int" will overflow.
>
> Okay to Commit on the trunk and backport to branch 5.0?
>
> Regards,
> Renlin Li
>
> gcc/ChangeLog:
>
> 2015-06-04  Renlin Li  <renlin.li@arm.com>
>
>      * varasm.c (emit_local): Use unsigned int for align variable.
OK.
jeff
diff mbox

Patch

diff --git a/gcc/varasm.c b/gcc/varasm.c
index 93b9699..8f9b7ec 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -1960,12 +1960,12 @@  emit_local (tree decl ATTRIBUTE_UNUSED,
 	    unsigned HOST_WIDE_INT rounded ATTRIBUTE_UNUSED)
 {
 #if defined ASM_OUTPUT_ALIGNED_DECL_LOCAL
-  int align = symtab_node::get (decl)->definition_alignment ();
+  unsigned int align = symtab_node::get (decl)->definition_alignment ();
   ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file, decl, name,
 				 size, align);
   return true;
 #elif defined ASM_OUTPUT_ALIGNED_LOCAL
-  int align = symtab_node::get (decl)->definition_alignment ();
+  unsigned int align = symtab_node::get (decl)->definition_alignment ();
   ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size, align);
   return true;
 #else