public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/52024] [OOP] GENERIC operator cannot be resolved
Date: Sat, 28 Jan 2012 15:12:00 -0000	[thread overview]
Message-ID: <bug-52024-4-IGAfFU9Bdq@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-52024-4@http.gcc.gnu.org/bugzilla/>

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |burnus at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-01-28 12:38:56 UTC ---
(In reply to comment #3)
> The question is only: What does that "generic_flag" actually do?

Answer: For generic procedures which are not operators one can do:
   generic (i=4, t=x)
which matches both interfaces:
  function t_equal_i( t, i ) result(res)
  function i_equal_t( i, t ) result(res)

For operators, the "t=" syntax is not possible, the argument order is fixed
and, thus, for operators the interface is not ambiguous.

Untested patch:

Index: gfortran.h
===================================================================
--- gfortran.h  (Revision 183664)
+++ gfortran.h
@@ -1118,2 +1118,3 @@ typedef struct gfc_tbp_generic
   struct gfc_tbp_generic* next;
+  bool is_operator;
 }
Index: resolve.c
===================================================================
--- resolve.c   (Revision 183664)
+++ resolve.c
@@ -10966,2 +10995,3 @@ check_generic_tbp_ambiguity (gfc_tbp_gen
   gcc_assert (!t2->specific->is_generic);
+  gcc_assert (t1->is_operator == t2->is_operator);

@@ -10984,3 +11014,4 @@ check_generic_tbp_ambiguity (gfc_tbp_gen
   /* Compare the interfaces.  */
-  if (gfc_compare_interfaces (sym1, sym2, sym2->name, 1, 0, NULL, 0))
+  if (gfc_compare_interfaces (sym1, sym2, sym2->name, !t1->is_operator, 0,
+                             NULL, 0))
     {
Index: decl.c
===================================================================
--- decl.c      (Revision 183664)
+++ decl.c
@@ -8394,2 +8394,4 @@ gfc_match_generic (void)
       target->next = tb->u.generic;
+      target->is_operator = ((op_type == INTERFACE_USER_OP)
+                            || (op_type == INTERFACE_INTRINSIC_OP));
       tb->u.generic = target;


  parent reply	other threads:[~2012-01-28 12:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-27 22:16 [Bug fortran/52024] New: " fmartinez at gmv dot com
2012-01-27 22:25 ` [Bug fortran/52024] " fmartinez at gmv dot com
2012-01-28 10:22 ` burnus at gcc dot gnu.org
2012-01-28 10:51 ` burnus at gcc dot gnu.org
2012-01-28 15:12 ` burnus at gcc dot gnu.org [this message]
2012-01-28 21:01 ` dominiq at lps dot ens.fr
2012-01-31 19:14 ` burnus at gcc dot gnu.org
2012-01-31 19:58 ` burnus at gcc dot gnu.org
2012-01-31 21:08 ` burnus at gcc dot gnu.org
2012-02-01 19:06 ` burnus at gcc dot gnu.org
2012-02-01 19:15 ` burnus 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-52024-4-IGAfFU9Bdq@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).