From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23590 invoked by alias); 6 Jan 2012 11:07:59 -0000 Received: (qmail 23579 invoked by uid 22791); 6 Jan 2012 11:07:58 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 06 Jan 2012 11:07:45 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/50981] [4.4/4.5/4.6 Regression] Wrong-code for scalarizing ELEMENTAL call with absent OPTIONAL argument Date: Fri, 06 Jan 2012 11:07: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: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: mikael at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.4.7 X-Bugzilla-Changed-Fields: 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: 2012-01/txt/msg00629.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50981 --- Comment #12 from Tobias Burnus 2012-01-06 11:06:59 UTC --- Draft patch. (It uses gfc_expr_attr to allow for pointer/allocatable components. I also tried to take BT_CLASS into account.) (This patch is a side effect of unsuccessful debugging of the related PR 51758.) --- trans-array.c (revision 182944) +++ trans-array.c (working copy) @@ -8362,9 +8384,17 @@ gfc_walk_elemental_function_args (gfc_ss * ss, gfc if (dummy_arg != NULL && dummy_arg->sym->attr.optional - && arg->expr->symtree - && arg->expr->symtree->n.sym->attr.optional - && arg->expr->ref == NULL) + && arg->expr->expr_type == EXPR_VARIABLE + && ((arg->expr->symtree->n.sym->attr.optional + && arg->expr->ref == NULL) + || ((gfc_expr_attr (arg->expr).allocatable + || gfc_expr_attr (arg->expr).pointer) + && ((dummy_arg->sym->ts.type != BT_CLASS + && !dummy_arg->sym->attr.allocatable + && !dummy_arg->sym->attr.pointer) + || (dummy_arg->sym->ts.type == BT_CLASS + && !CLASS_DATA (dummy_arg->sym)->attr.allocatable + && !CLASS_DATA (dummy_arg->sym)->attr.pointer))))) newss->info->data.scalar.can_be_null_ref = true; } else