From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 128036 invoked by alias); 2 Oct 2017 22:24:17 -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 127903 invoked by uid 89); 2 Oct 2017 22:24:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Okay, incremental X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 02 Oct 2017 22:24:06 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9ECC37E425; Mon, 2 Oct 2017 22:24:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9ECC37E425 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=law@redhat.com Received: from localhost.localdomain (ovpn-112-25.rdu2.redhat.com [10.10.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8435A5D973; Mon, 2 Oct 2017 22:23:56 +0000 (UTC) Subject: Re: [PATCH 1/3] improve detection of attribute conflicts (PR 81544) To: Martin Sebor , Joseph Myers Cc: Marek Polacek , Gcc Patch List , Jason Merrill 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: Jeff Law Message-ID: Date: Mon, 02 Oct 2017 22:24:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2017-10/txt/msg00086.txt.bz2 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