aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-common.c
diff options
context:
space:
mode:
authorFeng Wang <fengwang@nudt.edu.cn>2005-03-15 02:52:38 +0000
committerFeng Wang <fengwang@gcc.gnu.org>2005-03-15 02:52:38 +0000
commitce2df7c64ae0185dab22bb38628acf8ae48551b7 (patch)
tree9d626c10efe2ea1ff72bf8bd94fa123c776b3dad /gcc/fortran/trans-common.c
parent08091139067ee2565a3ad248bd0113e521a425ee (diff)
downloadgcc-ce2df7c64ae0185dab22bb38628acf8ae48551b7.zip
gcc-ce2df7c64ae0185dab22bb38628acf8ae48551b7.tar.gz
gcc-ce2df7c64ae0185dab22bb38628acf8ae48551b7.tar.bz2
re PR fortran/18827 (ICE on assign to common variable)
fortran/ 2005-03-15 Feng Wang <fengwang@nudt.edu.cn> PR fortran/18827 * io.c (resolve_tag): Add checking on assigned label. (match_dt_format): Does not set symbol assign attribute. * match.c (gfc_match_goto):Does not set symbol assign attribute. * resolve.c (resolve_code): Add checking on assigned label. * trans-common.c (build_field): Deals with common variable assigned a label. * trans-stmt.c (gfc_conv_label_variable): New function. (gfc_trans_label_assign): Use it. (gfc_trans_goto): Ditto. * trans-io.c (set_string): Ditto. * trans.h (gfc_conv_label_variable): Add prototype. testsuite/ 2005-03-15 Feng Wang <fengwang@nudt.edu.cn> PR fortran/18827 * gfortran.dg/assign_2.f90: New test. * gfortran.dg/assign_3.f90: New test. * gfortran.dg/assign.f90: New test. From-SVN: r96467
Diffstat (limited to 'gcc/fortran/trans-common.c')
-rw-r--r--gcc/fortran/trans-common.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/gcc/fortran/trans-common.c b/gcc/fortran/trans-common.c
index c62d68d..c8db6e7 100644
--- a/gcc/fortran/trans-common.c
+++ b/gcc/fortran/trans-common.c
@@ -242,6 +242,27 @@ build_field (segment_info *h, tree union_type, record_layout_info rli)
size_binop (PLUS_EXPR,
DECL_FIELD_OFFSET (field),
DECL_SIZE_UNIT (field)));
+ /* If this field is assigned to a label, we create another two variables.
+ One will hold the address of taget label or format label. The other will
+ hold the length of format label string. */
+ if (h->sym->attr.assign)
+ {
+ tree len;
+ tree addr;
+
+ gfc_allocate_lang_decl (field);
+ GFC_DECL_ASSIGN (field) = 1;
+ len = gfc_create_var_np (gfc_charlen_type_node,h->sym->name);
+ addr = gfc_create_var_np (pvoid_type_node, h->sym->name);
+ TREE_STATIC (len) = 1;
+ TREE_STATIC (addr) = 1;
+ DECL_INITIAL (len) = build_int_cst (NULL_TREE, -2);
+ gfc_set_decl_location (len, &h->sym->declared_at);
+ gfc_set_decl_location (addr, &h->sym->declared_at);
+ GFC_DECL_STRING_LEN (field) = pushdecl_top_level (len);
+ GFC_DECL_ASSIGN_ADDR (field) = pushdecl_top_level (addr);
+ }
+
h->field = field;
}
@@ -434,7 +455,7 @@ create_common (gfc_common_head *com, segment_info * head)
for (s = head; s; s = next_s)
{
s->sym->backend_decl = build3 (COMPONENT_REF, TREE_TYPE (s->field),
- decl, s->field, NULL_TREE);
+ decl, s->field, NULL_TREE);
next_s = s->next;
gfc_free (s);