+2010-04-27 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/18918
+ * resolve.c (resolve_allocate_expr): Allow array coarrays.
+ * trans-types.h (gfc_get_array_type_bounds): Update prototype.
+ * trans-types.c (gfc_get_array_type_bounds,
+ gfc_get_array_descriptor_base): Add corank argument.
+ * trans-array.c (gfc_array_init_size): Handle corank.
+ (gfc_trans_create_temp_array, gfc_array_allocate,
+ gfc_conv_expr_descriptor): Add corank argument to call.
+ * trans-stmt.c (gfc_trans_pointer_assign_need_temp): Ditto.
+
2010-04-24 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/30073
goto failure;
}
- if (codimension)
+ if (codimension && ar->as->rank == 0)
{
- gfc_error ("Sorry, allocatable coarrays are no yet supported coarray "
+ gfc_error ("Sorry, allocatable scalar coarrays are not yet supported "
"at %L", &e->where);
goto failure;
}
/* Initialize the descriptor. */
type =
- gfc_get_array_type_bounds (eltype, info->dimen, loop->from, loop->to, 1,
+ gfc_get_array_type_bounds (eltype, info->dimen, 0, loop->from, loop->to, 1,
GFC_ARRAY_UNKNOWN, true);
desc = gfc_create_var (type, "atmp");
GFC_DECL_PACKED_ARRAY (desc) = 1;
/*GCC ARRAYS*/
static tree
-gfc_array_init_size (tree descriptor, int rank, tree * poffset,
+gfc_array_init_size (tree descriptor, int rank, int corank, tree * poffset,
gfc_expr ** lower, gfc_expr ** upper,
stmtblock_t * pblock)
{
stride = gfc_evaluate_now (stride, pblock);
}
+ for (n = rank; n < rank + corank; n++)
+ {
+ ubound = upper[n];
+
+ /* Set lower bound. */
+ gfc_init_se (&se, NULL);
+ if (lower == NULL || lower[n] == NULL)
+ {
+ gcc_assert (n == rank + corank - 1);
+ se.expr = gfc_index_one_node;
+ }
+ else
+ {
+ if (ubound || n == rank + corank - 1)
+ {
+ gfc_conv_expr_type (&se, lower[n], gfc_array_index_type);
+ gfc_add_block_to_block (pblock, &se.pre);
+ }
+ else
+ {
+ se.expr = gfc_index_one_node;
+ ubound = lower[n];
+ }
+ }
+ gfc_conv_descriptor_lbound_set (pblock, descriptor, gfc_rank_cst[n],
+ se.expr);
+
+ if (n < rank + corank - 1)
+ {
+ gfc_init_se (&se, NULL);
+ gcc_assert (ubound);
+ gfc_conv_expr_type (&se, ubound, gfc_array_index_type);
+ gfc_add_block_to_block (pblock, &se.pre);
+ gfc_conv_descriptor_ubound_set (pblock, descriptor, gfc_rank_cst[n], se.expr);
+ }
+ }
+
/* The stride is the number of elements in the array, so multiply by the
size of an element to get the total size. */
tmp = TYPE_SIZE_UNIT (gfc_get_element_type (type));
gfc_expr **lower;
gfc_expr **upper;
gfc_ref *ref, *prev_ref = NULL;
- bool allocatable_array;
+ bool allocatable_array, coarray;
ref = expr->ref;
if (ref == NULL || ref->type != REF_ARRAY)
return false;
- /* Return if this is a scalar coarray. */
- if (!prev_ref && !expr->symtree->n.sym->attr.dimension)
+ if (!prev_ref)
{
- gcc_assert (expr->symtree->n.sym->attr.codimension);
- return false;
+ allocatable_array = expr->symtree->n.sym->attr.allocatable;
+ coarray = expr->symtree->n.sym->attr.codimension;
}
- else if (prev_ref && !prev_ref->u.c.component->attr.dimension)
+ else
{
- gcc_assert (prev_ref->u.c.component->attr.codimension);
- return false;
+ allocatable_array = prev_ref->u.c.component->attr.allocatable;
+ coarray = prev_ref->u.c.component->attr.codimension;
}
- if (!prev_ref)
- allocatable_array = expr->symtree->n.sym->attr.allocatable;
- else
- allocatable_array = prev_ref->u.c.component->attr.allocatable;
+ /* Return if this is a scalar coarray. */
+ if ((!prev_ref && !expr->symtree->n.sym->attr.dimension)
+ || (prev_ref && !prev_ref->u.c.component->attr.dimension))
+ {
+ gcc_assert (coarray);
+ return false;
+ }
/* Figure out the size of the array. */
switch (ref->u.ar.type)
{
case AR_ELEMENT:
- lower = NULL;
- upper = ref->u.ar.start;
+ if (!coarray)
+ {
+ lower = NULL;
+ upper = ref->u.ar.start;
+ break;
+ }
+ /* Fall through. */
+
+ case AR_SECTION:
+ lower = ref->u.ar.start;
+ upper = ref->u.ar.end;
break;
case AR_FULL:
upper = ref->u.ar.as->upper;
break;
- case AR_SECTION:
- lower = ref->u.ar.start;
- upper = ref->u.ar.end;
- break;
-
default:
gcc_unreachable ();
break;
}
- size = gfc_array_init_size (se->expr, ref->u.ar.as->rank, &offset,
- lower, upper, &se->pre);
+ size = gfc_array_init_size (se->expr, ref->u.ar.as->rank,
+ ref->u.ar.as->corank, &offset, lower, upper,
+ &se->pre);
/* Allocate memory to store the data. */
pointer = gfc_conv_descriptor_data_get (se->expr);
{
/* Otherwise make a new one. */
parmtype = gfc_get_element_type (TREE_TYPE (desc));
- parmtype = gfc_get_array_type_bounds (parmtype, loop.dimen,
+ parmtype = gfc_get_array_type_bounds (parmtype, loop.dimen, 0,
loop.from, loop.to, 0,
GFC_ARRAY_UNKNOWN, false);
parm = gfc_create_var (parmtype, "parm");
/* Make a new descriptor. */
parmtype = gfc_get_element_type (TREE_TYPE (desc));
- parmtype = gfc_get_array_type_bounds (parmtype, loop.dimen,
+ parmtype = gfc_get_array_type_bounds (parmtype, loop.dimen, 0,
loop.from, loop.to, 1,
GFC_ARRAY_UNKNOWN, true);
#include "system.h"
#include "coretypes.h"
#include "tree.h"
-#include "langhooks.h" /* For iso-c-bindings.def. */
+#include "langhooks.h"
+#include "tm.h"
#include "target.h"
#include "ggc.h"
#include "toplev.h"
#include "trans.h"
#include "trans-types.h"
#include "trans-const.h"
+#include "real.h"
#include "flags.h"
-#include "dwarf2out.h" /* For struct array_descr_info. */
+#include "dwarf2out.h"
\f
#if (GFC_MAX_DIMENSIONS < 10)
ppvoid_type_node = build_pointer_type (pvoid_type_node);
pchar_type_node = build_pointer_type (gfc_character1_type_node);
pfunc_type_node
- = build_pointer_type (build_function_type_list (void_type_node, NULL_TREE));
+ = build_pointer_type (build_function_type (void_type_node, NULL_TREE));
gfc_array_index_type = gfc_get_int_type (gfc_index_integer_kind);
/* We cannot use gfc_index_zero_node in definition of gfc_array_range_type,
{
tree fat_type, fieldlist, decl, arraytype;
char name[16 + 2*GFC_RANK_DIGITS + 1 + 1];
- int idx = 2 * (codimen + dimen - 1) + restricted;
+ int idx = 2 * (dimen - 1) + restricted;
gcc_assert (dimen >= 1 && codimen + dimen <= GFC_MAX_DIMENSIONS);
if (gfc_array_descriptor_base[idx])
/* Build the type node. */
fat_type = make_node (RECORD_TYPE);
- sprintf (name, "array_descriptor" GFC_RANK_PRINTF_FORMAT, dimen + codimen);
+ sprintf (name, "array_descriptor" GFC_RANK_PRINTF_FORMAT "_"
+ GFC_RANK_PRINTF_FORMAT, dimen, codimen);
TYPE_NAME (fat_type) = get_identifier (name);
/* Add the data member as the first element of the descriptor. */
type_name = IDENTIFIER_POINTER (tmp);
else
type_name = "unknown";
- sprintf (name, "array" GFC_RANK_PRINTF_FORMAT "_%.*s", dimen + codimen,
+ sprintf (name, "array" GFC_RANK_PRINTF_FORMAT "_"
+ GFC_RANK_PRINTF_FORMAT "_%.*s", dimen, codimen,
GFC_MAX_SYMBOL_LEN, type_name);
TYPE_NAME (fat_type) = get_identifier (name);
restricted);
byref = 0;
}
-
- if (sym->attr.cray_pointee)
- GFC_POINTER_TYPE_P (type) = 1;
}
else
{
{
if (sym->attr.allocatable || sym->attr.pointer)
type = gfc_build_pointer_type (sym, type);
- if (sym->attr.pointer || sym->attr.cray_pointee)
+ if (sym->attr.pointer)
GFC_POINTER_TYPE_P (type) = 1;
}
else
t = void_type_node;
- return build_pointer_type (build_function_type_list (t, NULL_TREE));
+ return build_pointer_type (build_function_type (t, NULL_TREE));
}
+2010-04-27 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/18918
+ * gfortran.dg/coarray_7.f90: Modified and removed obsolete tests.
+ * gfortran.dg/coarray_12.f90: New.
+
2010-04-27 Shujing Zhao <pearly.zhao@oracle.com>
PR c/32207
! { dg-final { scan-tree-dump-times "a.dim.0..lbound = 1;" 1 "original" } }
-! { dg-final { scan-tree-dump-times "a.dim.0..ubound = .*nn;" 1 "original" } }
+! { dg-final { scan-tree-dump-times "a.dim.0..ubound = .* nn;" 1 "original" } }
! { dg-final { scan-tree-dump-times "a.dim.1..lbound = 1;" 1 "original" } }
-! { dg-final { scan-tree-dump-times "a.dim.1..ubound = .*mm;" 1 "original" } }
+! { dg-final { scan-tree-dump-times "a.dim.1..ubound = .* mm;" 1 "original" } }
! { dg-final { scan-tree-dump-times "a.dim.2..lbound = 1;" 1 "original" } }
! { dg-final { scan-tree-dump-times "a.dim.2..ubound" 0 "original" } }
allocate(b(1)) ! { dg-error "Coarray specification" }
allocate(a[3]%a(5)) ! { dg-error "Coindexed allocatable" }
allocate(c[*]) ! { dg-error "Sorry" }
-allocate(b(3)[5:*]) ! { dg-error "Sorry" }
allocate(a%a(5)) ! OK
end subroutine alloc
subroutine allocateTest()
implicit none
- real, allocatable,dimension(:,:), codimension[:,:] :: a,b,c
+ real, allocatable, codimension[:,:] :: a,b,c
integer :: n, q
n = 1
q = 1
- allocate(a(n,n)[q,*]) ! { dg-error "Sorry" }
- allocate(b(n,n)[q,*]) ! { dg-error "Sorry" }
- allocate(c(n,n)[q,*]) ! { dg-error "Sorry" }
+ allocate(a[q,*]) ! { dg-error "Sorry" }
+ allocate(b[q,*]) ! { dg-error "Sorry" }
+ allocate(c[q,*]) ! { dg-error "Sorry" }
end subroutine allocateTest
-subroutine testAlloc3
-implicit none
-integer, allocatable :: a(:,:,:)[:,:]
-integer, allocatable, dimension(:),codimension[:] :: b(:,:,:)[:,:]
-integer, allocatable, dimension(:,:),codimension[:,:,:] :: c
-integer, allocatable, dimension(:,:),codimension[:,:,:] :: d[:,:]
-integer, allocatable, dimension(:,:,:),codimension[:,:,:] :: e(:,:)
-integer, allocatable, dimension(:,:,:),codimension[:,:,:] :: f(:,:)[:,:]
-
-allocate(a(1,2,3)[4,*]) ! { dg-error "Sorry" }
-allocate(b(1,2,3)[4,*]) ! { dg-error "Sorry" }
-allocate(c(1,2)[3,4,*]) ! { dg-error "Sorry" }
-allocate(d(1,2)[3,*]) ! { dg-error "Sorry" }
-allocate(e(1,2)[3,4,*]) ! { dg-error "Sorry" }
-allocate(f(1,2)[3,*]) ! { dg-error "Sorry" }
-end subroutine testAlloc3
-
-
subroutine testAlloc4()
implicit none
type co_double_3