From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25635 invoked by alias); 25 Feb 2010 13:40:46 -0000 Received: (qmail 25393 invoked by uid 48); 25 Feb 2010 13:40:16 -0000 Date: Thu, 25 Feb 2010 13:40:00 -0000 Message-ID: <20100225134016.25392.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug fortran/43169] [OOP] gfortran rejects pure procedure with select type construct In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "janus at gcc dot gnu dot org" 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: 2010-02/txt/msg02568.txt.bz2 ------- Comment #7 from janus at gcc dot gnu dot org 2010-02-25 13:40 ------- (In reply to comment #5) > (In reply to comment #3) > > Seems like statements inside a BLOCK are not being resolved at all?!? > > Sorry, this is wrong. They are resolved alright. The problem is just that > 'gfc_pure' does not work (checking if we're inside a pure function). The BLOCK issue in comment #3 is fixed by the following patch: Index: gcc/fortran/resolve.c =================================================================== --- gcc/fortran/resolve.c (revision 157055) +++ gcc/fortran/resolve.c (working copy) @@ -11689,18 +11695,30 @@ gfc_impure_variable (gfc_symbol *sym) } -/* Test whether a symbol is pure or not. For a NULL pointer, checks the - symbol of the current procedure. */ +/* Test whether a symbol is pure or not. For a NULL pointer, checks if the + current namespace is inside a pure procedure. */ int gfc_pure (gfc_symbol *sym) { symbol_attribute attr; + gfc_namespace *ns; if (sym == NULL) - sym = gfc_current_ns->proc_name; - if (sym == NULL) - return 0; + { + /* Check if the current namespace or one of its parents + belongs to a pure procedure. */ + for (ns = gfc_current_ns; ns; ns = ns->parent) + { + sym = ns->proc_name; + if (sym == NULL) + return 0; + attr = sym->attr; + if (attr.flavor == FL_PROCEDURE && (attr.pure || attr.elemental)) + return 1; + } + return 0; + } attr = sym->attr; -- janus at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|unassigned at gcc dot gnu |janus at gcc dot gnu dot org |dot org | Status|NEW |ASSIGNED Last reconfirmed|2010-02-25 08:38:03 |2010-02-25 13:40:15 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43169