This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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: PING [gfortran] PATCH Fix PR 19754 (with regressions)]


Steve Kargl wrote:
> 2005-02-03  Steven G. Kargl  <kargls@comcast.net>
> 
>       * resolve.c (compare_shapes):  New function.
>       (resolve_operator): Use it.

> +  for (i = 0; i < op1->rank; i++)
> +    {
> +      if (op1->shape != NULL && op2->shape != NULL)
> +	{

This check can be moved outside the loop.

> -
>  	      if (e->shape == NULL)
> -		e->shape = gfc_copy_shape (op1->shape, op1->rank);
> -
> +		{
> +		  e->shape = gfc_copy_shape (op1->shape, op1->rank);
> +		  if (compare_shapes(op1, op2) == FAILURE)
> +		    {
> +                      msg[0] = '\0';
> +		      goto bad_op;
> +		    }
> +		}
>  	    }
>  	  else
>  	    {
> @@ -1499,10 +1539,13 @@
>    return t;
>  
>  bad_op:
> +
>    if (gfc_extend_expr (e) == SUCCESS)
>      return SUCCESS;
>  
> -  gfc_error (msg, &e->where);
> +  if (msg[0] != '\0')
> +    gfc_error (msg, &e->where);
> +
>    return FAILURE;
>  }

Error handling should be handled the same way as for the case where the ranks
don't match.  The route through bad_op is for user-defined operators.

Also, you should add testcases which test for the new error message.

- Tobi


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