diff mbox

[Fortran] Create valid temporary variable to avoid assembler errors

Message ID 519CD449.6060305@net-b.de
State New
Headers show

Commit Message

Tobias Burnus May 22, 2013, 2:20 p.m. UTC
With one Fortran file, I get the following assembler errors:

/tmp/cc28epKK.s:2075: Error: junk `@1.2304+16' after expression

That's due to the way a temporary variable is generated. While that 
variable is local to the procedure, the name somehow escapes into the 
assembler file. The dump looks as follows.

   static struct foo DA@0;
   static struct universal DA@1;
   static struct universal DA@2;
...
     class.30._data = &DA@0.foo_parent.universal.counter;

I have now changed the mangling, see attached patch. (The test file uses 
finalization - hence, I do not include it into the patch. I will include 
it in the FINAL patch.)

Build and regtested on x86-64-gnu-linux.
OK for the trunk?

Tobias

Comments

Thomas Koenig May 22, 2013, 7:12 p.m. UTC | #1
Hi Tobias,

>
> I have now changed the mangling, see attached patch. (The test file uses
> finalization - hence, I do not include it into the patch. I will include
> it in the FINAL patch.)
>
> Build and regtested on x86-64-gnu-linux.
> OK for the trunk?

OK (obvious really).

Thanks for the patch!

	Thomas
Steven Bosscher May 22, 2013, 7:14 p.m. UTC | #2
On Wed, May 22, 2013 at 4:20 PM, Tobias Burnus wrote:
> With one Fortran file, I get the following assembler errors:
>
> /tmp/cc28epKK.s:2075: Error: junk `@1.2304+16' after expression
>
> That's due to the way a temporary variable is generated. While that variable
> is local to the procedure, the name somehow escapes into the assembler file.
> The dump looks as follows.
>
>   static struct foo DA@0;
>   static struct universal DA@1;
>   static struct universal DA@2;
> ...
>     class.30._data = &DA@0.foo_parent.universal.counter;
>
> I have now changed the mangling, see attached patch. (The test file uses
> finalization - hence, I do not include it into the patch. I will include it
> in the FINAL patch.)
>
> Build and regtested on x86-64-gnu-linux.
> OK for the trunk?

Hm, DA_F_0 is a valid variable name. So can't your patch cause clashes
with user names?

Ciao!
Steven
diff mbox

Patch

2013-05-22  Tobias Burnus  <burnus@net-b.de>

	* resolve.c (get_temp_from_expr): Fix temp var mangling.

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 6f32df8..5fabc9a 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -9254,7 +9254,7 @@  get_temp_from_expr (gfc_expr *e, gfc_namespace *ns)
   gfc_array_ref *aref;
   gfc_ref *ref;
 
-  sprintf (name, "DA@%d", serial++);
+  sprintf (name, "DA" GFC_PREFIX("%d"), serial++);
   gfc_get_sym_tree (name, ns, &tmp, false);
   gfc_add_type (tmp->n.sym, &e->ts, NULL);