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/49638] [OOP] length parameter is ignored when overriding type bound character functions with constant length.
Date: Wed, 03 Aug 2011 19:43:00 -0000	[thread overview]
Message-ID: <bug-49638-4-YoJi2Y2jNF@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-49638-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #6 from janus at gcc dot gnu.org 2011-08-03 19:41:17 UTC ---
The simple constant-length example in comment #0 can be rejected by extending
the resolve.c part of the patch in comment #3 into:


Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c    (revision 177065)
+++ gcc/fortran/resolve.c    (working copy)
@@ -10760,13 +10760,28 @@ check_typebound_override (gfc_symtree* proc, gfc_s
       /* FIXME:  Do more comprehensive checking (including, for instance, the
      rank and array-shape).  */
       gcc_assert (proc_target->result && old_target->result);
-      if (!gfc_compare_types (&proc_target->result->ts,
-                  &old_target->result->ts))
+      if (!compare_type_rank (proc_target->result, old_target->result))
     {
       gfc_error ("'%s' at %L and the overridden FUNCTION should have"
-             " matching result types", proc->name, &where);
+             " matching result types and ranks", proc->name, &where);
       return FAILURE;
     }
+    
+      if (proc_target->result->ts.type == BT_CHARACTER
+      && proc_target->result->ts.u.cl && proc_target->result->ts.u.cl->length
+      && proc_target->result->ts.u.cl->length->expr_type == EXPR_CONSTANT
+      && old_target->result->ts.u.cl && old_target->result->ts.u.cl &&
old_target->result->ts.u.cl->length
+      && old_target->result->ts.u.cl->length->expr_type == EXPR_CONSTANT
+      && (mpz_cmp (proc_target->result->ts.u.cl->length->value.integer,
+              old_target->result->ts.u.cl->length->value.integer) != 0))
+    {
+      gfc_error ("Character length mismatch (%ld/%ld) between '%s' at '%L' "
+             "and overridden FUNCTION",
+             mpz_get_si (proc_target->ts.u.cl->length->value.integer),
+             mpz_get_si (old_target->ts.u.cl->length->value.integer),
+             proc->name, &where);
+      return FAILURE;
+    }
     }

   /* If the overridden binding is PUBLIC, the overriding one must not be


  parent reply	other threads:[~2011-08-03 19:43 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-05  8:04 [Bug fortran/49638] New: " boschmann at tp1 dot physik.uni-siegen.de
2011-07-30 16:16 ` [Bug fortran/49638] " janus at gcc dot gnu.org
2011-07-30 16:24 ` janus at gcc dot gnu.org
2011-07-31 11:05 ` janus at gcc dot gnu.org
2011-08-03 18:37 ` janus at gcc dot gnu.org
2011-08-03 18:53 ` janus at gcc dot gnu.org
2011-08-03 19:43 ` janus at gcc dot gnu.org [this message]
2011-08-03 20:20 ` janus at gcc dot gnu.org
2011-08-03 21:36 ` mikael at gcc dot gnu.org
2011-08-04  7:42 ` janus at gcc dot gnu.org
2011-08-04  8:10 ` burnus at gcc dot gnu.org
2011-08-04 11:00 ` janus at gcc dot gnu.org
2011-08-04 11:15 ` mikael at gcc dot gnu.org
2011-08-04 11:17 ` mikael at gcc dot gnu.org
2011-08-04 15:19 ` kargl at gcc dot gnu.org
2011-08-04 21:17 ` janus at gcc dot gnu.org
2011-08-07 10:13 ` janus at gcc dot gnu.org
2011-08-07 10:17 ` janus at gcc dot gnu.org
2011-08-07 21:00 ` janus at gcc dot gnu.org
2011-08-07 21:13 ` janus at gcc dot gnu.org
2011-08-20 19:31 ` janus at gcc dot gnu.org
2011-08-20 19:35 ` janus at gcc dot gnu.org
2011-08-21 21:26 ` janus at gcc dot gnu.org

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-49638-4-YoJi2Y2jNF@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).