[GCC13,V4,0/2] Add a new option -fstrict-flex-array[=n] and attribute strict_flex_array(n) and use it in PR101836
Message ID | 20220907002817.236178-1-qing.zhao@oracle.com |
---|---|
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp899606wrt; Tue, 6 Sep 2022 17:29:58 -0700 (PDT) X-Google-Smtp-Source: AA6agR7R6F/zGO4U6whC+kTsbDzWGqW207PdNggocPlBUxhzXeZgF5R/FEt8lxee+/zBKCQbjYgP X-Received: by 2002:a17:907:a420:b0:765:70a4:c101 with SMTP id sg32-20020a170907a42000b0076570a4c101mr641844ejc.526.1662510598856; Tue, 06 Sep 2022 17:29:58 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ga28-20020a1709070c1c00b007707cdfc70fsi640097ejc.542.2022.09.06.17.29.58 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 17:29:58 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=x4DQ961w; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BD7C3383FBB8 for <ouuuleilei@gmail.com>; Wed, 7 Sep 2022 00:29:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BD7C3383FBB8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662510575; bh=mwZ0044E/yH+WR8vCJXlXl8QbpnVv6yQC3TShSKZdT0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=x4DQ961wxjiQl6uOz50Px18sysJ2GUtsH+PQt3a9oc4q+QC6GhU3Je+H53lqtu+EA Y8c9ChFs4yjej6VnXc6tucx6LDOQy8IUgsvaUCITWhCrCdt/V491Yp5qnYm07zSoql fb7+ur7fYbPNRyth1jZMaFi1PSfNkZR5+n23R0gs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id B4F433858297 for <gcc-patches@gcc.gnu.org>; Wed, 7 Sep 2022 00:28:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B4F433858297 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 286Ld2p5019652; Wed, 7 Sep 2022 00:28:46 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3jbxhsqduc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Sep 2022 00:28:46 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 286NueBX030634; Wed, 7 Sep 2022 00:28:45 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3jbwc3m311-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Sep 2022 00:28:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YTM2f2HAAraoFLKUcPWCXvSt/zFaGPwBpDt39lwnLlmU4IMfhzPFW7XSGiulIMSwXadj/qcyASQ+mPbgJ0iJAAMAcGtiYPH6vRQb+n+k3UnSv7okTV7iDz5+qYYiT0/I1AxU/GqZPNoc/stdzSIsznvYSDM4+o4d3kn3KkQE3mPDmhPQNtZzFsgc+F3xoJXZ55l6J5acXhQWvn46a1nrhu8gUCyBrDEPTXErVVcJ8UQWvACoFX6YSOWm6SQ1qo7WUjx7cA6uoet+pu3GpNgD3cSnZQgyuatfrqtx79H/gM3Ge3Ql+R9Qxk/Kdf9XOswl5Ee8jRKpa/xF03ySLZn0lQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mwZ0044E/yH+WR8vCJXlXl8QbpnVv6yQC3TShSKZdT0=; b=hyxe4KgFYCJ92Z8qW8+0sP7NW215xfWCNix5SujPYKfymJB4VXwJ8IFbsPRkrBs4ObZuySFDxJoO899B3X0VW0bpNBWpWnHoNfcFbE49V+hj/DB2oaFnXgfVeu+xSVnmPuK0Sk9Gpq4zMGpqhPWt0fT8Jn2bQ8RngAYxP24xSdzoxMfw9PpWbUOy08qsu1dOaYUIhbQ1SLNdoC5qJ52CpSr3JXwsyr57D2Kk/bNy4hPKVzuCUUexCYd6yUzB2YYWMxI1zOGcxZI+TD30lCNmoksWvbYs0MV1M3dYbYSB17eR9UwvPNuEey0+RYVcbYBQRrKMLSSEIxskJm+aGWQL4Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none Received: from CH2PR10MB4344.namprd10.prod.outlook.com (2603:10b6:610:af::19) by CY8PR10MB6801.namprd10.prod.outlook.com (2603:10b6:930:98::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10; Wed, 7 Sep 2022 00:28:43 +0000 Received: from CH2PR10MB4344.namprd10.prod.outlook.com ([fe80::84af:9275:f1d7:de1]) by CH2PR10MB4344.namprd10.prod.outlook.com ([fe80::84af:9275:f1d7:de1%6]) with mapi id 15.20.5588.018; Wed, 7 Sep 2022 00:28:42 +0000 To: gcc-patches@gcc.gnu.org Subject: [GCC13][Patch][V4][PATCH 0/2] Add a new option -fstrict-flex-array[=n] and attribute strict_flex_array(n) and use it in PR101836 Date: Wed, 7 Sep 2022 00:28:15 +0000 Message-Id: <20220907002817.236178-1-qing.zhao@oracle.com> X-Mailer: git-send-email 2.31.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SJ0PR03CA0353.namprd03.prod.outlook.com (2603:10b6:a03:39c::28) To CH2PR10MB4344.namprd10.prod.outlook.com (2603:10b6:610:af::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 957add78-4c9b-4bfc-494e-08da9067eb36 X-MS-TrafficTypeDiagnostic: CY8PR10MB6801:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kqm9IB8DrEd0t6cqhJ8i8v2hAwSKn0zogDPNhSHAwyJPHZEm8p41H2X/YC706GmTYTscF42UPuuaE5hDOvOfBNy+rzsy5DW0/3gpgkIaxcALys6iVn2OV3pcdu/158pCcODUFSTmoFIzGbDlZKlC634kDuS+XW73RiGUIzLNAI5YPSyAU9YauoG8TMdwKcJO8bwmQFummuFLBxL8XD0VhA8btBk84l09KjBzR4mXDcq5FY93MSub6U53lUJ/OeH9TM7gm5sad3YixyYMMK28h44Q3PScFxccxjVWxp7jMjhCYb/9rgfcldn9/vVc3Ty0s2+vJOlZMfMRky9p6pI94aLr1ZgvLu63jXHezvt3JP3nAiUeR7eiFxfRUOGvpJSnLY9LyuS3M+qAgow2m+WMhIeYNrwkqZ3M/2upf91X4g1n2av+2sBh1JEBTcoHHl08XE/uo3XCKWCekdOV64bc+8p0cRybkWCW31naDmT25B5RsrQeS9oJ0v8WoS2tguLYBKM96NH1azC+tMA4nNP5mBS34zZla+eN4xeC27klh2BcdFquEEsmnp3ejcwPd2KiRmFwA+KzXN32gxGKo5zmVtVNe9Nmi9YYv8EOWrXBvl+FOcX9pBH29CXRgC0bo3+ji4iUnik0H31pIwuxFlVsutB72VGbOjwK16aQXF9t+S44uD7M6DVIONAuzYj6xusCMoVBvDUJ9/hkgmX/6BfGUQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR10MB4344.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(396003)(39860400002)(376002)(366004)(136003)(346002)(6666004)(478600001)(6506007)(26005)(1076003)(6486002)(41300700001)(6512007)(4743002)(186003)(83380400001)(2616005)(5660300002)(2906002)(44832011)(8936002)(6916009)(107886003)(4326008)(66476007)(8676002)(66946007)(66556008)(316002)(86362001)(38100700002)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cr8pRQoRvnW/128lsXB5TTfzHcFJEFOSQmEb925lXPgoVoxpGBrzuU/U2xj1QucOq0O9MratiYXx7tW+5J8ZgWYcZP29oEE5PT1HUk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e498QGEEPjBPpnJJf0/YrjLuWzJebGv7Vt55uqCYXe1qy2bPYIhiB4mff5Tdd1lYiDtDmmUBRuBtD4xUWRZ6PporwXW+HDeix3CqFdQY31UNs8kBNNYMcVUsuii5EZE76ryljHj8brTlrZLnuC7F0JpG9jwMXpI9i54h/reU51zqnyEC7DNcMFPrYNWQYy+y3LGpfVVevEIf4Nae6U9WwBYeZzCCG6cgjyejL4o+ylOcRXUHt9TM0z/W9mRQjknZj4ASgMpk7Ho5RRGhRD4kcEhBK0xOYvJuZKL18AjMV0xj/XetVyt3uUkdcnu9PRD/WgVULi/c3wdrdJlB5EOfY0U3FYAZ7KZbRB7Y9/tcfCiQH98Im0dAzHZhKOOR1vMHcDHKjhtq1ZAQyi68UgwmEALAUTHW+nepNF/uRbWVW X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 957add78-4c9b-4bfc-494e-08da9067eb36 X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4344.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2022 00:28:42.9518 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: PYXSfUJ1we08b5Z7H7/wnqA1eXYdND4A6UezCj4DunsMjZ9NRzM0nPwk7D/CDMxwFEh/5OP3Mftzis6ygYAANg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR10MB6801 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-06_11,2022-09-06_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 malwarescore=0 mlxscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209070000 X-Proofpoint-GUID: UT05q7eXbRgz8WT6TINk9tcf8ttRPFpC X-Proofpoint-ORIG-GUID: UT05q7eXbRgz8WT6TINk9tcf8ttRPFpC X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Qing Zhao via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Qing Zhao <qing.zhao@oracle.com> Cc: jakub@redhat.com, rguenther@suse.de, msebor@gmail.com, joseph@codesourcery.com, keescook@chromium.org Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1743268713650634051?= X-GMAIL-MSGID: =?utf-8?q?1743268713650634051?= |
Series |
Add a new option -fstrict-flex-array[=n] and attribute strict_flex_array(n) and use it in PR101836
|
|
Message
Qing Zhao
Sept. 7, 2022, 12:28 a.m. UTC
This is the 4th version of the patch set. Compare to the 3rd version, the following are the major change: 1. delete all the warnings for the confliction between -std and -fstrict-flex-arrays per our discussion. 2. delete all the related testing cases for these warnings. 3. update all the wording changes, and documentation format changes recommanded by Joseph. I have bootstrapped and regression tested on both aarch64 and x86, no issues. Let me know if you have any comments on the patches. thanks. Qing Zhao (2): Add a new option -fstrict-flex-arrays[=n] and new attribute strict_flex_arrays Use array_at_struct_end_p in __builtin_object_size [PR101836] gcc/c-family/c-attribs.cc | 47 ++++++++ gcc/c-family/c.opt | 7 ++ gcc/c/c-decl.cc | 130 +++++++++++++++++++-- gcc/cp/module.cc | 2 + gcc/doc/extend.texi | 25 ++++ gcc/doc/invoke.texi | 27 ++++- gcc/print-tree.cc | 8 +- gcc/testsuite/g++.dg/strict-flex-array-1.C | 31 +++++ gcc/testsuite/gcc.dg/pr101836.c | 60 ++++++++++ gcc/testsuite/gcc.dg/pr101836_1.c | 60 ++++++++++ gcc/testsuite/gcc.dg/pr101836_2.c | 60 ++++++++++ gcc/testsuite/gcc.dg/pr101836_3.c | 60 ++++++++++ gcc/testsuite/gcc.dg/pr101836_4.c | 60 ++++++++++ gcc/testsuite/gcc.dg/pr101836_5.c | 60 ++++++++++ gcc/testsuite/gcc.dg/strict-flex-array-1.c | 31 +++++ gcc/testsuite/gcc.dg/strict-flex-array-2.c | 60 ++++++++++ gcc/testsuite/gcc.dg/strict-flex-array-3.c | 60 ++++++++++ gcc/tree-core.h | 5 +- gcc/tree-object-size.cc | 16 ++- gcc/tree-streamer-in.cc | 1 + gcc/tree-streamer-out.cc | 1 + gcc/tree.cc | 45 +++++-- gcc/tree.h | 14 ++- 23 files changed, 833 insertions(+), 37 deletions(-) create mode 100644 gcc/testsuite/g++.dg/strict-flex-array-1.C create mode 100644 gcc/testsuite/gcc.dg/pr101836.c create mode 100644 gcc/testsuite/gcc.dg/pr101836_1.c create mode 100644 gcc/testsuite/gcc.dg/pr101836_2.c create mode 100644 gcc/testsuite/gcc.dg/pr101836_3.c create mode 100644 gcc/testsuite/gcc.dg/pr101836_4.c create mode 100644 gcc/testsuite/gcc.dg/pr101836_5.c create mode 100644 gcc/testsuite/gcc.dg/strict-flex-array-1.c create mode 100644 gcc/testsuite/gcc.dg/strict-flex-array-2.c create mode 100644 gcc/testsuite/gcc.dg/strict-flex-array-3.c