From patchwork Sat Oct 6 17:53:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 979982 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-487069-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=netcologne.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ZC8SEVWw"; dkim=pass (2048-bit key; unprotected) header.d=netcologne.de header.i=@netcologne.de header.b="PQ18TNXD"; 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 42SDkV6cspz9s8T for ; Sun, 7 Oct 2018 04:53:21 +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:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=KeSEcY2pIP7BCGY23TsYCviU+LckqcsimUaLiGM/TOufBuVaQJ 1zsAdD01838Ue7rnQRyNXNu5UqfOnQZJtNXgsERwXgf68RkR8Cdrsrhjofd+iDjG a485z0mTVZ5FIZjPyV0stlCGoMIcgUj0YerTz/nZeLZShuv8WA0S/Ho2g= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=AM6Tzzs+Vap+dAR7dcG6dqR8ukk=; b=ZC8SEVWw/vOhSBBJwP+G 1++kWHyRV6HIOB1DIPRfcD455OOOYGcCUAdM4UQPOwZbL8ZF1kxr5GgjKpyudVf0 DrBesfV0mD7QXKB1jGbukA8iN5ck5qQ0Ft29J2TZx/oAMITW3NAM1PFje/gfmh19 Wic9rkAS/yNkDgmIYjhzamY= Received: (qmail 117705 invoked by alias); 6 Oct 2018 17:53:09 -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 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, 6 Oct 2018 19:53:03 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 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. 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. */