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



janus at gcc dot gnu.org changed:



           What    |Removed                     |Added

----------------------------------------------------------------------------

             Status|UNCONFIRMED                 |NEW

   Last reconfirmed|                            |2013-01-19

     Ever Confirmed|0                           |1



--- Comment #4 from janus at gcc dot gnu.org 2013-01-19 15:14:31 UTC ---

(In reply to comment #2)

> Yet another variant:

> [...]

>

> gives me (four times!):

> 

>       real, dimension(this%getdims()) :: getx

>                       1

> Error: Function 'this' at (1) must be PURE

> 

> 

> which is of course bogus, since 'this' is not even a function, and getdims is

> actually pure.



The wording of the error message can be fixed by this patch:





Index: gcc/fortran/expr.c

===================================================================

--- gcc/fortran/expr.c    (revision 195310)

+++ gcc/fortran/expr.c    (working copy)

@@ -2962,18 +2962,24 @@ gfc_specification_expr (gfc_expr *e)

       return FAILURE;

     }



-  comp = gfc_get_proc_ptr_comp (e);

-  if (e->expr_type == EXPR_FUNCTION

-      && !e->value.function.isym

-      && !e->value.function.esym

-      && !gfc_pure (e->symtree->n.sym)

-      && (!comp || !comp->attr.pure))

+  if (e->expr_type == EXPR_FUNCTION)

     {

-      gfc_error ("Function '%s' at %L must be PURE",

-         e->symtree->n.sym->name, &e->where);

-      /* Prevent repeat error messages.  */

-      e->symtree->n.sym->attr.pure = 1;

-      return FAILURE;

+      comp = gfc_get_proc_ptr_comp (e);

+      if (comp && !comp->attr.pure)

+    {

+      gfc_error ("Procedure pointer component '%s' at %L must be PURE",

+             comp->name, &e->where);

+      return FAILURE;

+    }

+      else if (!comp && !e->value.function.isym && !e->value.function.esym

+           && !gfc_pure (e->symtree->n.sym))

+    {

+      gfc_error ("Function '%s' at %L must be PURE",

+             e->symtree->n.sym->name, &e->where);

+      /* Prevent repeat error messages.  */

+      e->symtree->n.sym->attr.pure = 1;

+      return FAILURE;

+    }

     }



   if (e->rank != 0)







With this ones gets:



      real, dimension(this%getdims()) :: getx

                      1

Error: Procedure pointer component 'getdims' at (1) must be PURE





This still leaves us with some problems:

1) That we get the error at all. The interface of getdims is clearly PURE, but

it seems that its resolution happens too late, so that the attributes have not

yet been copied from the interface when the pureness check is done.

2) getdims is identified as a PPC in the error message, though it is a

type-bound procedure. The reason for this is that internally "this%getdims()"

is resolved to "this->_vptr->getdims" (where getdims is a PPC of _vptr).

3) The error message still comes four times (not sure why).

Reply via email to