[PATCH] fortran/41918 -- silence a warning

View: New views
4 Messages — Rating Filter:   Alert me  

[PATCH] fortran/41918 -- silence a warning

by Steve Kargl :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The patch has been built and regtested on x86_64-*-freebsd.
There are no regression.  I'm not sure if this will silence
all possible warnings where a default initialization can
occur, but it catches those in my tet program.

2009-11-03  Steven G. Kargl  <kargl@...>

   PR fortran/41918
   * fortran/trans-decl.c: Silence intent(out) warning for derived type
   dummy arguments with default initialization.


--
Steve


Index: gcc/fortran/trans-decl.c
===================================================================
--- gcc/fortran/trans-decl.c (revision 153823)
+++ gcc/fortran/trans-decl.c (working copy)
@@ -3776,8 +3776,12 @@ generate_local_decl (gfc_symbol * sym)
       else if (warn_unused_variable
        && sym->attr.dummy
        && sym->attr.intent == INTENT_OUT)
- gfc_warning ("Dummy argument '%s' at %L was declared INTENT(OUT) but was not set",
-     sym->name, &sym->declared_at);
+ {
+  if (!(sym->ts.type == BT_DERIVED
+ && sym->ts.u.derived->components->initializer))
+    gfc_warning ("Dummy argument '%s' at %L was declared INTENT(OUT) "
+         "but was not set",  sym->name, &sym->declared_at);
+ }
       /* Specific warning for unused dummy arguments. */
       else if (warn_unused_variable && sym->attr.dummy)
  gfc_warning ("Unused dummy argument '%s' at %L", sym->name,


Re: [PATCH] fortran/41918 -- silence a warning

by Janne Blomqvist-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Nov 4, 2009 at 01:01, Steve Kargl
<sgk@...> wrote:

> The patch has been built and regtested on x86_64-*-freebsd.
> There are no regression.  I'm not sure if this will silence
> all possible warnings where a default initialization can
> occur, but it catches those in my tet program.
>
> 2009-11-03  Steven G. Kargl  <kargl@...>
>
>   PR fortran/41918
>   * fortran/trans-decl.c: Silence intent(out) warning for derived type
>   dummy arguments with default initialization.
>
>
> --
> Steve
>

Ok.


--
Janne Blomqvist

Re: [PATCH] fortran/41918 -- silence a warning

by Steve Kargl :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Nov 04, 2009 at 01:13:07AM +0200, Janne Blomqvist wrote:

> On Wed, Nov 4, 2009 at 01:01, Steve Kargl
> <sgk@...> wrote:
> > The patch has been built and regtested on x86_64-*-freebsd.
> > There are no regression. ?I'm not sure if this will silence
> > all possible warnings where a default initialization can
> > occur, but it catches those in my tet program.
> >
> > 2009-11-03 ?Steven G. Kargl ?<kargl@...>
> >
> > ? PR fortran/41918
> > ? * fortran/trans-decl.c: Silence intent(out) warning for derived type
> > ? dummy arguments with default initialization.
> >
> >
>
> Ok.
>

Thanks, Janne.

I'll give Tobias a day or so to respond.  In c.l.f. or bugzilla,
he hinted that a similar spurious warning may be issues with
(allocatable?) procedure pointers.  I haven't started to use
procpointers, so can't dream up a test program.

--
Steve

Re: [PATCH] fortran/41918 -- silence a warning

by Tobias Burnus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Am 04.11.2009 00:01, schrieb Steve Kargl:
> The patch has been built and regtested on x86_64-*-freebsd.
> There are no regression.  I'm not sure if this will silence
> all possible warnings where a default initialization can
> occur, but it catches those in my tet program.
>  

+  if (!(sym->ts.type == BT_DERIVED
+ && sym->ts.u.derived->components->initializer))
+    gfc_warning ("Dummy argument '%s' at %L was declared INTENT(OUT) "


Looks OK. Richard Maine would probably also add a check for "alloc_comp" as he sees the automatic deallocation also as a kind of assignment. I am not sure whether this sensible or not.

Tobias