public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/31564] New: Error: Type/rank mismatch in argument
@ 2007-04-13 17:48 michael dot a dot richmond at nasa dot gov
2007-04-13 18:05 ` [Bug fortran/31564] " kargl at gcc dot gnu dot org
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: michael dot a dot richmond at nasa dot gov @ 2007-04-13 17:48 UTC (permalink / raw)
To: gcc-bugs
When I compile the module listed below I get the message:
c3.f90:15.23:
USE cdf_aux_mod
1
Error: Type/rank mismatch in argument 'arg_name' at (1)
g95 and Lahey do not produce error messages. Is it legal?
MODULE cdf_aux_mod
TYPE :: the_distribution
INTEGER :: parameters(1)
END TYPE the_distribution
TYPE (the_distribution), PARAMETER :: the_beta = the_distribution((/0/))
CONTAINS
SUBROUTINE set_bound(arg_name)
INTEGER, INTENT (IN) :: arg_name
END SUBROUTINE set_bound
END MODULE cdf_aux_mod
MODULE cdf_beta_mod
CONTAINS
SUBROUTINE cdf_beta()
USE cdf_aux_mod
INTEGER :: which
CALL set_bound(the_beta%parameters(which))
END SUBROUTINE cdf_beta
END MODULE cdf_beta_mod
--
Summary: Error: Type/rank mismatch in argument
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: michael dot a dot richmond at nasa dot gov
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31564
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/31564] Error: Type/rank mismatch in argument
2007-04-13 17:48 [Bug fortran/31564] New: Error: Type/rank mismatch in argument michael dot a dot richmond at nasa dot gov
@ 2007-04-13 18:05 ` kargl at gcc dot gnu dot org
2007-04-13 18:40 ` burnus at gcc dot gnu dot org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: kargl at gcc dot gnu dot org @ 2007-04-13 18:05 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from kargl at gcc dot gnu dot org 2007-04-13 19:05 -------
The code is illegal, but in accordance with the error message.
You need to set WHICH to 1 via either
INTEGER :: which = 1
or
which = 1
This however doesn't fix the problem. If you change the call to
CALL set_bound(the_beta%parameters(1))
then it compiles. So, it looks as if gfortran isn't
properly evaluating the derived type arguments.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31564
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/31564] Error: Type/rank mismatch in argument
2007-04-13 17:48 [Bug fortran/31564] New: Error: Type/rank mismatch in argument michael dot a dot richmond at nasa dot gov
2007-04-13 18:05 ` [Bug fortran/31564] " kargl at gcc dot gnu dot org
@ 2007-04-13 18:40 ` burnus at gcc dot gnu dot org
2007-04-22 17:49 ` eedelman at gcc dot gnu dot org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-04-13 18:40 UTC (permalink / raw)
To: gcc-bugs
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |rejects-valid
Last reconfirmed|0000-00-00 00:00:00 |2007-04-13 19:39:56
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31564
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/31564] Error: Type/rank mismatch in argument
2007-04-13 17:48 [Bug fortran/31564] New: Error: Type/rank mismatch in argument michael dot a dot richmond at nasa dot gov
2007-04-13 18:05 ` [Bug fortran/31564] " kargl at gcc dot gnu dot org
2007-04-13 18:40 ` burnus at gcc dot gnu dot org
@ 2007-04-22 17:49 ` eedelman at gcc dot gnu dot org
2007-05-27 23:40 ` burnus at gcc dot gnu dot org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: eedelman at gcc dot gnu dot org @ 2007-04-22 17:49 UTC (permalink / raw)
To: gcc-bugs
--
eedelman at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |eedelman at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
Last reconfirmed|2007-04-13 19:39:56 |2007-04-22 18:49:14
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31564
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/31564] Error: Type/rank mismatch in argument
2007-04-13 17:48 [Bug fortran/31564] New: Error: Type/rank mismatch in argument michael dot a dot richmond at nasa dot gov
` (2 preceding siblings ...)
2007-04-22 17:49 ` eedelman at gcc dot gnu dot org
@ 2007-05-27 23:40 ` burnus at gcc dot gnu dot org
2007-05-28 15:41 ` eedelman at gcc dot gnu dot org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-05-27 23:40 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from burnus at gcc dot gnu dot org 2007-05-27 23:40 -------
Created an attachment (id=13618)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13618&action=view)
decl.c patch (not check-gfortran tested)
Erik, are you still working on this?
One should also check that:
CALL set_bound(the_beta%parameters(1:which))
is rejected. (This does not seem to call compare_parameter).
First step, to get it further is to modify compare_parameter (see attachment).
However, this then crashes in trans-expr.c's gfc_conv_function_call (l.2148)
[invalid memory access].
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31564
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/31564] Error: Type/rank mismatch in argument
2007-04-13 17:48 [Bug fortran/31564] New: Error: Type/rank mismatch in argument michael dot a dot richmond at nasa dot gov
` (3 preceding siblings ...)
2007-05-27 23:40 ` burnus at gcc dot gnu dot org
@ 2007-05-28 15:41 ` eedelman at gcc dot gnu dot org
2007-05-28 18:51 ` eedelman at gcc dot gnu dot org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: eedelman at gcc dot gnu dot org @ 2007-05-28 15:41 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from eedelman at gcc dot gnu dot org 2007-05-28 15:41 -------
(In reply to comment #2)
> Created an attachment (id=13618)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13618&action=view) [edit]
> decl.c patch (not check-gfortran tested)
>
> Erik, are you still working on this?
Officially, yes :-)
I.e., I began, but now I haven't had time to look at it for a couple of weeks.
Just go ahead and fix it if you are interested.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31564
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/31564] Error: Type/rank mismatch in argument
2007-04-13 17:48 [Bug fortran/31564] New: Error: Type/rank mismatch in argument michael dot a dot richmond at nasa dot gov
` (4 preceding siblings ...)
2007-05-28 15:41 ` eedelman at gcc dot gnu dot org
@ 2007-05-28 18:51 ` eedelman at gcc dot gnu dot org
2007-06-03 19:28 ` eedelman at gcc dot gnu dot org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: eedelman at gcc dot gnu dot org @ 2007-05-28 18:51 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from eedelman at gcc dot gnu dot org 2007-05-28 18:51 -------
(In reply to comment #3)
> (In reply to comment #2)
> > Created an attachment (id=13618)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13618&action=view) [edit]
> > decl.c patch (not check-gfortran tested)
> >
> > Erik, are you still working on this?
>
> Officially, yes :-)
> I.e., I began, but now I haven't had time to look at it for a couple of weeks.
> Just go ahead and fix it if you are interested.
Just to add one more data point: It's not just procedure arguments that are
problematic; it's expression like
foo%array(variable)
in general, where foo is a PARAMETER. E.g. this piece of code is also
rejected:
SUBROUTINE cdf_beta()
TYPE :: the_distribution
INTEGER :: parameters(1)
END TYPE the_distribution
TYPE (the_distribution), PARAMETER :: the_beta = the_distribution((/0/))
INTEGER :: which, pooh
which = 1
pooh = the_beta%parameters(which)
END SUBROUTINE cdf_beta
erik:~/gcc$ gfortran pr31564.f90
pr31564.f90:12.8:
pooh = the_beta%parameters(which)
1
Error: Incompatible ranks 0 and 1 in assignment at (1)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31564
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/31564] Error: Type/rank mismatch in argument
2007-04-13 17:48 [Bug fortran/31564] New: Error: Type/rank mismatch in argument michael dot a dot richmond at nasa dot gov
` (5 preceding siblings ...)
2007-05-28 18:51 ` eedelman at gcc dot gnu dot org
@ 2007-06-03 19:28 ` eedelman at gcc dot gnu dot org
2007-08-18 6:04 ` pault at gcc dot gnu dot org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: eedelman at gcc dot gnu dot org @ 2007-06-03 19:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from eedelman at gcc dot gnu dot org 2007-06-03 19:28 -------
I never seem to get time to do anything about this bug, so I'll better unassign
it from me.
--
eedelman at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|eedelman at gcc dot gnu dot |unassigned at gcc dot gnu
|org |dot org
Status|ASSIGNED |NEW
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31564
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/31564] Error: Type/rank mismatch in argument
2007-04-13 17:48 [Bug fortran/31564] New: Error: Type/rank mismatch in argument michael dot a dot richmond at nasa dot gov
` (6 preceding siblings ...)
2007-06-03 19:28 ` eedelman at gcc dot gnu dot org
@ 2007-08-18 6:04 ` pault at gcc dot gnu dot org
2007-09-04 18:16 ` pault at gcc dot gnu dot org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-08-18 6:04 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from pault at gcc dot gnu dot org 2007-08-18 06:04 -------
This one is a real head-banger. The array element reference is being
completely ignored in translation. I tried simplifying it by grabbing out the
array component and attaching the array reference to it. The resulting
expression looks fine but the reference is ignore further downstream; I have
run out of time to look at this, for a while. Note that replacing the array
component of a derived type parameter with a parameter array works fine.
Just for the record, my attempt to fix this by simplification appears below.
Paul
Index: gcc/fortran/expr.c
===================================================================
*** gcc/fortran/expr.c (revision 127505)
--- gcc/fortran/expr.c (working copy)
*************** simplify_ref_chain (gfc_ref *ref, int ty
*** 1461,1466 ****
--- 1461,1535 ----
}
+ /* Simplify structure references. */
+
+ static void
+ simplify_structure_refs (gfc_expr *e)
+ {
+ int n;
+ bool seen_array_ref;
+ bool reduced_structure = false;
+ gfc_ref *ref;
+ gfc_component *cmp;
+ gfc_constructor *ctr;
+ gfc_expr *p = e;
+ gfc_symtree *st;
+
+ if (e->expr_type != EXPR_STRUCTURE)
+ return;
+
+ start:
+ seen_array_ref = false;
+ ref = p->ref;
+
+ for (; ref; ref = ref->next)
+ {
+ switch (ref->type)
+ {
+ case REF_COMPONENT:
+ if (p->symtree
+ && p->symtree->n.sym->ts.derived
+ && !p->ts.derived)
+ p->ts = p->symtree->n.sym->ts;
+
+ if (seen_array_ref || !p->ts.derived)
+ break;
+
+ ctr = p->value.constructor;
+ cmp = p->ts.derived->components;
+ for (;ctr; ctr = ctr->next, cmp = cmp->next)
+ {
+ if (ref->u.c.component != cmp || ctr->expr == NULL)
+ continue;
+ p = ctr->expr;
+ p->ts = cmp->ts;
+ ctr->expr = NULL;
+ p->ref = ref->next;
+ ref->next = NULL;
+ gfc_free_expr (e);
+ *e = *p;
+ reduced_structure = true;
+ goto start;
+ }
+ break;
+
+ case REF_ARRAY:
+ for (n = 0; n < ref->u.ar.dimen; n++)
+ {
+ if (reduced_structure
+ && ref->u.ar.dimen_type[n] == DIMEN_ELEMENT)
+ p->rank--;
+ }
+ seen_array_ref = true;
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+
+
/* Try to substitute the value of a parameter variable. */
static try
*************** gfc_simplify_expr (gfc_expr *p, int type
*** 1604,1609 ****
--- 1673,1681 ----
if (simplify_ref_chain (p->ref, type) == FAILURE)
return FAILURE;
+ if (p->ref)
+ simplify_structure_refs (p);
+
if (simplify_constructor (p->value.constructor, type) == FAILURE)
return FAILURE;
*************** gfc_check_pointer_assign (gfc_expr *lval
*** 2749,2755 ****
is_pure = gfc_pure (NULL);
! if (is_pure && gfc_impure_variable (lvalue->symtree->n.sym))
{
gfc_error ("Bad pointer object in PURE procedure at %L",
&lvalue->where)
;
return FAILURE;
--- 2821,2828 ----
is_pure = gfc_pure (NULL);
! if (is_pure && gfc_impure_variable (lvalue->symtree->n.sym)
! && lvalue->symtree->n.sym->value != rvalue)
{
gfc_error ("Bad pointer object in PURE procedure at %L",
&lvalue->where)
;
return FAILURE;
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31564
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/31564] Error: Type/rank mismatch in argument
2007-04-13 17:48 [Bug fortran/31564] New: Error: Type/rank mismatch in argument michael dot a dot richmond at nasa dot gov
` (7 preceding siblings ...)
2007-08-18 6:04 ` pault at gcc dot gnu dot org
@ 2007-09-04 18:16 ` pault at gcc dot gnu dot org
2007-09-05 13:35 ` pault at gcc dot gnu dot org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-09-04 18:16 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from pault at gcc dot gnu dot org 2007-09-04 18:16 -------
To my surprise, I have a fix for this one. I'll post it to the list in the
next 48 hours.
Paul
--
pault at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |pault at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2007-04-22 18:49:14 |2007-09-04 18:16:23
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31564
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/31564] Error: Type/rank mismatch in argument
2007-04-13 17:48 [Bug fortran/31564] New: Error: Type/rank mismatch in argument michael dot a dot richmond at nasa dot gov
` (8 preceding siblings ...)
2007-09-04 18:16 ` pault at gcc dot gnu dot org
@ 2007-09-05 13:35 ` pault at gcc dot gnu dot org
2007-09-05 13:38 ` pault at gcc dot gnu dot org
2007-09-06 11:56 ` patchapp at dberlin dot org
11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-09-05 13:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from pault at gcc dot gnu dot org 2007-09-05 13:34 -------
Subject: Bug 31564
Author: pault
Date: Wed Sep 5 13:34:25 2007
New Revision: 128130
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128130
Log:
2007-09-05 Paul Thomas <pault@gcc.gnu.org>
PR fortran/31564
* primary.c (gfc_match_rvalue): Make expressions that refer
to derived type parameters that have array references into
variable expressions. Remove references to use association
from the symbol.
PR fortran/33241
* decl.c (add_init_expr_to_sym): Provide assumed character
length parameters with the length of the initialization
expression, if a constant, or that of the first element of
an array.
2007-09-05 Paul Thomas <pault@gcc.gnu.org>
PR fortran/31564
* gfortran.dg/derived_comp_array_ref_2.f90: New test.
PR fortran/33241
* gfortran.dg/char_length_10.f90: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/char_length_10.f90
trunk/gcc/testsuite/gfortran.dg/derived_comp_array_ref_2.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/decl.c
trunk/gcc/fortran/primary.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31564
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/31564] Error: Type/rank mismatch in argument
2007-04-13 17:48 [Bug fortran/31564] New: Error: Type/rank mismatch in argument michael dot a dot richmond at nasa dot gov
` (9 preceding siblings ...)
2007-09-05 13:35 ` pault at gcc dot gnu dot org
@ 2007-09-05 13:38 ` pault at gcc dot gnu dot org
2007-09-06 11:56 ` patchapp at dberlin dot org
11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-09-05 13:38 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from pault at gcc dot gnu dot org 2007-09-05 13:38 -------
Fixed on trunk.
Paul
--
pault at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31564
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/31564] Error: Type/rank mismatch in argument
2007-04-13 17:48 [Bug fortran/31564] New: Error: Type/rank mismatch in argument michael dot a dot richmond at nasa dot gov
` (10 preceding siblings ...)
2007-09-05 13:38 ` pault at gcc dot gnu dot org
@ 2007-09-06 11:56 ` patchapp at dberlin dot org
11 siblings, 0 replies; 13+ messages in thread
From: patchapp at dberlin dot org @ 2007-09-06 11:56 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from patchapp at dberlin dot org 2007-09-06 11:55 -------
Subject: Bug number PR31564
A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2007-09/msg00319.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31564
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2007-09-06 11:56 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-13 17:48 [Bug fortran/31564] New: Error: Type/rank mismatch in argument michael dot a dot richmond at nasa dot gov
2007-04-13 18:05 ` [Bug fortran/31564] " kargl at gcc dot gnu dot org
2007-04-13 18:40 ` burnus at gcc dot gnu dot org
2007-04-22 17:49 ` eedelman at gcc dot gnu dot org
2007-05-27 23:40 ` burnus at gcc dot gnu dot org
2007-05-28 15:41 ` eedelman at gcc dot gnu dot org
2007-05-28 18:51 ` eedelman at gcc dot gnu dot org
2007-06-03 19:28 ` eedelman at gcc dot gnu dot org
2007-08-18 6:04 ` pault at gcc dot gnu dot org
2007-09-04 18:16 ` pault at gcc dot gnu dot org
2007-09-05 13:35 ` pault at gcc dot gnu dot org
2007-09-05 13:38 ` pault at gcc dot gnu dot org
2007-09-06 11:56 ` patchapp at dberlin dot org
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).