* [Patch, Fortran] PRs 61881/61888 - Fix issues with SIZEOF, CLASS(*) and assumed-rank
@ 2014-07-26 1:33 Tobias Burnus
2014-07-26 9:38 ` Paul Richard Thomas
2014-09-02 17:03 ` Thomas Schwinge
0 siblings, 2 replies; 6+ messages in thread
From: Tobias Burnus @ 2014-07-26 1:33 UTC (permalink / raw)
To: gcc-patches, gfortran
[-- Attachment #1: Type: text/plain, Size: 551 bytes --]
The patch has been motivated by the needs for implementing the openacc
module. In particular, it does:
- Fix passing intrinsic types to CLASS(*) [F2003]
- Fix STORAGE_SIZE for polymorphic arrays [F2003]
- Permit the vendor intrinsic SIZEOF also for TYPE(*) if and only if an
array descriptor has been used [extend GNU extension]
- Fix SIZEOF with assumed-rank [fix GNU extension]
- Document that SIZEOF's result are not well defined for noncontiguous
arrays. [fix GNU extension]
Build and regtested on x86-64-gnu-linux.
OK for the trunk?
Tobias
[-- Attachment #2: sizeof.diff --]
[-- Type: text/x-patch, Size: 16261 bytes --]
2014-07-26 Tobias Burnus <burnus@net-b.de>
* check.c (gfc_check_sizeof): Permit for assumed type if and
only if it has an array descriptor.
* intrinsic.c (do_ts29113_check): Permit SIZEOF.
(add_functions): SIZEOF is an Inquiry function.
* intrinsic.texi (SIZEOF): Add note that only contiguous
arrays are permitted.
* trans-expr.c (gfc_conv_intrinsic_to_class): Handle assumed
rank.
* trans-intrinsic.c (gfc_conv_intrinsic_sizeof): Handle
assumed type + array descriptor, CLASS and assumed rank.
(gfc_conv_intrinsic_storage_size): Handle class arrays.
2014-07-26 Tobias Burnus <burnus@net-b.de>
* gfortran.dg/sizeof_2.f90: Change dg-error.
* gfortran.dg/sizeof_4.f90: New.
* gfortran.dg/storage_size_1.f08: Correct expected
value.
diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index eff2c4c..ff7e53d 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -3902,7 +3902,12 @@ gfc_check_sizeof (gfc_expr *arg)
return false;
}
- if (arg->ts.type == BT_ASSUMED)
+ // TYPE(*) is acceptable if and only if it uses an array descriptor.
+ if (arg->ts.type == BT_ASSUMED
+ && (arg->symtree->n.sym->as == NULL
+ || (arg->symtree->n.sym->as->type != AS_ASSUMED_SHAPE
+ && arg->symtree->n.sym->as->type != AS_DEFERRED
+ && arg->symtree->n.sym->as->type != AS_ASSUMED_RANK)))
{
gfc_error ("'%s' argument of '%s' intrinsic at %L shall not be TYPE(*)",
gfc_current_intrinsic_arg[0]->name, gfc_current_intrinsic,
diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c
index d681d70..1ad1e69 100644
--- a/gcc/fortran/intrinsic.c
+++ b/gcc/fortran/intrinsic.c
@@ -204,6 +204,7 @@ do_ts29113_check (gfc_intrinsic_sym *specific, gfc_actual_arglist *arg)
&& specific->id != GFC_ISYM_RANK
&& specific->id != GFC_ISYM_SHAPE
&& specific->id != GFC_ISYM_SIZE
+ && specific->id != GFC_ISYM_SIZEOF
&& specific->id != GFC_ISYM_UBOUND
&& specific->id != GFC_ISYM_C_LOC)
{
@@ -2765,8 +2766,9 @@ add_functions (void)
ar, BT_REAL, dr, REQUIRED, dm, BT_INTEGER, ii, OPTIONAL);
make_from_module();
- add_sym_1 ("sizeof", GFC_ISYM_SIZEOF, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER, ii,
- GFC_STD_GNU, gfc_check_sizeof, gfc_simplify_sizeof, NULL,
+ add_sym_1 ("sizeof", GFC_ISYM_SIZEOF, CLASS_INQUIRY, ACTUAL_NO,
+ BT_INTEGER, ii, GFC_STD_GNU,
+ gfc_check_sizeof, gfc_simplify_sizeof, NULL,
x, BT_UNKNOWN, 0, REQUIRED);
make_generic ("sizeof", GFC_ISYM_SIZEOF, GFC_STD_GNU);
diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi
index 152b46c..6c4cb09 100644
--- a/gcc/fortran/intrinsic.texi
+++ b/gcc/fortran/intrinsic.texi
@@ -12205,7 +12205,9 @@ to is returned. If the argument is of a derived type with @code{POINTER}
or @code{ALLOCATABLE} components, the return value does not account for
the sizes of the data pointed to by these components. If the argument is
polymorphic, the size according to the declared type is returned. The argument
-may not be a procedure or procedure pointer.
+may not be a procedure or procedure pointer. Note that the code assumes for
+arrays that those are contiguous; for contiguous arrays, it returns the
+storage or an array element multiplicated by the size of the array.
@item @emph{Example}:
@smallexample
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 81f2137..02cec97 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -564,7 +564,7 @@ gfc_conv_intrinsic_to_class (gfc_se *parmse, gfc_expr *e,
var = gfc_create_var (tmp, "class");
/* Set the vptr. */
- ctree = gfc_class_vptr_get (var);
+ ctree = gfc_class_vptr_get (var);
vtab = gfc_find_vtab (&e->ts);
gcc_assert (vtab);
@@ -573,7 +573,7 @@ gfc_conv_intrinsic_to_class (gfc_se *parmse, gfc_expr *e,
fold_convert (TREE_TYPE (ctree), tmp));
/* Now set the data field. */
- ctree = gfc_class_data_get (var);
+ ctree = gfc_class_data_get (var);
if (parmse->ss && parmse->ss->info->useflags)
{
/* For an array reference in an elemental procedure call we need
@@ -589,7 +589,16 @@ gfc_conv_intrinsic_to_class (gfc_se *parmse, gfc_expr *e,
{
parmse->ss = NULL;
gfc_conv_expr_reference (parmse, e);
- tmp = fold_convert (TREE_TYPE (ctree), parmse->expr);
+ if (class_ts.u.derived->components->as
+ && class_ts.u.derived->components->as->type == AS_ASSUMED_RANK)
+ {
+ tmp = gfc_conv_scalar_to_descriptor (parmse, parmse->expr,
+ gfc_expr_attr (e));
+ tmp = fold_build1_loc (input_location, VIEW_CONVERT_EXPR,
+ TREE_TYPE (ctree), tmp);
+ }
+ else
+ tmp = fold_convert (TREE_TYPE (ctree), parmse->expr);
gfc_add_modify (&parmse->pre, ctree, tmp);
}
else
@@ -597,7 +606,14 @@ gfc_conv_intrinsic_to_class (gfc_se *parmse, gfc_expr *e,
parmse->ss = ss;
parmse->use_offset = 1;
gfc_conv_expr_descriptor (parmse, e);
- gfc_add_modify (&parmse->pre, ctree, parmse->expr);
+ if (class_ts.u.derived->components->as->rank != e->rank)
+ {
+ tmp = fold_build1_loc (input_location, VIEW_CONVERT_EXPR,
+ TREE_TYPE (ctree), parmse->expr);
+ gfc_add_modify (&parmse->pre, ctree, tmp);
+ }
+ else
+ gfc_add_modify (&parmse->pre, ctree, parmse->expr);
}
}
diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
index 3de0b09..31c9207 100644
--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -5891,62 +5891,131 @@ gfc_conv_intrinsic_sizeof (gfc_se *se, gfc_expr *expr)
gfc_expr *arg;
gfc_se argse;
tree source_bytes;
- tree type;
tree tmp;
tree lower;
tree upper;
+ tree byte_size;
int n;
- arg = expr->value.function.actual->expr;
-
gfc_init_se (&argse, NULL);
+ arg = expr->value.function.actual->expr;
- if (arg->rank == 0)
+ if (arg->rank || arg->ts.type == BT_ASSUMED)
+ gfc_conv_expr_descriptor (&argse, arg);
+ else
+ gfc_conv_expr_reference (&argse, arg);
+
+ if (arg->ts.type == BT_ASSUMED)
+ {
+ // This only works if an array descriptor has been passed; thus, extract
+ // the size from the descriptor.
+ gcc_assert (TYPE_PRECISION (gfc_array_index_type)
+ == TYPE_PRECISION (size_type_node));
+ tmp = arg->symtree->n.sym->backend_decl;
+ tmp = DECL_LANG_SPECIFIC (tmp)
+ && GFC_DECL_SAVED_DESCRIPTOR (tmp) != NULL_TREE
+ ? GFC_DECL_SAVED_DESCRIPTOR (tmp) : tmp;
+ if (POINTER_TYPE_P (TREE_TYPE (tmp)))
+ tmp = build_fold_indirect_ref_loc (input_location, tmp);
+ tmp = fold_convert (size_type_node, gfc_conv_descriptor_dtype (tmp));
+ tmp = fold_build2_loc (input_location, RSHIFT_EXPR, TREE_TYPE (tmp), tmp,
+ build_int_cst (TREE_TYPE (tmp),
+ GFC_DTYPE_SIZE_SHIFT));
+ byte_size = fold_convert (gfc_array_index_type, tmp);
+ }
+ else if (arg->ts.type == BT_CLASS)
+ {
+ if (arg->rank)
+ byte_size = gfc_vtable_size_get (TREE_OPERAND (argse.expr, 0));
+ else
+ byte_size = gfc_vtable_size_get (argse.expr);
+ }
+ else
{
- if (arg->ts.type == BT_CLASS)
- gfc_add_data_component (arg);
-
- gfc_conv_expr_reference (&argse, arg);
-
- type = TREE_TYPE (build_fold_indirect_ref_loc (input_location,
- argse.expr));
-
- /* Obtain the source word length. */
if (arg->ts.type == BT_CHARACTER)
- se->expr = size_of_string_in_bytes (arg->ts.kind,
- argse.string_length);
+ byte_size = size_of_string_in_bytes (arg->ts.kind, argse.string_length);
else
- se->expr = fold_convert (gfc_array_index_type, size_in_bytes (type));
+ {
+ if (arg->rank == 0)
+ byte_size = TREE_TYPE (build_fold_indirect_ref_loc (input_location,
+ argse.expr));
+ else
+ byte_size = gfc_get_element_type (TREE_TYPE (argse.expr));
+ byte_size = fold_convert (gfc_array_index_type,
+ size_in_bytes (byte_size));
+ }
}
+
+ if (arg->rank == 0)
+ se->expr = byte_size;
else
{
source_bytes = gfc_create_var (gfc_array_index_type, "bytes");
- argse.want_pointer = 0;
- gfc_conv_expr_descriptor (&argse, arg);
- type = gfc_get_element_type (TREE_TYPE (argse.expr));
+ gfc_add_modify (&argse.pre, source_bytes, byte_size);
- /* Obtain the argument's word length. */
- if (arg->ts.type == BT_CHARACTER)
- tmp = size_of_string_in_bytes (arg->ts.kind, argse.string_length);
- else
- tmp = fold_convert (gfc_array_index_type,
- size_in_bytes (type));
- gfc_add_modify (&argse.pre, source_bytes, tmp);
-
- /* Obtain the size of the array in bytes. */
- for (n = 0; n < arg->rank; n++)
+ if (arg->rank == -1)
{
- tree idx;
- idx = gfc_rank_cst[n];
- lower = gfc_conv_descriptor_lbound_get (argse.expr, idx);
- upper = gfc_conv_descriptor_ubound_get (argse.expr, idx);
- tmp = fold_build2_loc (input_location, MINUS_EXPR,
- gfc_array_index_type, upper, lower);
- tmp = fold_build2_loc (input_location, PLUS_EXPR,
- gfc_array_index_type, tmp, gfc_index_one_node);
+ tree cond, loop_var, exit_label;
+ stmtblock_t body;
+
+ tmp = fold_convert (gfc_array_index_type,
+ gfc_conv_descriptor_rank (argse.expr));
+ loop_var = gfc_create_var (gfc_array_index_type, "i");
+ gfc_add_modify (&argse.pre, loop_var, gfc_index_zero_node);
+ exit_label = gfc_build_label_decl (NULL_TREE);
+
+ /* Create loop:
+ for (;;)
+ {
+ if (i >= rank)
+ goto exit;
+ source_bytes = source_bytes * array.dim[i].extent;
+ i = i + 1;
+ }
+ exit: */
+ gfc_start_block (&body);
+ cond = fold_build2_loc (input_location, GE_EXPR, boolean_type_node,
+ loop_var, tmp);
+ tmp = build1_v (GOTO_EXPR, exit_label);
+ tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
+ cond, tmp, build_empty_stmt (input_location));
+ gfc_add_expr_to_block (&body, tmp);
+
+ lower = gfc_conv_descriptor_lbound_get (argse.expr, loop_var);
+ upper = gfc_conv_descriptor_ubound_get (argse.expr, loop_var);
+ tmp = gfc_conv_array_extent_dim (lower, upper, NULL);
tmp = fold_build2_loc (input_location, MULT_EXPR,
gfc_array_index_type, tmp, source_bytes);
- gfc_add_modify (&argse.pre, source_bytes, tmp);
+ gfc_add_modify (&body, source_bytes, tmp);
+
+ tmp = fold_build2_loc (input_location, PLUS_EXPR,
+ gfc_array_index_type, loop_var,
+ gfc_index_one_node);
+ gfc_add_modify_loc (input_location, &body, loop_var, tmp);
+
+ tmp = gfc_finish_block (&body);
+
+ tmp = fold_build1_loc (input_location, LOOP_EXPR, void_type_node,
+ tmp);
+ gfc_add_expr_to_block (&argse.pre, tmp);
+
+ tmp = build1_v (LABEL_EXPR, exit_label);
+ gfc_add_expr_to_block (&argse.pre, tmp);
+ }
+ else
+ {
+ /* Obtain the size of the array in bytes. */
+ for (n = 0; n < arg->rank; n++)
+ {
+ tree idx;
+ idx = gfc_rank_cst[n];
+ lower = gfc_conv_descriptor_lbound_get (argse.expr, idx);
+ upper = gfc_conv_descriptor_ubound_get (argse.expr, idx);
+ tmp = gfc_conv_array_extent_dim (lower, upper, NULL);
+ tmp = fold_build2_loc (input_location, MULT_EXPR,
+ gfc_array_index_type, tmp, source_bytes);
+ gfc_add_modify (&argse.pre, source_bytes, tmp);
+ }
}
se->expr = source_bytes;
}
@@ -5970,13 +6039,13 @@ gfc_conv_intrinsic_storage_size (gfc_se *se, gfc_expr *expr)
if (arg->rank == 0)
{
if (arg->ts.type == BT_CLASS)
- {
- gfc_add_vptr_component (arg);
- gfc_add_size_component (arg);
- gfc_conv_expr (&argse, arg);
- tmp = fold_convert (result_type, argse.expr);
- goto done;
- }
+ {
+ gfc_add_vptr_component (arg);
+ gfc_add_size_component (arg);
+ gfc_conv_expr (&argse, arg);
+ tmp = fold_convert (result_type, argse.expr);
+ goto done;
+ }
gfc_conv_expr_reference (&argse, arg);
type = TREE_TYPE (build_fold_indirect_ref_loc (input_location,
@@ -5986,6 +6055,12 @@ gfc_conv_intrinsic_storage_size (gfc_se *se, gfc_expr *expr)
{
argse.want_pointer = 0;
gfc_conv_expr_descriptor (&argse, arg);
+ if (arg->ts.type == BT_CLASS)
+ {
+ tmp = gfc_vtable_size_get (TREE_OPERAND (argse.expr, 0));
+ tmp = fold_convert (result_type, tmp);
+ goto done;
+ }
type = gfc_get_element_type (TREE_TYPE (argse.expr));
}
diff --git a/gcc/testsuite/gfortran.dg/sizeof_2.f90 b/gcc/testsuite/gfortran.dg/sizeof_2.f90
index 5f19288..e6661a5 100644
--- a/gcc/testsuite/gfortran.dg/sizeof_2.f90
+++ b/gcc/testsuite/gfortran.dg/sizeof_2.f90
@@ -10,7 +10,7 @@ subroutine foo(x, y)
integer(8) :: ii
procedure() :: proc
- ii = sizeof (x) ! { dg-error "Assumed-type argument at .1. is not permitted as actual argument to the intrinsic sizeof" }
+ ii = sizeof (x) ! { dg-error "'x' argument of 'sizeof' intrinsic at \\(1\\) shall not be TYPE\\(\\*\\)" }
ii = c_sizeof (x) ! { dg-error "Assumed-type argument at .1. is not permitted as actual argument to the intrinsic c_sizeof" }
ii = storage_size (x) ! { dg-error "Assumed-type argument at .1. is not permitted as actual argument to the intrinsic storage_size" }
diff --git a/gcc/testsuite/gfortran.dg/sizeof_4.f90 b/gcc/testsuite/gfortran.dg/sizeof_4.f90
new file mode 100644
index 0000000..d4d8baa
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/sizeof_4.f90
@@ -0,0 +1,95 @@
+! { dg-do run }
+!
+! PR fortran/61881
+! PR fortran/61888
+!
+!
+use iso_c_binding
+implicit none
+
+call dim0(5, 4)
+
+call dim1([1, 2, 3], 4*3)
+
+call dimd(5, 4)
+call dimd([1, 2, 3], 4*3)
+call dimd(reshape([1, 4, 2, 3],[2, 2]), 4*4)
+
+call tdim1([1, 2, 3], 4*3)
+call tdim1([1_8, 2_8, 3_8], 8*3)
+
+call tdimd(5, 4)
+call tdimd([1, 2, 3], 4*3)
+call tdimd(reshape([1, 4, 2, 3], [2, 2]), 4*4)
+call tdimd(5_8, 8)
+call tdimd([1_8, 2_8, 3_8], 8*3)
+call tdimd(reshape([1_8, 4_8, 2_8, 3_8],[2,2]), 8*4)
+
+call cdim0(5, 4)
+
+call cdim1([1, 2, 3], 4*3)
+
+call cdimd(5, 4)
+call cdimd([1, 2, 3], 4*3)
+call cdimd(reshape([1,4,2,3],[2,2]), 4*4)
+call cdimd(5_8, 8)
+call cdimd([1_8, 2_8, 3_8], 8*3)
+call cdimd(reshape([1_8, 4_8, 2_8, 3_8], [2, 2]), 8*4)
+
+contains
+
+subroutine dim0(x, expected_size)
+ integer :: x
+ integer, value :: expected_size
+ if (sizeof(x) /= expected_size) call abort()
+ if (storage_size(x)/8 /= expected_size) call abort()
+end
+
+subroutine dim1(x, expected_size)
+ integer, dimension(:) :: x
+ integer, value :: expected_size
+ if (sizeof(x) /= expected_size) call abort()
+ if (storage_size(x)/8*size(x) /= expected_size) call abort()
+end
+
+subroutine dimd(x, expected_size)
+ integer, dimension(..) :: x
+ integer, value :: expected_size
+ if (sizeof(x) /= expected_size) call abort()
+ if (storage_size(x)/8*size(x) /= expected_size) call abort()
+end
+
+subroutine cdim0(x, expected_size)
+ class(*) :: x
+ integer, value :: expected_size
+ if (sizeof(x) /= expected_size) call abort()
+ if (storage_size(x)/8 /= expected_size) call abort()
+end
+
+subroutine cdim1(x, expected_size)
+ class(*), dimension(:) :: x
+ integer, value :: expected_size
+ if (sizeof(x) /= expected_size) call abort()
+ if (storage_size(x)/8*size(x) /= expected_size) call abort()
+end
+
+subroutine cdimd(x, expected_size)
+ class(*), dimension(..) :: x
+ integer, value :: expected_size
+ if (sizeof(x) /= expected_size) call abort()
+ if (storage_size(x)/8*size(x) /= expected_size) call abort()
+end
+
+subroutine tdim1(x, expected_size)
+ type(*), dimension(:) :: x
+ integer, value :: expected_size
+ if (sizeof(x) /= expected_size) call abort()
+end
+
+subroutine tdimd(x, expected_size)
+ type(*), dimension(..) :: x
+ integer, value :: expected_size
+ if (sizeof(x) /= expected_size) call abort()
+end
+
+end
diff --git a/gcc/testsuite/gfortran.dg/storage_size_1.f08 b/gcc/testsuite/gfortran.dg/storage_size_1.f08
index ade9dfc..71d3589 100644
--- a/gcc/testsuite/gfortran.dg/storage_size_1.f08
+++ b/gcc/testsuite/gfortran.dg/storage_size_1.f08
@@ -25,7 +25,7 @@ if (storage_size(a) /= 64) call abort()
if (sizeof(b) /= 24) call abort()
if (storage_size(b) /= 64) call abort()
-if (sizeof(cp) /= 8) call abort()
+if (sizeof(cp) /= 12) call abort()
if (storage_size(cp) /= 96) call abort()
end
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch, Fortran] PRs 61881/61888 - Fix issues with SIZEOF, CLASS(*) and assumed-rank
2014-07-26 1:33 [Patch, Fortran] PRs 61881/61888 - Fix issues with SIZEOF, CLASS(*) and assumed-rank Tobias Burnus
@ 2014-07-26 9:38 ` Paul Richard Thomas
2014-07-26 9:53 ` Tobias Burnus
2014-09-02 17:03 ` Thomas Schwinge
1 sibling, 1 reply; 6+ messages in thread
From: Paul Richard Thomas @ 2014-07-26 9:38 UTC (permalink / raw)
To: Tobias Burnus; +Cc: gcc-patches, gfortran
Dear Tobias,
Whilst I am aware that we can now use the single line C++ comment,
would it perhaps be a better idea to stick with the C style comments
just for uniformity?
+ if (arg->ts.type == BT_CLASS)
+ {
+ tmp = gfc_vtable_size_get (TREE_OPERAND (argse.expr, 0));
+ tmp = fold_convert (result_type, tmp);
+ goto done;
+ }
Is there any possibility that the class object will be adorned by any
kind of reference here? In which case, you should drill down through
the TREE_OPERANDS to find it.
Otherwise, this is OK for trunk.
Thanks for the patch
Paul
On 26 July 2014 01:47, Tobias Burnus <burnus@net-b.de> wrote:
> The patch has been motivated by the needs for implementing the openacc
> module. In particular, it does:
>
> - Fix passing intrinsic types to CLASS(*) [F2003]
> - Fix STORAGE_SIZE for polymorphic arrays [F2003]
> - Permit the vendor intrinsic SIZEOF also for TYPE(*) if and only if an
> array descriptor has been used [extend GNU extension]
> - Fix SIZEOF with assumed-rank [fix GNU extension]
> - Document that SIZEOF's result are not well defined for noncontiguous
> arrays. [fix GNU extension]
>
> Build and regtested on x86-64-gnu-linux.
> OK for the trunk?
>
> Tobias
--
The knack of flying is learning how to throw yourself at the ground and miss.
--Hitchhikers Guide to the Galaxy
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch, Fortran] PRs 61881/61888 - Fix issues with SIZEOF, CLASS(*) and assumed-rank
2014-07-26 9:38 ` Paul Richard Thomas
@ 2014-07-26 9:53 ` Tobias Burnus
2014-07-26 19:21 ` Tobias Burnus
0 siblings, 1 reply; 6+ messages in thread
From: Tobias Burnus @ 2014-07-26 9:53 UTC (permalink / raw)
To: Paul Richard Thomas; +Cc: gcc-patches, gfortran
Dear Paul,
Paul Richard Thomas wrote:
> Whilst I am aware that we can now use the single line C++ comment,
> would it perhaps be a better idea to stick with the C style comments
> just for uniformity?
Okay.
> + if (arg->ts.type == BT_CLASS)
> + {
> + tmp = gfc_vtable_size_get (TREE_OPERAND (argse.expr, 0));
> + tmp = fold_convert (result_type, tmp);
> + goto done;
> + }
>
> Is there any possibility that the class object will be adorned by any
> kind of reference here? In which case, you should drill down through
> the TREE_OPERANDS to find it.
I think it should be fine - it just removes the outermost component
reference, which should give the class struct, independently whether it
is class_var or dt(5)%comp(7)%class_comp.
> Otherwise, this is OK for trunk.
> Thanks for the patch
Assuming that the second part is okay, I have now committed it with the
comment-style change as Rev. 213079.
Thanks for the patch review!
Tobias
PS: Next on my to-do list is to post a RFC version of openacc_lib.h /
module openacc, using the patch, for the gomp-4_0-branch. And then I
want to continue on the locking/critical section support for coarrays.
PPS: I realized that the sub-pointer issues, where the actual stride is
not a multiple of the element length, very quickly and badly hits me
with scalar derived-type coarrays with array components. Thus, to
support those, I am also very interested in getting the new array
descriptor up and running and onto the trunk⦠I do not really like the
idea of coding around that issue.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch, Fortran] PRs 61881/61888 - Fix issues with SIZEOF, CLASS(*) and assumed-rank
2014-07-26 9:53 ` Tobias Burnus
@ 2014-07-26 19:21 ` Tobias Burnus
0 siblings, 0 replies; 6+ messages in thread
From: Tobias Burnus @ 2014-07-26 19:21 UTC (permalink / raw)
To: Paul Richard Thomas; +Cc: gcc-patches, gfortran
[-- Attachment #1: Type: text/plain, Size: 426 bytes --]
Tobias Burnus wrote:
> Assuming that the second part is okay, I have now committed it with
> the comment-style change as Rev. 213079.
Dominique has pointed out (thanks!) that the patch fixed PR57305 - and
reading that PR, I saw that I missed the declared -> dynamic type
change. Hence, I have committed the attached patch (as Rev. 213085) and
added also the PR numbers to the changelog, what I had missed before.
Tobias
[-- Attachment #2: committed.diff --]
[-- Type: text/x-patch, Size: 2069 bytes --]
Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog (Revision 213084)
+++ gcc/fortran/ChangeLog (Arbeitskopie)
@@ -1,5 +1,16 @@
2014-07-26 Tobias Burnus <burnus@net-b.de>
+ PR fortran/61881
+ PR fortran/61888
+ PR fortran/57305
+ * intrinsic.texi (SIZEOF): Document changed behavior
+ for polymorphic arrays.
+
+2014-07-26 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/61881
+ PR fortran/61888
+ PR fortran/57305
* check.c (gfc_check_sizeof): Permit for assumed type if and
only if it has an array descriptor.
* intrinsic.c (do_ts29113_check): Permit SIZEOF.
Index: gcc/fortran/intrinsic.texi
===================================================================
--- gcc/fortran/intrinsic.texi (Revision 213084)
+++ gcc/fortran/intrinsic.texi (Arbeitskopie)
@@ -12204,10 +12204,10 @@ number of bytes occupied by the argument. If the
to is returned. If the argument is of a derived type with @code{POINTER}
or @code{ALLOCATABLE} components, the return value does not account for
the sizes of the data pointed to by these components. If the argument is
-polymorphic, the size according to the declared type is returned. The argument
+polymorphic, the size according to the dynamic type is returned. The argument
may not be a procedure or procedure pointer. Note that the code assumes for
arrays that those are contiguous; for contiguous arrays, it returns the
-storage or an array element multiplicated by the size of the array.
+storage or an array element multiplied by the size of the array.
@item @emph{Example}:
@smallexample
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog (Revision 213084)
+++ gcc/testsuite/ChangeLog (Arbeitskopie)
@@ -5,6 +5,9 @@
2014-07-26 Tobias Burnus <burnus@net-b.de>
+ PR fortran/61881
+ PR fortran/61888
+ PR fortran/57305
* gfortran.dg/sizeof_2.f90: Change dg-error.
* gfortran.dg/sizeof_4.f90: New.
* gfortran.dg/storage_size_1.f08: Correct expected
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch, Fortran] PRs 61881/61888 - Fix issues with SIZEOF, CLASS(*) and assumed-rank
2014-07-26 1:33 [Patch, Fortran] PRs 61881/61888 - Fix issues with SIZEOF, CLASS(*) and assumed-rank Tobias Burnus
2014-07-26 9:38 ` Paul Richard Thomas
@ 2014-09-02 17:03 ` Thomas Schwinge
2014-09-03 6:43 ` Tobias Burnus
1 sibling, 1 reply; 6+ messages in thread
From: Thomas Schwinge @ 2014-09-02 17:03 UTC (permalink / raw)
To: Tobias Burnus; +Cc: gcc-patches, gfortran
[-- Attachment #1: Type: text/plain, Size: 1302 bytes --]
Hi Tobias!
On Sat, 26 Jul 2014 01:47:02 +0200, Tobias Burnus <burnus@net-b.de> wrote:
> 2014-07-26 Tobias Burnus <burnus@net-b.de>
>
> * check.c (gfc_check_sizeof): Permit for assumed type if and
> only if it has an array descriptor.
> * intrinsic.c (do_ts29113_check): Permit SIZEOF.
> (add_functions): SIZEOF is an Inquiry function.
> * intrinsic.texi (SIZEOF): Add note that only contiguous
> arrays are permitted.
> * trans-expr.c (gfc_conv_intrinsic_to_class): Handle assumed
> rank.
> * trans-intrinsic.c (gfc_conv_intrinsic_sizeof): Handle
> assumed type + array descriptor, CLASS and assumed rank.
> (gfc_conv_intrinsic_storage_size): Handle class arrays.
>
> 2014-07-26 Tobias Burnus <burnus@net-b.de>
>
> * gfortran.dg/sizeof_2.f90: Change dg-error.
> * gfortran.dg/sizeof_4.f90: New.
> * gfortran.dg/storage_size_1.f08: Correct expected
> value.
I noticed that the sizeof_4.f90 test case has not been checked in,
probably just forgot to svn add the file?
Searching for it in my emails, I also noticed that a year ago a similar
patch has been posted in
<http://news.gmane.org/find-root.php?message_id=%3CCAKwh3qi633jU-ojPKqRa_16DKWhXn9L2N0Wr4trAG9p1dJ-sXg%40mail.gmail.com%3E>,
but that is now probably obsolete.
Grüße,
Thomas
[-- Attachment #2: Type: application/pgp-signature, Size: 472 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch, Fortran] PRs 61881/61888 - Fix issues with SIZEOF, CLASS(*) and assumed-rank
2014-09-02 17:03 ` Thomas Schwinge
@ 2014-09-03 6:43 ` Tobias Burnus
0 siblings, 0 replies; 6+ messages in thread
From: Tobias Burnus @ 2014-09-03 6:43 UTC (permalink / raw)
To: Thomas Schwinge; +Cc: gcc-patches, gfortran
Thomas Schwinge wrote:
> On Sat, 26 Jul 2014 01:47:02 +0200, Tobias Burnus <burnus@net-b.de> wrote:
>> [...]
>> 2014-07-26 Tobias Burnus <burnus@net-b.de>
>>
>> * gfortran.dg/sizeof_4.f90: New.
>> [...]
> I noticed that the sizeof_4.f90 test case has not been checked in,
> probably just forgot to svn add the file?
I have now committed it as Rev. 214843 - it was lying indeed around in
my commit-tree, lacking the "svn add".
Tobias
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-09-03 6:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-26 1:33 [Patch, Fortran] PRs 61881/61888 - Fix issues with SIZEOF, CLASS(*) and assumed-rank Tobias Burnus
2014-07-26 9:38 ` Paul Richard Thomas
2014-07-26 9:53 ` Tobias Burnus
2014-07-26 19:21 ` Tobias Burnus
2014-09-02 17:03 ` Thomas Schwinge
2014-09-03 6:43 ` Tobias Burnus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).