From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 54369 invoked by alias); 20 Feb 2020 07:11:42 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 54361 invoked by uid 89); 20 Feb 2020 07:11:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mailout1.w1.samsung.com Received: from mailout1.w1.samsung.com (HELO mailout1.w1.samsung.com) (210.118.77.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 20 Feb 2020 07:11:39 +0000 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200220071136euoutp015e11e6a04d279dc67637acc46bd6c93c~1Csd-NtEW2988029880euoutp01D for ; Thu, 20 Feb 2020 07:11:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200220071136euoutp015e11e6a04d279dc67637acc46bd6c93c~1Csd-NtEW2988029880euoutp01D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1582182696; bh=JjrjXkOnwzi+PeC68cYndAYds3MUE6s8ozrTSaiLjy4=; h=From:To:Cc:Subject:Date:References:From; b=PIptmKQZNxMemwD+dV2FleIc7hjT7l6+mx+Z0JDHXoeFq4DrL0CY8hgjQIG6zbM9O ZEFj6i6zTw1XashX1UInDs1HQltDrZZRqOrfUdAZ7AhmbwFK6K3oNT4fvf3EMkkr2z gzlzO0EUOjH02FOCoCcvEtOzrchlfzHfggt2RgH4= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200220071135eucas1p1e92d3aa4216d5b50f2cc4eb3a055d454~1CsdvlRZ11216212162eucas1p1b; Thu, 20 Feb 2020 07:11:35 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id E0.B3.60679.7213E4E5; Thu, 20 Feb 2020 07:11:35 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200220071135eucas1p1af0b37124681ceb36eeddd16ba62ecb6~1CsdWm0HQ2993329933eucas1p1m; Thu, 20 Feb 2020 07:11:35 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200220071135eusmtrp209b385b1be8ed93d6c8dae191cd33d74~1CsdWFDQR2180721807eusmtrp2s; Thu, 20 Feb 2020 07:11:35 +0000 (GMT) Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 77.35.07950.7213E4E5; Thu, 20 Feb 2020 07:11:35 +0000 (GMT) Received: from vbarinov (unknown [106.109.129.54]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200220071134eusmtip1fce59797e2a3d1a2868eb448fd3dc826~1CscII-ra0604106041eusmtip10; Thu, 20 Feb 2020 07:11:33 +0000 (GMT) Received: by vbarinov (sSMTP sendmail emulation); Thu, 20 Feb 2020 10:11:33 +0300 From: Slava Barinov To: gcc-patches@gcc.gnu.org Cc: Slava Barinov Subject: [PATCH] c++/93730 create VLA constructor if explicitly initialized as zeroes Date: Thu, 20 Feb 2020 07:11:00 -0000 Message-Id: <20200220071120.13391-1-v.barinov@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CMS-MailID: 20200220071135eucas1p1af0b37124681ceb36eeddd16ba62ecb6 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200220071135eucas1p1af0b37124681ceb36eeddd16ba62ecb6 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200220071135eucas1p1af0b37124681ceb36eeddd16ba62ecb6 References: X-SW-Source: 2020-02/txt/msg01148.txt.bz2 * cp/decl.c (reshape_init_array_1): Enforce constructor creation for VLAs when initialized with zero value. * testsuite/g++.dg/pr93730.C: New test * testsuite/g++.dg/abi/mangle72.C: Change mangling to new version Signed-off-by: Slava Barinov This fixes case when VLA is explicitly initialized with zero, not generic issue c++/58646 though. Bootstrapped on x86_64, no testsuite regressions found, except mangling change in mangle72.C, Not sure about mangling: is there any ABI requirements to mangling for that cases? --- gcc/ChangeLog | 8 ++++++++ gcc/cp/decl.c | 3 ++- gcc/testsuite/g++.dg/abi/mangle72.C | 14 +++++++------- gcc/testsuite/g++.dg/pr93730.C | 8 ++++++++ 4 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/g++.dg/pr93730.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f5876a3023e..10fa0334ec3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2020-02-20 Vyacheslav Barinov + + PR c++/93730 + * cp/decl.c (reshape_init_array_1): Enforce constructor creation + for VLAs when initialized with zero value. + * testsuite/g++.dg/pr93730.C: New test + * testsuite/g++.dg/abi/mangle72.C: Change mangling to new version + 2020-02-19 Bernd Edlinger * collect2.c (maybe_run_lto_and_relink): Fix typo in diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 31a556a0a1f..e90a397fc11 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -6043,7 +6043,8 @@ reshape_init_array_1 (tree elt_type, tree max_index, reshape_iter *d, even if the string is empty. */ tree init_type = TREE_TYPE (elt_init); if (POINTER_TYPE_P (elt_type) != POINTER_TYPE_P (init_type) - || !type_initializer_zero_p (elt_type, elt_init)) + || !type_initializer_zero_p (elt_type, elt_init) + || sized_array_p) last_nonzero = index; /* This can happen with an invalid initializer (c++/54501). */ diff --git a/gcc/testsuite/g++.dg/abi/mangle72.C b/gcc/testsuite/g++.dg/abi/mangle72.C index 656a0cae403..928a38da021 100644 --- a/gcc/testsuite/g++.dg/abi/mangle72.C +++ b/gcc/testsuite/g++.dg/abi/mangle72.C @@ -27,16 +27,16 @@ void g__ (Y) { } // { dg-final { scan-assembler "_Z3g__1YIXtl1BtlA2_M1AA2_iLS3_0EEEEE" } } void g0_ (Y) { } -// { dg-final { scan-assembler "_Z3g0_1YIXtl1BtlA2_M1AA2_iLS3_0EEEEE" } } +// { dg-final { scan-assembler "_Z3g0_1YIXtl1BtlA2_M1AA2_iLS3_0ELS3_0EEEEE" } } void g00 (Y) { } -// { dg-final { scan-assembler "_Z3g001YIXtl1BtlA2_M1AA2_iLS3_0EEEEE" } } +// { dg-final { scan-assembler "_Z3g001YIXtl1BtlA2_M1AA2_iLS3_0ELS3_0EEEEE" } } void g0x (Y) { } // FIXME: This needs to mangle differently from g00. The space at // the end is intentional to make the directive fail so that the xfail // can be reminder to change this once the mangling is fixed. -// { dg-final { scan-assembler "_Z3g0x1YIXtl1BtlA2_M1AA2_iLS3_0EEEEE " { xfail *-*-* } } } +// { dg-final { scan-assembler "_Z3g0x1YIXtl1BtlA2_M1AA2_iLS3_0ELS3_0EEEEE " { xfail *-*-* } } } void gx_ (Y) { } // { dg-final { scan-assembler "_Z3gx_1YIXtl1BtlA2_M1AA2_iLS3_0ELS3_0EEEEE" } } @@ -49,17 +49,17 @@ void h___ (Z) { } // { dg-final { scan-assembler "_Z4h___1ZIXtl1CtlA3_M1AA2_iLS3_0EEEEE" } } void h0__ (Z) { } -// { dg-final { scan-assembler "_Z4h0__1ZIXtl1CtlA3_M1AA2_iLS3_0EEEEE" } } +// { dg-final { scan-assembler "_Z4h0__1ZIXtl1CtlA3_M1AA2_iLS3_0ELS3_0EEEEE" } } void h00_ (Z) { } -// { dg-final { scan-assembler "_Z4h00_1ZIXtl1CtlA3_M1AA2_iLS3_0EEEEE" } } +// { dg-final { scan-assembler "_Z4h00_1ZIXtl1CtlA3_M1AA2_iLS3_0ELS3_0ELS3_0EEEEE" } } void h000 (Z) { } -// { dg-final { scan-assembler "_Z4h0001ZIXtl1CtlA3_M1AA2_iLS3_0EEEEE" } } +// { dg-final { scan-assembler "_Z4h0001ZIXtl1CtlA3_M1AA2_iLS3_0ELS3_0ELS3_0EEEEE" } } void h00x (Z) { } // FIXME: This needs to mangle differently from hx0_ and hx__. -// { dg-final { scan-assembler "_Z4h00x1ZIXtl1CtlA3_M1AA2_iLS3_0ELS3_0EEEEE " { xfail *-*-*} } } +// { dg-final { scan-assembler "_Z4h00x1ZIXtl1CtlA3_M1AA2_iLS3_0ELS3_0ELS3_0EEEEE " { xfail *-*-*} } } void h0x0 (Z) { } // { dg-final { scan-assembler "_Z4h0x01ZIXtl1CtlA3_M1AA2_iLS3_0ELS3_0ELS3_0EEEEE" } } diff --git a/gcc/testsuite/g++.dg/pr93730.C b/gcc/testsuite/g++.dg/pr93730.C new file mode 100644 index 00000000000..066c23a99cb --- /dev/null +++ b/gcc/testsuite/g++.dg/pr93730.C @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Wno-vla" } */ + +int sz = 1; + +void f() { + int arr[1][sz] = { 0 }; +} -- 2.25.1