public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "janus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/51945] Diagnose wrong default initialization of DTs in a DT declaration
Date: Thu, 08 Aug 2013 19:46:00 -0000	[thread overview]
Message-ID: <bug-51945-4-rt7WWiAHRh@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-51945-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51945

--- Comment #4 from janus at gcc dot gnu.org ---
The following patch should somewhat improve the situation:


Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c    (revision 201576)
+++ gcc/fortran/resolve.c    (working copy)
@@ -1178,7 +1178,7 @@ resolve_structure_cons (gfc_expr *expr, int init)
              gfc_basic_typename (comp->ts.type));
           t = false;
         }
-      else
+      else if (!init)
         {
           bool t2 = gfc_convert_type (cons->expr, &comp->ts, 1);
           if (t)
@@ -12344,7 +12344,7 @@ resolve_fl_derived0 (gfc_symbol *sym)

       if (c->initializer && !sym->attr.vtype
       && !gfc_check_assign_symbol (sym, c, c->initializer))
-    return false;
+    continue;
     }

   check_defined_assignments (sym);



The first hunk suppresses the errors in the resolution of the symbol 'a', since
they should already be thrown in the resolution of the type.

The second hunk makes sure one gets the error in both components when resolving
the type (a similar thing is also done in PR 58023 comment 5).


With the above patch I get the expected result on the original test case in
comment 0:

Error: Can't convert TYPE(t2) to TYPE(t) at (1)
Error: Can't convert TYPE(t3) to TYPE(t) at (1)

On the version with the uncommented line, each error unfortunately still
appears twice, but that is due to the fact that the type symbol is resolved
twice (cf. also PR 44978).


  parent reply	other threads:[~2013-08-08 19:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-22 17:05 [Bug fortran/51945] New: " burnus at gcc dot gnu.org
2013-08-08 16:49 ` [Bug fortran/51945] " dominiq at lps dot ens.fr
2013-08-08 18:31 ` janus at gcc dot gnu.org
2013-08-08 18:38 ` janus at gcc dot gnu.org
2013-08-08 19:46 ` janus at gcc dot gnu.org [this message]
2013-08-08 20:56 ` janus at gcc dot gnu.org
2013-08-08 21:18 ` janus at gcc dot gnu.org
2013-08-10 11:28 ` janus at gcc dot gnu.org
2014-05-04 14:02 ` dominiq at lps dot ens.fr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-51945-4-rt7WWiAHRh@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).