Patchwork [2/6,AArch64-4.7] Fix warning - aarch64_add_constant mixed code and declarations.

login
register
mail settings
Submitter James Greenhalgh
Date Feb. 1, 2013, 5:42 p.m.
Message ID <1359740555-10179-3-git-send-email-james.greenhalgh@arm.com>
Download mbox | patch
Permalink /patch/217546/
State New
Headers show

Comments

James Greenhalgh - Feb. 1, 2013, 5:42 p.m.
Hi,

In config/aarch64/aarch64.c::aarch64_add_constant `shift' was
declared after we started writing code. C90 doesn't like this,
so split the declaration and the assignment.

This fixes the warning:

config/aarch64/aarch64.c: In function ‘aarch64_add_constant’:
config/aarch64/aarch64.c:2249:4: warning: ISO C90 forbids mixed declarations and code [-pedantic]

Regression tested on aarch64-none-elf with no regressions.

OK for aarch64-4.7-branch?

Thanks,
James

---
gcc/

2013-02-01  James Greenhalgh  <james.greenhalgh@arm.com>

	* config/aarch64/aarch64.c
  	(aarch64_add_constant): Move declaration of 'shift' above code.
Richard Earnshaw - Feb. 2, 2013, 2:24 p.m.
On 01/02/13 17:42, James Greenhalgh wrote:
>
> Hi,
>
> In config/aarch64/aarch64.c::aarch64_add_constant `shift' was
> declared after we started writing code. C90 doesn't like this,
> so split the declaration and the assignment.
>
> This fixes the warning:
>
> config/aarch64/aarch64.c: In function ‘aarch64_add_constant’:
> config/aarch64/aarch64.c:2249:4: warning: ISO C90 forbids mixed declarations and code [-pedantic]
>
> Regression tested on aarch64-none-elf with no regressions.
>
> OK for aarch64-4.7-branch?
>
> Thanks,
> James
>
> ---
> gcc/
>
> 2013-02-01  James Greenhalgh  <james.greenhalgh@arm.com>
>
> 	* config/aarch64/aarch64.c
>    	(aarch64_add_constant): Move declaration of 'shift' above code.
>
>
> 0002-AArch64-4.7-Fix-warning-aarch64_add_constant-mixed-c.patch
>
>
> diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
> index 59124eb..62d0a12 100644
> --- a/gcc/config/aarch64/aarch64.c
> +++ b/gcc/config/aarch64/aarch64.c
> @@ -2307,8 +2307,9 @@ aarch64_add_constant (int regnum, int scratchreg, HOST_WIDE_INT delta)
>       {
>         if (mdelta >= 4096)
>   	{
> +	  rtx shift;
>   	  emit_insn (gen_rtx_SET (Pmode, scratch_rtx, GEN_INT (mdelta / 4096)));

Blank line between declarations and code.

OK with that change.

R.

Patch

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 59124eb..62d0a12 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -2307,8 +2307,9 @@  aarch64_add_constant (int regnum, int scratchreg, HOST_WIDE_INT delta)
     {
       if (mdelta >= 4096)
 	{
+	  rtx shift;
 	  emit_insn (gen_rtx_SET (Pmode, scratch_rtx, GEN_INT (mdelta / 4096)));
-	  rtx shift = gen_rtx_ASHIFT (Pmode, scratch_rtx, GEN_INT (12));
+	  shift = gen_rtx_ASHIFT (Pmode, scratch_rtx, GEN_INT (12));
 	  if (delta < 0)
 	    emit_insn (gen_rtx_SET (Pmode, this_rtx,
 				    gen_rtx_MINUS (Pmode, this_rtx, shift)));