This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch, fortran] PR36355: fix argument type checking for matmul


Daniel Franke wrote:
Updated patch attached, not regression tested yet.
Still NOT OK. It is valid to mix two numeric types, e.g. integer + real (result: real), or real + complex (result: complex):

print *, matmul(a,b)
1
Error: Argument types of 'matmul' intrinsic at (1) must match (INTEGER(4)/REAL(4))


You need to test:

if (matrix_a->ts.type != matrix_b->ts.type
|| (gfc_numeric_ts (&matrix_a->ts) && gfc_numeric_ts (&matrix_b->ts))


Besides: I don't like your error message. I'd prefer "must be the same" otherwise the text in the parentheses is misleading. However, in our case this is not the right choice either. Other compilers use:


"Error: Data type mismatch in arguments to MATMUL intrinsic" (NAG f95)

Which looks ok, here one could append a ": %s and %s" or " (%s/%s)".

Alternative (based on g95/gfortran old output):
"Error: Argument of 'matmul' intrinsic at (1) must be all numeric or all logical"
(the "%s..." type stuff could also be added)


ifort:
Error: Logical and numeric arguments must not be mixed.

Tobias

PS: When you create a final patch, please include also test cases for valid and invalid code.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]