aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2009-03-31 20:05:44 +0000
committerPaul Thomas <pault@gcc.gnu.org>2009-03-31 20:05:44 +0000
commite49be8f7c371881733a0f9b0c7ecccef5232f10e (patch)
tree821da1a5b2c279999ca9eb0b101be73abc85c3ff /gcc/fortran
parentbf0d171aead0443d546cf48d714ea84ecbb6ab91 (diff)
downloadgcc-e49be8f7c371881733a0f9b0c7ecccef5232f10e.zip
gcc-e49be8f7c371881733a0f9b0c7ecccef5232f10e.tar.gz
gcc-e49be8f7c371881733a0f9b0c7ecccef5232f10e.tar.bz2
re PR fortran/38917 (Can't use DATA to initialize pointer to array to NULL())
2009-03-31 Paul Thomas <pault@gcc.gnu.org> PR fortran/38917 * expr.c (gfc_check_assign): Allow pointer components when checking for NULL. PR fortran/38918 * resolve.c (check_data_variable): Treat pointer arrays with scalars. 2009-03-31 Paul Thomas <pault@gcc.gnu.org> PR fortran/38917 PR fortran/38918 * gfortran.dg/data_pointer_1.f90: New test. From-SVN: r145371
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog10
-rw-r--r--gcc/fortran/expr.c2
-rw-r--r--gcc/fortran/resolve.c32
3 files changed, 37 insertions, 7 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index ef6d2b5..0b9bc88 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -139,6 +139,16 @@
2009-03-31 Paul Thomas <pault@gcc.gnu.org>
+ PR fortran/38917
+ * expr.c (gfc_check_assign): Allow pointer components when
+ checking for NULL.
+
+ PR fortran/38918
+ * resolve.c (check_data_variable): Treat pointer arrays with
+ scalars.
+
+2009-03-31 Paul Thomas <pault@gcc.gnu.org>
+
PR fortran/38915
* trans-expr.c (gfc_trans_assignment_1): Ensure temporaries
have a string_length.
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 8dec53f..233516e 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -2913,7 +2913,7 @@ gfc_check_assign (gfc_expr *lvalue, gfc_expr *rvalue, int conform)
if (rvalue->expr_type == EXPR_NULL)
{
- if (lvalue->symtree->n.sym->attr.pointer
+ if (has_pointer && (ref == NULL || ref->next == NULL)
&& lvalue->symtree->n.sym->attr.data)
return SUCCESS;
else
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 4ab9df6..1fa1a79 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -9647,6 +9647,8 @@ check_data_variable (gfc_data_variable *var, locus *where)
mpz_t section_index[GFC_MAX_DIMENSIONS];
gfc_ref *ref;
gfc_array_ref *ar;
+ gfc_symbol *sym;
+ int has_pointer;
if (gfc_resolve_expr (var->expr) == FAILURE)
return FAILURE;
@@ -9658,21 +9660,39 @@ check_data_variable (gfc_data_variable *var, locus *where)
if (e->expr_type != EXPR_VARIABLE)
gfc_internal_error ("check_data_variable(): Bad expression");
- if (e->symtree->n.sym->ns->is_block_data
- && !e->symtree->n.sym->attr.in_common)
+ sym = e->symtree->n.sym;
+
+ if (sym->ns->is_block_data && !sym->attr.in_common)
{
gfc_error ("BLOCK DATA element '%s' at %L must be in COMMON",
- e->symtree->n.sym->name, &e->symtree->n.sym->declared_at);
+ sym->name, &sym->declared_at);
}
- if (e->ref == NULL && e->symtree->n.sym->as)
+ if (e->ref == NULL && sym->as)
{
gfc_error ("DATA array '%s' at %L must be specified in a previous"
- " declaration", e->symtree->n.sym->name, where);
+ " declaration", sym->name, where);
return FAILURE;
}
- if (e->rank == 0)
+ has_pointer = sym->attr.pointer;
+
+ for (ref = e->ref; ref; ref = ref->next)
+ {
+ if (ref->type == REF_COMPONENT && ref->u.c.component->attr.pointer)
+ has_pointer = 1;
+
+ if (has_pointer
+ && ref->type == REF_ARRAY
+ && ref->u.ar.type != AR_FULL)
+ {
+ gfc_error ("DATA element '%s' at %L is a pointer and so must "
+ "be a full array", sym->name, where);
+ return FAILURE;
+ }
+ }
+
+ if (e->rank == 0 || has_pointer)
{
mpz_init_set_ui (size, 1);
ref = NULL;