[patch, fortran] PR20373 - intrinsic symbols can be given the wrong type (take 3)
Daniel Franke
franke.daniel@gmail.com
Fri Jun 22 07:16:00 GMT 2007
On Friday 22 June 2007 01:37:18 Brooks Moses wrote:
> Daniel Franke wrote:
> > __convert_* functions are internally used and generated to implicitely
> > convert between types where possible. The symbols of these functions have
> > the "intrinsic" bit set, which results in something unintended:
> >
> > logical, parameter :: maybe = -1
> > 1
> > Warning: Type specified for intrinsic function '__convert_i4_l4' at (1)
> > is ignored
> >
> > Applying the change below avoids the warning (gfc_convert_type_warn):
>
> [Note: the change removes the "intrinsic" attribute on these functions.]
>
> It seems odd that this statement is causing a "type specified for
> function" error in the first place, though.
>
> What happens if you put an "explicit" intrinsic function there instead
> of the implicit "convert" one -- i.e.,
>
> integer, parameter :: maybe = abs(-1)
>
> Does that also get the same error? If not, what's different?
If a conversion is involved and the intrinsic bit is set to the conversion
functions, the warning shown above is given (e.g. ANINT(3.2)). Without the
intrinsic bit for conversion functions, everything seems to be fine. The
reason:
The same function that sets the intrinsic bit also adds a type:
[snip]
new->symtree->n.sym->ts = *ts; /* type specification */
new->symtree->n.sym->attr.flavor = FL_PROCEDURE;
new->symtree->n.sym->attr.function = 1;
new->symtree->n.sym->attr.intrinsic = 1; /* this line was removed */
[/snip]
Thus triggering this codepath of the patch:
+ if (sym->attr.flavor != FL_MODULE && sym->attr.intrinsic)
+ {
+ if (gfc_intrinsic_name (sym->name, 0))
+ {
+ if (sym->ts.type != BT_UNKNOWN && gfc_option.warn_surprising)
+ gfc_warning ("Type specified for intrinsic function '%s' at %L is
ignored",
+ sym->name, &sym->declared_at);
+ }
This warning was meant for constructs as
complex, intrinsic :: sum
only.
Regards
Daniel
More information about the Fortran
mailing list