This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [patch, fortran] PR36355: fix argument type checking for matmul
- From: "Daniel Franke" <franke dot daniel at gmail dot com>
- To: "Tobias Burnus" <burnus at net-b dot de>
- Cc: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Wed, 28 May 2008 17:31:02 +0200
- Subject: Re: [patch, fortran] PR36355: fix argument type checking for matmul
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; bh=ZQgKzMOLinH6lLKFsBwbyUfesvNUKdUcH+6G30VMy1s=; b=mFr7ZX3eX4SfJzYWSOSnSfKlluKVqLuoyUORj6ZdYXU3mKeExOeGJ3AJDzdrIoVZM/5yb3wuGqNKA8oXMslTswTBn1BYldzj5VtOtzvcPKHA9k42NfODu1joUyd4x2kfpHwpYmHAdbxmixFGy1mdjBusULC4PRG2H/h1oFr5uwY=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=G3q0UIrW0Xg4a7Hvf3JLByle4xjb5FUD0zOQZ5y5Amgvm+gPFJd358OeH4lYmn8v6a0sUzHuMI+KrYZt5N9G6f4s+5jW/Cdel/I+W1YgdPU3UmXyttbUg1jS6yQS6ia2O79pZAXuX+N6G83JPAkytCNEWK/Ju4H8u3q+ShzLBKw=
- References: <640ad44b0805280503m1b1e968ds78357844a17368e7@mail.gmail.com> <483D7340.4040603@net-b.de>
2008/5/28, Tobias Burnus <burnus@net-b.de>:
> a) a=[logical/numeric], b = invalid(e.g. character)
> b) a = invalid(e.g. character), b=[logical/numeric]
> c) a=logical, b = numerical
> d) a=numerical, b = logical.
>
> Test program, which should be rejected:
>
> integer :: a(4,4)
> logical :: b(4,4)
> print *, matmul(a,b)
> end
matmul.f90:12.19:
print *, matmul(a,b)
1
Error: Argument types of 'matmul' intrinsic at (1) must match
(INTEGER(4)/LOGICAL(4))
Updated patch attached, not regression tested yet.
Index: check.c
===================================================================
--- check.c (revision 136058)
+++ check.c (working copy)
@@ -1761,7 +1761,7 @@ gfc_check_malloc (gfc_expr *size)
try
gfc_check_matmul (gfc_expr *matrix_a, gfc_expr *matrix_b)
{
- if ((matrix_a->ts.type != BT_LOGICAL) && !gfc_numeric_ts (&matrix_b->ts))
+ if ((matrix_a->ts.type != BT_LOGICAL) && !gfc_numeric_ts (&matrix_a->ts))
{
gfc_error ("'%s' argument of '%s' intrinsic at %L must be numeric "
"or LOGICAL", gfc_current_intrinsic_arg[0],
@@ -1769,7 +1769,7 @@ gfc_check_matmul (gfc_expr *matrix_a, gf
return FAILURE;
}
- if ((matrix_b->ts.type != BT_LOGICAL) && !gfc_numeric_ts (&matrix_a->ts))
+ if ((matrix_b->ts.type != BT_LOGICAL) && !gfc_numeric_ts (&matrix_b->ts))
{
gfc_error ("'%s' argument of '%s' intrinsic at %L must be numeric "
"or LOGICAL", gfc_current_intrinsic_arg[1],
@@ -1777,6 +1777,14 @@ gfc_check_matmul (gfc_expr *matrix_a, gf
return FAILURE;
}
+ if (matrix_a->ts.type != matrix_b->ts.type)
+ {
+ gfc_error ("Argument types of '%s' intrinsic at %L must match (%s/%s)",
+ gfc_current_intrinsic, &matrix_a->where,
+ gfc_typename(&matrix_a->ts), gfc_typename(&matrix_b->ts));
+ return FAILURE;
+ }
+
switch (matrix_a->rank)
{
case 1: