From patchwork Sun Mar 31 07:10:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teresa Johnson X-Patchwork-Id: 232594 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id E7EDB2C00CE for ; Sun, 31 Mar 2013 18:11:04 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :to:subject:mime-version:content-type:content-transfer-encoding :message-id:from; q=dns; s=default; b=eE8vvypXVh2M6P6F2FSlJmnWST x79rUiN2loN6+8jHknQj18Z1gJ8NZ+l1L2O2BVfyg3knYGUmq8hhl0aSSIZgRMIf 98R/5jGzH9BD2yq5rzAe0y8DOIxZ+uq1FMg6cRnL57i0wQ4cfVBYUGo1W1NVCFWW H+9tZo++G/i92WXpY= 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:date :to:subject:mime-version:content-type:content-transfer-encoding :message-id:from; s=default; bh=aK/gs3gIyajteOnOXd8iLSBjVXg=; b= Mf5KqPq/p+vbdSWUte6+uXkytlATyoY67m4+M6IZUDbUc/gv/mlmigHnMcpm1YXN p6TJSR1o5IxK76851sk06pPze58ID8y/6dVh/vhhqxxJ+Fz8q1EcxdAwMfa2Q/k+ iKuU5TRE1sERhusBsUvwnBxLHH1JpECHRfBZNqmST9Y= Received: (qmail 13872 invoked by alias); 31 Mar 2013 07:10:53 -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 13825 invoked by uid 89); 31 Mar 2013 07:10:43 -0000 X-Spam-SWARE-Status: No, score=-5.5 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD autolearn=ham version=3.3.1 Received: from mail-bk0-f74.google.com (HELO mail-bk0-f74.google.com) (209.85.214.74) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Sun, 31 Mar 2013 07:10:40 +0000 Received: by mail-bk0-f74.google.com with SMTP id y8so108024bkt.5 for ; Sun, 31 Mar 2013 00:10:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:date:to:subject:user-agent:mime-version:content-type :content-transfer-encoding:message-id:from:x-gm-message-state; bh=NHqFbMS5L3Vs4XlKvWAM64Ig3aVzozZEwrfMVMJPIk8=; b=kE9cSKJy72Qhbb1UNqU5JoOx1X/rTEkBnmBjWsnN7cBrHk9GfK+vEeF7DD+Z1/dVU8 kuqGVQ6c3xbhO3Bhh07fnGoA3vTX4leOf4kMpPV6Qszmt/wDTTQGELnYTZP2bSOXhRq+ hrikrTCCZ1TvL8eB6pc+ta5nJ7LIwdldENljC3xuASmeleIWKmGv5TX6zFuFMgIkpFtq tSPuTHbK1+wfBmSF5pOXmMv5ItTc738ujBOku0Z3v0b4nYy1TUSoBZGspqF/p9XDnVtD cBWTC5tb8z+oZ66fBIf1ESnqUhCaeo6U95QGDRGpEjCo4qIrzEyZw2u4u49OvG9X5f8c +VpA== X-Received: by 10.14.221.3 with SMTP id q3mr11211439eep.5.1364713837633; Sun, 31 Mar 2013 00:10:37 -0700 (PDT) Received: from corp2gmr1-2.eem.corp.google.com (corp2gmr1-2.eem.corp.google.com [172.25.138.117]) by gmr-mx.google.com with ESMTPS id 6si2276812eej.0.2013.03.31.00.10.37 (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Sun, 31 Mar 2013 00:10:37 -0700 (PDT) Received: from tjsboxrox.mtv.corp.google.com (tjsboxrox.mtv.corp.google.com [172.17.129.49]) by corp2gmr1-2.eem.corp.google.com (Postfix) with ESMTP id 622DF1E419F; Sun, 31 Mar 2013 00:10:37 -0700 (PDT) Received: by tjsboxrox.mtv.corp.google.com (Postfix, from userid 147431) id A877C807B2; Sun, 31 Mar 2013 00:10:36 -0700 (PDT) Date: Sun, 31 Mar 2013 00:10:36 -0700 To: gcc-patches@gcc.gnu.org, reply@codereview.appspotmail.com Subject: [PATCH] Avoid warning when unused attribute applied to C++ member variables (issue8212043) User-Agent: Heirloom mailx 12.5 6/20/10 MIME-Version: 1.0 Message-Id: <20130331071036.A877C807B2@tjsboxrox.mtv.corp.google.com> From: tejohnson@google.com (Teresa Johnson) X-Gm-Message-State: ALoCoQlUNmOZ9x8vNL3FuEwQMZZc5WEXJ7GXsmGQWmCUsa4UchSy+Yl/Hjov/HiqQscsv3JGntFiHAJKCW3T42fCASuk7WI3GmU8NbglGagkNGx8g3Lg3+yMX6RdJD1GtdFYqfdJCpX7ns08nH0jy1fLC3mCsGBZkV75XwFiOcHJtg8d5K6rewk8R3fHg+vpNxyP+QUy1HA4 This patch allows the unused attribute to be used without warning on C++ class members, which are of type FIELD_DECL. This is for compatibility with clang, which allows the attribute to be specified on class members and struct fields. It looks like more work would need to be done to implement the actual unused variable detection and warning on FIELD_DECLs, but this change will at least avoid the warning on the code that uses the unused attribute in these cases. The documentation at http://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html also doesn't seem to preclude its use on C++ member variables. Bootstrapped and tested on x86-64-unknown-linux-gnu. Ok for trunk? 2013-03-30 Teresa Johnson * c-family/c-common.c (handle_unused_attribute): Handle FIELD_DECL for C++ class members. --- This patch is available for review at http://codereview.appspot.com/8212043 Index: c-family/c-common.c =================================================================== --- c-family/c-common.c (revision 197266) +++ c-family/c-common.c (working copy) @@ -6753,6 +6753,7 @@ handle_unused_attribute (tree *node, tree name, tr if (TREE_CODE (decl) == PARM_DECL || TREE_CODE (decl) == VAR_DECL + || TREE_CODE (decl) == FIELD_DECL || TREE_CODE (decl) == FUNCTION_DECL || TREE_CODE (decl) == LABEL_DECL || TREE_CODE (decl) == TYPE_DECL)