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] PRs 20862, 23152, 25053, 25063, 25064, 25066, 25067, 25068, 25069, 25307 data transfer constraints


:REVIEWMAIL:

> --- 1063,1082 ----
>   
>         if (tag == &tag_iostat && e->ts.kind != gfc_default_integer_kind)
>   	{
> ! 	  if (gfc_notify_std (GFC_STD_GNU, "Fortran 95 requires default "
>   			      "integer kind in IOSTAT tag at %L",
>   			      &e->where) == FAILURE)
>   	    return FAILURE;
>   	}

Here and immediately below a 'default INTEGER' is required, not a 'default
integer kind'.  Actually, a scalar-default-in-var is required, so you should
tighten up that check some more.

> +   match m;
> +   gfc_expr * expr;
> +   gfc_symbol * sym = NULL;
> + 
> +   m = MATCH_YES;
> + 
> +   expr = dt->io_unit;
> +   if (expr && expr->expr_type == EXPR_VARIABLE
> + 	&& expr->ts.type == BT_CHARACTER)
> +     {
> +       sym = expr->symtree->n.sym;
> + 
> +       io_constraint (k == M_WRITE && sym->attr.intent == INTENT_IN,
> + 		     "Internal file at %L must not be INTENT(IN)",
> + 		     &expr->where);
> + 
> +       io_constraint (gfc_has_vector_index (dt->io_unit),
> + 		     "Internal file incompatible with vector subscript at %L",
> + 		     &expr->where);
> + 
> +       io_constraint (dt->rec != NULL,
> + 		     "REC tag at %L is incompatible with internal file",
> + 		     &dt->rec->where);
> + 
> +       io_constraint (dt->namelist != NULL,
> + 		     "Internal file at %L is incompatible with namelist",
> + 		     &expr->where);
> + 
> +       io_constraint (dt->advance != NULL,
> + 		     "ADVANCE tag at %L is incompatible with internal file",
> + 		     &dt->advance->where);
> +     }
> + 
> +   if (expr && expr->ts.type != BT_CHARACTER)
> +     {
> + 
> +       io_constraint (gfc_pure (NULL)
> + 		       && (k == M_READ || k == M_WRITE),
> + 		     "IO UNIT in %s statement at %C must be "
> + 		     "an internal file in a PURE procedure",
> + 		     io_kind_name (k));
> +     }

Is it not also an error if an internal unit is expr->ts.type == BT_CHARACTER
&& expr->expr_type != BT_CHARACTER.

> +       not_no = strncmp (advance, "no", 2) != 0 && strncmp (advance, "NO", 2);
> +       not_yes = strncmp (advance, "yes", 2) != 0 && strncmp (advance, "YES", 2);

What about 'No', 'nO', 'yeS' etc.?  Fortunately, libiberty provides
strncasecmp :-)

Apart from that this is ok.

I believe introducing a gfc_is_writable (gfc_expr *), which encapsulates
checks for INTENT(IN), constness, non-localness (in PURE procedures) and
EXPR_VARIABLE would be a good idea, there are several places where we have to
check if an expression may be written to, e.g. when passing them to
INTENT(OUT) arguments or as internal-io unit.

Cheers,
- Tobi


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