From patchwork Fri Dec 2 18:06:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janus Weil X-Patchwork-Id: 702051 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tVhtt0Bytz9vF3 for ; Sat, 3 Dec 2016 05:06:59 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="q1pcQJQT"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; q=dns; s=default; b=dLUynKixTjs4Siu xr8MpDjgI3s4LAN07mzJ8dX6gSDhPbQoxROtGFYh7dxJ2RZyVQSKL3cBaVXRQo6c Wde2sj/JWioSlAbMbypX6DzJb3JHW4y69pp/sKkenLh/lQ08WtNCxuyjxBKemUJs sol6Zjyzye8zMYhPx//8H9FTg5II= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; s=default; bh=pqniAIIA8dkbXgFrhomqR CO8XSc=; b=q1pcQJQTgyaQ5ve/lvVugy6EEUcGNLoKdUB4tQY6L/0ffsDtI6eQm DHZV9Sx4T8caDTtRa2Fb9DdqDuYw6R4nQusFmPwnIJ2BT/WStfs/SmhGSgsJa9Wu 3kHCDtMY1+BerYz/h2boV1sUjeacVu9CrSeFpmWq1bZnFpkF9j0Mew= Received: (qmail 49463 invoked by alias); 2 Dec 2016 18:06:46 -0000 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 Received: (qmail 49400 invoked by uid 89); 2 Dec 2016 18:06:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=HTo:D*washington.edu X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-yb0-f195.google.com Received: from mail-yb0-f195.google.com (HELO mail-yb0-f195.google.com) (209.85.213.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 02 Dec 2016 18:06:35 +0000 Received: by mail-yb0-f195.google.com with SMTP id v78so5350549ybe.0; Fri, 02 Dec 2016 10:06:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=R07QTu53QuLdrIs3DlyrXhRyscgCtGE6zoGDKKe/Psw=; b=HM6Zfz18tQ62K7ZUQ+PtIoKtZrb+7BqOd5wpPJ4I2MEtE/YtVWLbDw014ycJiQ1t0F pivDf6vkF9Lduz0iy7lP6mmUwCuOOZrBNuXBC77UGYPYbHAwqWU69d4YW8SmlDNiW39A p+wBVHQN+PnjC05+54R7GlQrH01AY5kKL4P4JXbg/gSCoV2cErpp+xnm8m4fdK63xIT3 zyeAPChHkOOfLkdxW/SjlagdurKphHrAnglK1OGqdRcAVfThHWd1jGRzC0YzT0OOWR+W Oo8uIqQ++9Dls20LHMsaONUtJcySVHBGeH1VHZleMXcnZlQGX8FoyWP50fVSOJVYJdaQ a22g== X-Gm-Message-State: AKaTC020vqxpszMUGY+ynHFDkoanN+M4UM/TrJHJRd+JC764p51JR0cW7sKkqClR2fiTKdL0Qa/iBkfK4Bbk3w== X-Received: by 10.37.105.141 with SMTP id e135mr3936804ybc.179.1480701993568; Fri, 02 Dec 2016 10:06:33 -0800 (PST) MIME-Version: 1.0 Received: by 10.129.51.145 with HTTP; Fri, 2 Dec 2016 10:06:33 -0800 (PST) In-Reply-To: <20161202171337.GA46326@troutmask.apl.washington.edu> References: <20161202013354.GA42106@troutmask.apl.washington.edu> <20161202163014.GA46189@troutmask.apl.washington.edu> <20161202171337.GA46326@troutmask.apl.washington.edu> From: Janus Weil Date: Fri, 2 Dec 2016 19:06:33 +0100 Message-ID: Subject: Re: [PATCH] PR fortran/78618 -- RANK() should not ICE To: Steve Kargl Cc: kargl@uw.edu, gfortran , gcc-patches 2016-12-02 18:13 GMT+01:00 Steve Kargl : >> >> > The attached patch fixes an ICE, a nearby whitespace issue, and >> >> > removed the ATTRIBUTE_UNUSED tag. THe change has passed regression >> >> > testing on x86_64-*-freebsd. Ok to commit? >> >> >> >> huh, I don't really understand why the argument of RANK is detected to >> >> be an EXPR_FUNCTION for the test case at hand. Shouldn't it rather be >> >> an EXPR_CONSTANT? >> >> >> >> Some debugging in gfc_check_rank shows that a->symtree->n.sym indeed >> >> is the symbol "c" (as expected), but that clearly is not a function, >> >> so it seems to me that the actual bug here is that a->expr_type is set >> >> incorrectly ...? >> > >> > I found that it is the function __convert_s4_s1. >> >> That's strange. If we see different things here, maybe we are running >> into some kind of undefined behavior (possibly related to >> gfc_bad_expr?). Anyway, after some more debugging I came to the >> conclusion that what actually fails is the error propagation, which >> seems to be broken in gfc_check_assign and can be fixed like this: >> >> >> Index: gcc/fortran/expr.c >> =================================================================== >> --- gcc/fortran/expr.c (revision 243194) >> +++ gcc/fortran/expr.c (working copy) >> @@ -3314,9 +3314,9 @@ gfc_check_assign (gfc_expr *lvalue, gfc_expr *rval >> if (lvalue->ts.type == BT_CHARACTER && rvalue->ts.type == BT_CHARACTER) >> { >> if (lvalue->ts.kind != rvalue->ts.kind && allow_convert) >> - gfc_convert_chartype (rvalue, &lvalue->ts); >> - >> - return true; >> + return gfc_convert_chartype (rvalue, &lvalue->ts); >> + else >> + return true; >> } >> >> if (!allow_convert) >> >> >> This also avoids the ICE and I think is the proper way to fix this ... >> > > When developing the patch, I fixed/avoided the ICE, first. Then, > I tried Gerhard's second testcase without the PARAMETER attribute. > An error message is emitted, so I went hunting for why PARAMETER > suppressed the error message. This led to the second part of the > patch of changing gfc_error to gfc_error_now. I think the gfc_error_now should not be necessary with my fix, but removing the ATTRIBUTE_UNUSED is certainly a good idea. > In any event, if your patch causes an error message to be emitted, > then I think that your patch is better than the one I proposed. > Feel free to commit your patch. I am now regtesting the attached version and, if successful, will commit. Cheers, Janus Index: gcc/fortran/check.c =================================================================== --- gcc/fortran/check.c (revision 243194) +++ gcc/fortran/check.c (working copy) @@ -3667,7 +3667,7 @@ gfc_check_range (gfc_expr *x) bool -gfc_check_rank (gfc_expr *a ATTRIBUTE_UNUSED) +gfc_check_rank (gfc_expr *a) { /* Any data object is allowed; a "data object" is a "constant (4.1.3), variable (6), or subobject of a constant (2.4.3.2.3)" (F2008, 1.3.45). */ Index: gcc/fortran/expr.c =================================================================== --- gcc/fortran/expr.c (revision 243194) +++ gcc/fortran/expr.c (working copy) @@ -3314,9 +3314,9 @@ gfc_check_assign (gfc_expr *lvalue, gfc_expr *rval if (lvalue->ts.type == BT_CHARACTER && rvalue->ts.type == BT_CHARACTER) { if (lvalue->ts.kind != rvalue->ts.kind && allow_convert) - gfc_convert_chartype (rvalue, &lvalue->ts); - - return true; + return gfc_convert_chartype (rvalue, &lvalue->ts); + else + return true; } if (!allow_convert)