This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [gfortran] ICE with common blocks
- From: canqun at nudt dot edu dot cn
- To: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Date: Wed, 26 Nov 2003 20:10:57 +0800 (HKT)
- Subject: Re: [gfortran] ICE with common blocks
- Reply-to: canqun at nudt dot edu dot cn
Paul Brook <paul@nowt.org>:
> Patch below fixes an ICE when using COMMON blocks in
modules. We were trying
>
> to explicity create a variable from the symbol for
the common block iteslf.
>
> Tested on i686-linux
> Applied to tree-ssa branch.
>
> Paul
I supplied another patch to generate backend
declarations for COMMON variables and EQUIVALENCE
objects defind in MODULE. But part of the testcase I
attached still can not be passed. It seems there is
much work to do.
Canqun Yang.
Below is the ChangeLog entry.
2003-11-26 Canqun Yang <canqun@nudt.edu.cn>
* trans-decl.c (gfc_get_symbol_decl):
Register the backend_decl for
COMMON variable or EQUIVALENCE object.
(gfc_create_module_variable): Skip COMMON
variables and EQUIVALENCE
objects.
(gfc_generate_module_vars): Translate
EQUIVALENCE lists and COMMON
blocks.
*** t.c 2003-11-26 11:54:26.000000000 +0800
--- trans-decl.c 2003-11-26 11:51:21.000000000 +0800
*************** gfc_get_symbol_decl (gfc_symbol * sym)
*** 728,733 ****
--- 728,734 ----
are part of a common block. */
gfc_todo_error ("CHARACTER inside COMMON or EQUIVALENCE");
}
+ sym->backend_decl = decl;
return decl;
}
*************** gfc_create_module_variable (gfc_symbol *
*** 1679,1684 ****
--- 1680,1689 ----
/* Create the decl. */
decl = gfc_get_symbol_decl (sym);
+ /* Skip COMMON variables and EQUIVALENCE objects. */
+ if (sym->addr_base)
+ return;
+
/* We want to allocate storage for this variable. */
TREE_STATIC (decl) = 1;
*************** gfc_generate_module_vars (gfc_namespace
*** 1735,1740 ****
--- 1740,1751 ----
/* Check the frontend left the namespace in a reasonable state. */
assert (ns->proc_name && !ns->proc_name->tlink);
+ /* Translate EQUIVALENCE lists. */
+ gfc_trans_equivalence (ns);
+
+ /* Translate COMMON blocks. */
+ gfc_trans_common (ns);
+
/* Create decls for all the module varuiables. */
gfc_traverse_ns (ns, gfc_create_module_variable);
}
! Generate proper backend declarations for COMMON variables and EQUIVALENCE
! objects defined in a MODULE.
module m
real (kind=8) a(8)
real (kind=8) b(5), c(5)
common /com1/b,c
equivalence (a(1), b(2))
contains
subroutine suba
b = 100
c = 200
end subroutine
end module m
program module_common
use m
call suba ()
if (any (b .ne. 100) .or. any (c .ne. 200)) call abort
! Can not pass. The address of a(4) should be com1_ + 32
! if ((a(4) .ne. 100) .or. (a(5) .ne. 200)) call abort
call subb ()
call subc ()
contains
subroutine subb
! Can not pass. The reference of a, b, c should be com1_ + offset
! if (any (b .ne. 100) .or. any (c .ne. 200)) call abort
! if ((a (4) .ne. 100) .or. (a(5) .ne. 200)) call abort
end subroutine
end
subroutine subc
real (kind=8) a(8)
real (kind=8) b(5), c(5)
common /com1/b,c
equivalence (a(1), b(2))
if ((a (4) .ne. 100) .or. (a(5) .ne. 200)) call abort
end subroutine