re PR fortran/45933 ([OOP] ICE in gfc_add_component_ref, at fortran/class.c:77)
authorJanus Weil <janus@gcc.gnu.org>
Thu, 7 Oct 2010 17:35:18 +0000 (19:35 +0200)
committerJanus Weil <janus@gcc.gnu.org>
Thu, 7 Oct 2010 17:35:18 +0000 (19:35 +0200)
2010-10-07  Janus Weil  <janus@gcc.gnu.org>

PR fortran/45933
* resolve.c (resolve_typebound_function): Use correct declared type
for type-bound operators.

2010-10-07  Janus Weil  <janus@gcc.gnu.org>

PR fortran/45933
* gfortran.dg/typebound_operator_5.f03: New.

From-SVN: r165126

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/typebound_operator_5.f03 [new file with mode: 0644]

index 18e4dd9..641807f 100644 (file)
@@ -1,3 +1,9 @@
+2010-10-07  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/45933
+       * resolve.c (resolve_typebound_function): Use correct declared type
+       for type-bound operators.
+
 2010-10-07  Mikael Morin  <mikael@gcc.gnu.org>
 
        PR fortran/45916
index 526e6df..a5aa62a 100644 (file)
@@ -5719,13 +5719,12 @@ resolve_typebound_function (gfc_expr* e)
 
   /* Deal with typebound operators for CLASS objects.  */
   expr = e->value.compcall.base_object;
-  if (expr && expr->symtree->n.sym->ts.type == BT_CLASS
-       && e->value.compcall.name)
+  if (expr && expr->ts.type == BT_CLASS && e->value.compcall.name)
     {
       /* Since the typebound operators are generic, we have to ensure
         that any delays in resolution are corrected and that the vtab
         is present.  */
-      ts = expr->symtree->n.sym->ts;
+      ts = expr->ts;
       declared = ts.u.derived;
       c = gfc_find_component (declared, "$vptr", true, true);
       if (c->ts.u.derived == NULL)
index c8f841e..b68689c 100644 (file)
@@ -1,3 +1,8 @@
+2010-10-07  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/45933
+       * gfortran.dg/typebound_operator_5.f03: New.
+
 2010-10-07  Nicola Pero  <nicola.pero@meta-innovation.com>
 
        Merge from 'apple/trunk' branch on FSF servers.
diff --git a/gcc/testsuite/gfortran.dg/typebound_operator_5.f03 b/gcc/testsuite/gfortran.dg/typebound_operator_5.f03
new file mode 100644 (file)
index 0000000..440c1b5
--- /dev/null
@@ -0,0 +1,30 @@
+! { dg-do compile }
+!
+! PR 45933: [4.6 regression] [OOP] ICE in gfc_add_component_ref, at fortran/class.c:77
+!
+! Contributed by Mark Rashid <mmrashid@ucdavis.edu>
+
+MODULE DEF1
+  TYPE :: DAT
+    INTEGER :: NN
+  CONTAINS
+    PROCEDURE :: LESS_THAN
+    GENERIC :: OPERATOR (.LT.) => LESS_THAN
+  END TYPE
+CONTAINS
+  LOGICAL FUNCTION LESS_THAN(A, B)
+    CLASS (DAT), INTENT (IN) :: A, B
+    LESS_THAN = (A%NN .LT. B%NN)
+  END FUNCTION
+END MODULE
+
+PROGRAM P
+  USE DEF1
+  TYPE NODE
+    TYPE (DAT), POINTER :: PT
+  END TYPE
+  CLASS (NODE),POINTER :: A, B
+  PRINT *, A%PT .LT. B%PT
+END
+
+! { dg-final { cleanup-modules "DEF1" } }