From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 84223 invoked by alias); 4 Apr 2018 16:16: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 84205 invoked by uid 89); 4 Apr 2018 16:16:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=jeff, Jeff, Common, excl X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 04 Apr 2018 16:16:38 +0000 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w34GDFxE012621 for ; Wed, 4 Apr 2018 12:16:37 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0a-001b2d01.pphosted.com with ESMTP id 2h50ga576r-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 04 Apr 2018 12:16:36 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 4 Apr 2018 17:16:34 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 4 Apr 2018 17:16:33 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w34GGWxs5702038; Wed, 4 Apr 2018 16:16:32 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CF8CC42045; Wed, 4 Apr 2018 17:08:22 +0100 (BST) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ABF1F4204B; Wed, 4 Apr 2018 17:08:22 +0100 (BST) Received: from [9.152.212.134] (unknown [9.152.212.134]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 4 Apr 2018 17:08:22 +0100 (BST) Subject: Re: [PATCH 1/3] improve detection of attribute conflicts (PR 81544) To: Martin Sebor Cc: Gcc Patch List References: <20170809115341.GM17069@redhat.com> <52dbf0e4-09b3-f313-d6b1-92f0e5ac6c16@gmail.com> <0fc9f24b-f474-3ab5-e660-b206486cc644@gmail.com> <61464927-ba0d-860d-d08f-5d36d473e3c2@gmail.com> From: Andreas Krebbel Date: Wed, 04 Apr 2018 16:16:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 18040416-0044-0000-0000-0000054374EF X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18040416-0045-0000-0000-000028838CB0 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-04-04_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804040163 X-IsSubscribed: yes X-SW-Source: 2018-04/txt/msg00167.txt.bz2 On 10/03/2017 12:23 AM, Jeff Law wrote: > On 09/20/2017 12:04 PM, Martin Sebor wrote: >> On 09/19/2017 03:00 PM, Joseph Myers wrote: >>> On Tue, 19 Sep 2017, Martin Sebor wrote: >>> >>>>> In general, the data structures where you need to ensure manually that if >>>>> >>>>> attribute A is listed in EXCL for B, then attribute B is also listed in >>>>> EXCL for A, seem concerning.  I'd expect either data structures that make >>>>> >>>>> such asymmetry impossible, or a self-test that verifies that the tables in >>>>> >>>>> use are in fact symmetric (unless there is some reason the symmetry is not >>>>> >>>>> in fact required and symmetric diagnostics still result from asymmetric >>>>> tables - in which case the various combinations and orderings of >>>>> gnu_inline and noinline definitely need tests to show that the diagnostics >>>>> >>>>> work). >>>> >>>> If I understand correctly what you're concerned about then I don't >>>> think there are any such cases in the updated version of the patch. >>> >>> I don't see how you ensure that it's not possible to have such asymmetry. >>> My point wasn't so much "there was a bug in the previous patch version" as >>> >>> "the choice of data structures for defining such exclusions is prone to >>> such bugs".  Which can be addressed either by using different data >>> structures (e.g. listing incompatible pairs in a single array) or by a >>> self-test to verify symmetry so a compiler with asymmetry doesn't build. >> >> Okay, that's a useful thing to add.  It exposed a couple of missing >> attribute exclusions that I had overlooked.  Thanks for the suggestion! >> Attached is an incremental diff with just these changes to make review >> easier and an updated patch. >> >> As an aside, there are a number of other possible logic errors in >> the attribute specifications that could be detected by self-tests. >> The one I ran into is misspelled attribute names.  The added test >> detects misspelled names in exclusions, but not in the main specs. >> >> Martin >> >> gcc-81544-1-inc.diff >> >> > > >> gcc-81544-1.diff >> >> >> PR c/81544 - attribute noreturn and warn_unused_result on the same function accepted >> >> gcc/c/ChangeLog: >> >> PR c/81544 >> * c-decl.c (c_decl_attributes): Look up existing declaration and >> pass it to decl_attributes. >> >> gcc/c-family/ChangeLog: >> >> PR c/81544 >> * c-attribs.c (attr_aligned_exclusions): New array. >> (attr_alloc_exclusions, attr_cold_hot_exclusions): Same. >> (attr_common_exclusions, attr_const_pure_exclusions): Same. >> (attr_gnu_inline_exclusions, attr_inline_exclusions): Same. >> (attr_noreturn_exclusions, attr_returns_twice_exclusions): Same. >> (attr_warn_unused_result_exclusions): Same. >> (handle_hot_attribute, handle_cold_attribute): Simplify. >> (handle_const_attribute): Warn on function returning void. >> (handle_pure_attribute): Same. >> * c-warn.c (diagnose_mismatched_attributes): Simplify. >> >> gcc/ChangeLog: >> >> PR c/81544 >> * attribs.c (empty_attribute_table): Initialize new member of >> struct attribute_spec. >> (decl_attributes): Add argument. Handle mutually exclusive >> combinations of attributes. >> * attribs.h (decl_attributes): Add default argument. >> * selftest.h (attribute_c_tests): Declare. >> * selftest-run-tests.c (selftest::run_tests): Call attribute_c_tests. >> * tree-core.h (attribute_spec::exclusions, exclude): New type and >> member. >> * doc/extend.texi (Common Function Attributes): Update const and pure. >> >> gcc/testsuite/ChangeLog: >> >> PR c/81544 >> * c-c++-common/Wattributes-2.c: New test. >> * c-c++-common/Wattributes.c: New test. >> * c-c++-common/attributes-3.c: Adjust. >> * gcc.dg/attr-noinline.c: Adjust. >> * gcc.dg/pr44964.c: Same. >> * gcc.dg/torture/pr42363.c: Same. >> * gcc.dg/tree-ssa/ssa-ccp-2.c: Same. > OK. > jeff > On targets enforcing a function alignment bigger than 4 bytes this triggers an error instead: +inline int ATTR ((aligned (4))) +finline_hot_noret_align (int); /* { dg-warning "ignoring attribute .aligned \\(4\\). because it conflicts with attribute .aligned \\(8\\)." } */ gcc/gcc/testsuite/c-c++-common/Wattributes.c:404:1: error: alignment for 'finline_hot_noret_align' must be at least 8^M