From patchwork Sun Dec 15 18:41:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Richard Thomas X-Patchwork-Id: 1209995 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-516004-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="GqERC59T"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="rqiqpBKF"; dkim-atps=neutral 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 47bYDD4rKqz9sPK for ; Mon, 16 Dec 2019 05:42:18 +1100 (AEDT) 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:from:date:message-id:subject:to:content-type; q= dns; s=default; b=ZB1PjlJUP8tnzFNUG7UFBWRzcbTjCb8rnWoug/O5IXwUKP HGGaqAu53s7L/IBCq908Fr6JYTiqdZLZn2dKr4CPEDxfNtPpYQgOJGZbNzJOZcJu v1wwzVyOe5p0t6SCwMycR/2PYsDvRZleGd+OVLf1XTeHDwvc9WLlrGOK5xgmQ= 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:from:date:message-id:subject:to:content-type; s= default; bh=ulGwQ26Jg115CBuqD8nJnNbviwM=; b=GqERC59TruZmEzIVLrVO Xp3R/WwCZwd9uJcUrTonIcHAZBKYspmuO5lrBspohdNRCvbppAXXfdct/Adncbm/ efc6l2Ap/a85VyBPYJ1ZgVaT7e+NxPoNbHYKNQNg4dBDE3Ea/j0GiDcgnkEnLENs aI6iNORzVk+Y7oKyxTc0h/E= Received: (qmail 4509 invoked by alias); 15 Dec 2019 18:42:06 -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 4489 invoked by uid 89); 15 Dec 2019 18:42:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-3.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, KAM_ASCII_DIVIDERS, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=sk:inquiry X-HELO: mail-lf1-f50.google.com Received: from mail-lf1-f50.google.com (HELO mail-lf1-f50.google.com) (209.85.167.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 15 Dec 2019 18:42:04 +0000 Received: by mail-lf1-f50.google.com with SMTP id r14so2652550lfm.5; Sun, 15 Dec 2019 10:42:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=GaETMk8QDmRhqRlb338zJbCBcAxrTrs+8e4rSlwzdJM=; b=rqiqpBKFFjWidxmVb4Th9HjrHra+c/1a78I/r2G0rYymVC8j5TZfNpvyF7Ye7XzMeF MOdYiQh4RSTlreNqCsBMQzfral/TB5FcNnZUVpOabBbLmS7KcJZnEnhCOUz7WvAW2QmL ka+ibeoWKc8N3Xu3ArczqOA03kjpvte/i9RpoFl0yHhPtMoGjPXAQOEfZ6YWFYOl7GNY cN+q1J+pJWPdHXHAPfmAmoa1Dib7jFQtgYnmTnBfXGRnvLTJhhwiXF3aYPOX76L2au6J kS1u7jABdQJDjnaha7oX+f5l4MpPr0cCBkzs90kOJ8/jE91ICmC5Y0T2ELP+iMvuOyFL H7SQ== MIME-Version: 1.0 From: Paul Richard Thomas Date: Sun, 15 Dec 2019 18:41:50 +0000 Message-ID: Subject: [Patch, fortran] PR92753 - [9/10 Regression] ICE in gfc_trans_call, at fortran/trans-stmt.c:392 To: "fortran@gcc.gnu.org" , gcc-patches This patch is straight forward and well explained by the ChangeLogs. The ICE comes about because the simplification of the inquiry_part_ref expressions produced bad expressions. Thanks to Steve for spotting the error in the INQUIRY_RE and INQUIRY_IM parts that was so blindingly obvious that I couldn't see it. This was not in the PR but was detected while fixing it. Regtested on FC31/x86_64 - OK for 9- and 10- branches? Cheers Paul 2019-12-15 Paul Thomas PR fortran/92753 * expr.c (find_inquiry_ref): Catch INQUIRY_LEN case, where the temporary expression has been converted to a constant and make the new expression accordingly. Correct the error in INQUIRY_RE and INQUIRY_IM cases. The original rather than the resolved expression was being used as the source in mpfr_set. 2019-12-15 Paul Thomas PR fortran/92753 * gfortran.dg/inquiry_type_ref_5.f90 : New test. Index: gcc/fortran/expr.c =================================================================== *** gcc/fortran/expr.c (revision 278354) --- gcc/fortran/expr.c (working copy) *************** find_inquiry_ref (gfc_expr *p, gfc_expr *** 1787,1797 **** if (!gfc_notify_std (GFC_STD_F2003, "LEN part_ref at %C")) goto cleanup; ! if (!tmp->ts.u.cl->length ! || tmp->ts.u.cl->length->expr_type != EXPR_CONSTANT) goto cleanup; - *newp = gfc_copy_expr (tmp->ts.u.cl->length); break; case INQUIRY_KIND: --- 1787,1801 ---- if (!gfc_notify_std (GFC_STD_F2003, "LEN part_ref at %C")) goto cleanup; ! if (tmp->ts.u.cl->length ! && tmp->ts.u.cl->length->expr_type == EXPR_CONSTANT) ! *newp = gfc_copy_expr (tmp->ts.u.cl->length); ! else if (tmp->expr_type == EXPR_CONSTANT) ! *newp = gfc_get_int_expr (gfc_default_integer_kind, ! NULL, tmp->value.character.length); ! else goto cleanup; break; case INQUIRY_KIND: *************** find_inquiry_ref (gfc_expr *p, gfc_expr *** 1814,1820 **** *newp = gfc_get_constant_expr (BT_REAL, tmp->ts.kind, &tmp->where); mpfr_set ((*newp)->value.real, ! mpc_realref (p->value.complex), GFC_RND_MODE); break; case INQUIRY_IM: --- 1818,1824 ---- *newp = gfc_get_constant_expr (BT_REAL, tmp->ts.kind, &tmp->where); mpfr_set ((*newp)->value.real, ! mpc_realref (tmp->value.complex), GFC_RND_MODE); break; case INQUIRY_IM: *************** find_inquiry_ref (gfc_expr *p, gfc_expr *** 1826,1832 **** *newp = gfc_get_constant_expr (BT_REAL, tmp->ts.kind, &tmp->where); mpfr_set ((*newp)->value.real, ! mpc_imagref (p->value.complex), GFC_RND_MODE); break; } tmp = gfc_copy_expr (*newp); --- 1830,1836 ---- *newp = gfc_get_constant_expr (BT_REAL, tmp->ts.kind, &tmp->where); mpfr_set ((*newp)->value.real, ! mpc_imagref (tmp->value.complex), GFC_RND_MODE); break; } tmp = gfc_copy_expr (*newp); Index: gcc/testsuite/gfortran.dg/inquiry_type_ref_5.f90 =================================================================== *** gcc/testsuite/gfortran.dg/inquiry_type_ref_5.f90 (nonexistent) --- gcc/testsuite/gfortran.dg/inquiry_type_ref_5.f90 (working copy) *************** *** 0 **** --- 1,29 ---- + ! { dg-do run } + ! + ! Test the fix for pr92753 + ! + ! Contributed by Gerhardt Steinmetz + ! + module m + type t + character(3) :: c + end type + type u + complex :: z + end type + type(t), parameter :: x = t ('abc') + integer, parameter :: l = x%c%len ! Used to ICE + + type(u), parameter :: z = u ((42.0,-42.0)) + end + program p + use m + call s (x%c%len) ! ditto + + if (int (z%z%re) .ne. 42) stop 1 ! Produced wrong code and + if (int (z%z%re) .ne. -int (z%z%im)) stop 2 ! runtime seg fault + contains + subroutine s(n) + if (n .ne. l) stop 3 + end + end