[Patch, Fortran, OOP] PR 49638: [OOP] length parameter is ignored when overriding type bound character functions with constant length.

Thomas Koenig tkoenig@netcologne.de
Sun Aug 7 12:39:00 GMT 2011


Am 07.08.2011 12:56, schrieb Janus Weil:
> +      /* Check string length.  */
> +      if (proc_target->result->ts.type == BT_CHARACTER
> +	&&  proc_target->result->ts.u.cl&&  old_target->result->ts.u.cl
> +	&&  gfc_dep_compare_expr (proc_target->result->ts.u.cl->length,
> +				   old_target->result->ts.u.cl->length) != 0)
> +	{
> +	  gfc_error ("Character length mismatch between '%s' at '%L' "
> +		     "and overridden FUNCTION", proc->name,&where);
> +	  return FAILURE;
> +	}
>       }

Well, let's make this into (again, typing the patch directly into
e-mail)

	
       /* Check string length.  */
       if (proc_target->result->ts.type == BT_CHARACTER
	  && proc_target->result->ts.u.cl && old_target->result->ts.u.cl
             {
                int compval =
	  gfc_dep_compare_expr (proc_target->result->ts.u.cl->length,
				   old_target->result->ts.u.cl->length);

              switch (compval)
	{
	    case -3:
             case -1:
             case 1:

	  gfc_error ("Character length mismatch between '%s' at '%L' "
		     "and overridden FUNCTION", proc->name, &where);
	  return FAILURE;

	    case -2:
            gfc_warning ("Possible length mismatch between '%s' at '%L' "
                         "and overriden FUNCTION, proc->name, &where);
            break;

	case 0:
	    break;

	default:
	    gfc_internal_error ("Unexpected return of gfc_dep_compare_expr";
            break;
        }

and then work on extending gfc_dep_compare_expr to return -3 for more 
cases.  I can help with that.

Regards

	Thomas



More information about the Gcc-patches mailing list