From patchwork Sun Jul 4 09:46:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 57834 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 17DB6B6F04 for ; Sun, 4 Jul 2010 19:47:06 +1000 (EST) Received: (qmail 14469 invoked by alias); 4 Jul 2010 09:47:03 -0000 Received: (qmail 14454 invoked by uid 22791); 4 Jul 2010 09:47:02 -0000 X-SWARE-Spam-Status: No, hits=0.3 required=5.0 tests=AWL, BAYES_50, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp5.netcologne.de (HELO smtp5.netcologne.de) (194.8.194.25) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 04 Jul 2010 09:46:56 +0000 Received: from [192.168.0.197] (xdsl-213-168-110-26.netcologne.de [213.168.110.26]) by smtp5.netcologne.de (Postfix) with ESMTP id 14F4840CF0A; Sun, 4 Jul 2010 11:46:54 +0200 (CEST) Subject: [patch, fortran] Fix PR 44693 From: Thomas Koenig To: fortran@gcc.gnu.org Cc: gcc-patches@gcc.gnu.org Date: Sun, 04 Jul 2010 11:46:53 +0200 Message-ID: <1278236813.4645.7.camel@linux-fd1f.site> Mime-Version: 1.0 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hello world, the attached patch fixes PR 44693. During regression-testing, there was a failure of dynamic_dispatch_6.f03 at higher optimization levels. I *think* that this is not related to this patch, but I would appreciate if the reviewer would check for that. Of course, if this turns out to really cause a regression or expose a latent bug, I don't want to commit this. OK for trunk? Thomas 2010-07-04 Thomas Koenig PR fortran/PR44693 * check.c (dim_rank_check): Also check intrinsic functions. Adjust permissible rank for functions which reduce the rank of their argument. PR fortran/PR44693 * dim_range_1.f90: New test. Index: check.c =================================================================== --- check.c (Revision 161784) +++ check.c (Arbeitskopie) @@ -473,12 +473,34 @@ dim_rank_check (gfc_expr *dim, gfc_expr *array, in if (dim == NULL) return SUCCESS; - if (dim->expr_type != EXPR_CONSTANT - || (array->expr_type != EXPR_VARIABLE - && array->expr_type != EXPR_ARRAY)) + if (dim->expr_type != EXPR_CONSTANT) return SUCCESS; - rank = array->rank; + if (array->expr_type == EXPR_FUNCTION && array->value.function.isym) + { + + /* Functions which reduce the rank of their arguments. */ + switch(array->value.function.isym->id) + { + case GFC_ISYM_SUM: + case GFC_ISYM_PRODUCT: + case GFC_ISYM_ANY: + case GFC_ISYM_ALL: + case GFC_ISYM_COUNT: + case GFC_ISYM_MINVAL: + case GFC_ISYM_MAXVAL: + rank = array->rank + 1; + break; + + default: + rank = array->rank; + } + } + else + { + rank = array->rank; + } + if (array->expr_type == EXPR_VARIABLE) { ar = gfc_find_array_ref (array);