From patchwork Fri Sep 13 10:07:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 1161944 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-508982-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=hotmail.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="katlzt7i"; 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 46VBC00fhRz9sNF for ; Fri, 13 Sep 2019 20:07:21 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:content-type:mime-version; q=dns; s=default; b=v94QKJpAQhSXDj9CltSx3NY7DKXVOjs3wLNl0JREn7EgfmzH/2 6puFsl4WFlLloTb6JxXF/kOCl8FtrFuxL9ozQivFLmRgN+zPY4FyX3b3s0CSNeEJ oHfyAvNsW1FfHnyRbIGWiEUSwWagHhq77JnhpcVncNPpnNv1ZrL0lBwKc= 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:from :to:cc:subject:date:message-id:content-type:mime-version; s= default; bh=jkRqx7sqk0DwHzGCnshZfBYL2O8=; b=katlzt7isk8K3nZRBsdA JoZym7fvwboy+QoOq/UkDBV8bDXPHV5fRwbYLelQyqdmxUbyiYGQTCR9z8cTNbpk 68IopLXJiI/X6nudfo5pRHd6cEWgWhPAcPgNaHIyCqvd7qEld4XAGob0sa7MkM4v VO7XEtIQY3C8dn+L3d54FII= Received: (qmail 50514 invoked by alias); 13 Sep 2019 10:07:11 -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 50499 invoked by uid 89); 13 Sep 2019 10:07:10 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.2 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy=Gerhard, Steinmetz, H*MI:COM, gerhard X-HELO: EUR02-VE1-obe.outbound.protection.outlook.com Received: from mail-oln040092069020.outbound.protection.outlook.com (HELO EUR02-VE1-obe.outbound.protection.outlook.com) (40.92.69.20) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 13 Sep 2019 10:07:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gu11wgcVao0hLVaTFrlBJDYmZ8wv/QFg3ZW4my3g3i77ioZ5QR83PAxxy5mZPwux6h+KZ34xb+dE7SPuky/lIn/UTXnRDtLOUr2jL+z+UewjBSTFBctiVZstHF7IkL1wbGv3mfIzzicawWYRf5rnaBqIVYBKdRdTWW62yHmyoiOiIhTx7f7P9+ie63ymc/SehoSWm5gCmmPuBl2k6JBxsVh1lMPIysnZXvaKEK19TE260Rqu9gwEj73zJGCxcTsK0/enoFPLUPIWyZa5kfnN5G0WTIuzhtM2OFgREbphglrtXDUMedDsF0nJiK6z2HmLSVldlPHL+xLvoYeJIbiWfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=v7v/SwKUUeZQmqxNVHxDbjS19VqUvc8fDuhz8Z4MGBU=; b=SK77otGWsuCnnKL6B3to2wdrEnx8TfXoV7H7V+z7FzRciKikmsRUo14K4KChWX7lLW/ABUfxPaFieTtZMMQQrFIto7WyF0uA4H9ptjKAi2B6weWnMt5prS6RkQCqj9Odwb6NySfEVxjhPEriFHrKlmlvkw6bx5es3q4sqVoCve2cEE5pXsL9qT+eOmQ+CYoQxJWAkRNEnXWpZQyzveTPhTqyPaZmhjULvmdfKytuavl9KkxhKvbKbd/dEqtQEcrSakRUzun2TDigIDLEgoePg1qdoQFGkZGsssPtRdNLRrFXdA8VlolAD3TLf6YuKchMRw4Urtw7ecok5fmAlhB8DQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from AM5EUR02FT057.eop-EUR02.prod.protection.outlook.com (10.152.8.60) by AM5EUR02HT101.eop-EUR02.prod.protection.outlook.com (10.152.9.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2241.14; Fri, 13 Sep 2019 10:07:05 +0000 Received: from AM6PR10MB2566.EURPRD10.PROD.OUTLOOK.COM (10.152.8.60) by AM5EUR02FT057.mail.protection.outlook.com (10.152.9.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2241.14 via Frontend Transport; Fri, 13 Sep 2019 10:07:05 +0000 Received: from AM6PR10MB2566.EURPRD10.PROD.OUTLOOK.COM ([fe80::2c65:b468:fdc0:d924]) by AM6PR10MB2566.EURPRD10.PROD.OUTLOOK.COM ([fe80::2c65:b468:fdc0:d924%6]) with mapi id 15.20.2263.018; Fri, 13 Sep 2019 10:07:05 +0000 From: Bernd Edlinger To: "gcc-patches@gcc.gnu.org" , "fortran@gcc.gnu.org" CC: Jeff Law Subject: [PATCH] Fix PR fortran/91716 Date: Fri, 13 Sep 2019 10:07:05 +0000 Message-ID: x-ms-exchange-transport-forked: True MIME-Version: 1.0 Hi, this fixes a test case where a short string constant is put in a larger memory object. The consistency check in varasm.c is failed because both types should agree. Since the failed assertion is just a gcc_checking_assert I think a back-port of this fix to the gcc-9 branch will not be necessary. Bootstrapped and reg-tested on x86_64-pc-linux-gnu. Is it OK for trunk? Thanks Bernd. 2019-09-13 Bernd Edlinger PR fortran/91716 * trans-array.c (gfc_conv_array_initializer): Always assign the array type of the field to the string constant. testsuite: 2019-09-13 Bernd Edlinger PR fortran/91716 * gfortran.dg/pr91716.f90: New test. Index: gcc/fortran/trans-array.c =================================================================== --- gcc/fortran/trans-array.c (revision 275685) +++ gcc/fortran/trans-array.c (working copy) @@ -6108,9 +6108,12 @@ gfc_conv_array_initializer (tree type, gfc_expr * tree atype = type; while (TREE_CODE (TREE_TYPE (atype)) == ARRAY_TYPE) atype = TREE_TYPE (atype); - if (TREE_CODE (TREE_TYPE (atype)) == INTEGER_TYPE - && tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (se.expr))) - > tree_to_uhwi (TYPE_SIZE_UNIT (atype))) + gcc_checking_assert (TREE_CODE (TREE_TYPE (atype)) + == INTEGER_TYPE); + gcc_checking_assert (TREE_TYPE (TREE_TYPE (se.expr)) + == TREE_TYPE (atype)); + if (tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (se.expr))) + > tree_to_uhwi (TYPE_SIZE_UNIT (atype))) { unsigned HOST_WIDE_INT size = tree_to_uhwi (TYPE_SIZE_UNIT (atype)); @@ -6117,8 +6120,8 @@ gfc_conv_array_initializer (tree type, gfc_expr * const char *p = TREE_STRING_POINTER (se.expr); se.expr = build_string (size, p); - TREE_TYPE (se.expr) = atype; } + TREE_TYPE (se.expr) = atype; } break; Index: gcc/testsuite/gfortran.dg/pr91716.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr91716.f90 (revision 0) +++ gcc/testsuite/gfortran.dg/pr91716.f90 (working copy) @@ -0,0 +1,8 @@ +! { dg-do compile } +! PR fortran/91716 +! Code contributed by Gerhard Steinmetz +module m + type t + character :: c(2) = [character(-1) :: 'a', 'b'] + end type +end