From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 117704 invoked by alias); 6 Oct 2018 17:53:09 -0000 Mailing-List: contact fortran-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: fortran-owner@gcc.gnu.org Received: (qmail 117682 invoked by uid 89); 6 Oct 2018 17:53:09 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: cc-smtpout1.netcologne.de Received: from cc-smtpout1.netcologne.de (HELO cc-smtpout1.netcologne.de) (89.1.8.211) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 06 Oct 2018 17:53:07 +0000 Received: from cc-smtpin2.netcologne.de (cc-smtpin2.netcologne.de [89.1.8.202]) by cc-smtpout1.netcologne.de (Postfix) with ESMTP id CBC211320C; Sat, 6 Oct 2018 19:53:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=netcologne.de; s=nc1116a; t=1538848384; bh=7xKmwSLzLOtPAqmSdWNMlK3U1dwILgjXIh+oC9sh0Wc=; h=To:From:Subject:Message-ID:Date:From; b=PQ18TNXDv/p0Chx6E8b0UXYgjaUofo/Zj6zhgpEutWYZv4rIuTAp1JAVtxcCfTfZ5 YCtvjec0p0iZpg2a8qBnPn4bQZ/zM/Pb11/fsWC6J4T6YEUWEw56f78du+kbjtolJy sHpKWviwgaZNVd/Xrtkba8t9dwp83Zg7sDowe8eMvNqPQeY7ffbCDNeggyTmBI0shv 677cpqM1s/xn3jO3Wx1SpRh7hPJhxFMX/sOOC4wxaSFuTl5Kv7S0ywB7QS9eFQUg0A p36adbXaxO74T/+XJwy5nc8R0CI/QohlDeGx4+YQWBZbNXvjrjDLedxooIBcRKAdEq QE2cZnRvCgbhg== Received: from localhost (localhost [127.0.0.1]) by cc-smtpin2.netcologne.de (Postfix) with ESMTP id BDDE011EAA; Sat, 6 Oct 2018 19:53:04 +0200 (CEST) Received: from [78.35.136.172] (helo=cc-smtpin2.netcologne.de) by localhost with ESMTP (eXpurgate 4.6.0) (envelope-from ) id 5bb8f680-01b0-7f0000012729-7f000001eb56-1 for ; Sat, 06 Oct 2018 19:53:04 +0200 Received: from [192.168.178.68] (xdsl-78-35-136-172.netcologne.de [78.35.136.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by cc-smtpin2.netcologne.de (Postfix) with ESMTPSA; Sat, 6 Oct 2018 19:53:03 +0200 (CEST) To: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Subject: [patch, fortran] Fix PR 86111, ICE on invalid Message-ID: <5dc538d0-870d-0596-fa34-f2d71fdeeda1@netcologne.de> Date: Sat, 06 Oct 2018 17:53:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------1430B2363604359B639BE908" X-SW-Source: 2018-10/txt/msg00027.txt.bz2 This is a multi-part message in MIME format. --------------1430B2363604359B639BE908 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 715 Hello world, the attached patch fixes an ICE regression by issuing an error when a clever combination of array constructors ends up in gfc_arith_concat with mismatched types, before resultion has a chance to report the error. Regression-tested. OK for trunk? Regards Thomas 2018-10-06 Thomas Koenig PR fortran/86111 * gfortran.h (enum arith): Add ARITH_WRONGCONCAT. * arith.h (gfc_arith_error): Issue error for ARITH_WRONGCONCAT. (gfc_arith_concat): If the types of op1 and op2 are not character of if their kinds do not match, issue ARITH_WRONGCONCAT. 2018-10-06 Thomas Koenig PR fortran/86111 * gfortran.dg/array_constructor_type_23.f90: New test. --------------1430B2363604359B639BE908 Content-Type: text/x-patch; name="p1.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="p1.diff" Content-length: 1455 Index: arith.c =================================================================== --- arith.c (Revision 264897) +++ arith.c (Arbeitskopie) @@ -113,6 +113,11 @@ gfc_arith_error (arith code) p = _("Integer outside symmetric range implied by Standard Fortran at %L"); break; + case ARITH_WRONGCONCAT: + p = + _("Illegal type in character concatenation at %L"); + break; + default: gfc_internal_error ("gfc_arith_error(): Bad error code"); } @@ -982,7 +987,12 @@ gfc_arith_concat (gfc_expr *op1, gfc_expr *op2, gf gfc_expr *result; size_t len; - gcc_assert (op1->ts.kind == op2->ts.kind); + /* By cleverly playing around with constructors, is is possible + to get mismaching types here. */ + if (op1->ts.type != BT_CHARACTER || op2->ts.type != BT_CHARACTER + || op1->ts.kind != op2->ts.kind) + return ARITH_WRONGCONCAT; + result = gfc_get_constant_expr (BT_CHARACTER, op1->ts.kind, &op1->where); Index: gfortran.h =================================================================== --- gfortran.h (Revision 264897) +++ gfortran.h (Arbeitskopie) @@ -191,7 +191,8 @@ enum gfc_intrinsic_op /* Arithmetic results. */ enum arith { ARITH_OK = 1, ARITH_OVERFLOW, ARITH_UNDERFLOW, ARITH_NAN, - ARITH_DIV0, ARITH_INCOMMENSURATE, ARITH_ASYMMETRIC, ARITH_PROHIBIT + ARITH_DIV0, ARITH_INCOMMENSURATE, ARITH_ASYMMETRIC, ARITH_PROHIBIT, + ARITH_WRONGCONCAT }; /* Statements. */ --------------1430B2363604359B639BE908 Content-Type: text/x-fortran; name="array_constructor_type_23.f90" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="array_constructor_type_23.f90" Content-length: 217 ! { dg-do compile } ! PR 83999 - this used to ICE ! Origial test case by Gerhard Steinmetz program p character(2) :: c = 'a' // [character :: [1]] ! { dg-error "Illegal type in character concatenation" } end --------------1430B2363604359B639BE908--