From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5251 invoked by alias); 19 Jan 2013 15:14:58 -0000 Received: (qmail 4536 invoked by uid 48); 19 Jan 2013 15:14:34 -0000 From: "janus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/55960] [OOP] ICE in replace_comp, at fortran/expr.c:4356 Date: Sat, 19 Jan 2013 15:14:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: janus at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Status Last reconfirmed Ever Confirmed Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2013-01/txt/msg01830.txt.bz2 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).