From patchwork Mon Jun 8 10:07:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 481813 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 00CC314018C for ; Mon, 8 Jun 2015 20:08:12 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=Jh74ljef; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=OBjI01el3LauwPUKBPbTvIt9H9dms1L+Uoafnhua+CAoQc4n/0 V3mlApHRCP00spKLMD7LIqIE6rWGzPGGqIG93GZcSChrKsXejIcAvlIBtfQXmmqw dQ/eDlRPjN/uzD9gNr7kNycRaS2T7VPrzfeidtjQ1pG1yBmRZPMgC2GPw= 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 :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=P3EUomLqKhkfz8gM3k3V9Nwxtyo=; b=Jh74ljefHhnlreLoN4j5 1OTtMgp+O/g+g+DqOGWEyPcaK3V7XaVTR6fOGNoCYd9WUSoEes4qi0XirTWWTegh EGfsLCd5yByyuwF8Ol/RCN/q6HS+k3jgmlIxe5k9PNz+8OR9h2ShUxTHLoHtQIor jAF8AqoBqBDQosYZQw4qj2c= Received: (qmail 69694 invoked by alias); 8 Jun 2015 10:08:05 -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 69677 invoked by uid 89); 8 Jun 2015 10:08:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 08 Jun 2015 10:08:01 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 3831CB1F87; Mon, 8 Jun 2015 10:07:58 +0000 (UTC) Received: from redhat.com (ovpn-204-27.brq.redhat.com [10.40.204.27]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t58A7s0M003445 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Mon, 8 Jun 2015 06:07:57 -0400 Date: Mon, 8 Jun 2015 12:07:54 +0200 From: Marek Polacek To: GCC Patches Cc: Jakub Jelinek , Richard Biener Subject: [PATCH] Disable -Wunused warning for artificial decls (PR sanitizer/66452) Message-ID: <20150608100753.GP2756@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) This PR is about a bogus -Wunused-variable warning about an internal structure (*.Lubsan_data*), exposed by the debug-early merge. I think the "defined but not used" warning should not be allowed for the compiler-generated entities. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2015-06-08 Marek Polacek PR sanitizer/66452 * toplev.c (check_global_declaration): Don't warn about artificial decls. * g++.dg/ubsan/pr66452.C: New test. Marek diff --git gcc/testsuite/g++.dg/ubsan/pr66452.C gcc/testsuite/g++.dg/ubsan/pr66452.C index e69de29..473543c 100644 --- gcc/testsuite/g++.dg/ubsan/pr66452.C +++ gcc/testsuite/g++.dg/ubsan/pr66452.C @@ -0,0 +1,16 @@ +// PR sanitizer/66452 +// { dg-do compile } +// { dg-options "-Wall -fsanitize=undefined" } + +class A { +public: + A(int); +}; +class B { + A m_fn1() const; +}; +A B::m_fn1() const { + for (int i = 0;i;) + ; + return 0; +} diff --git gcc/toplev.c gcc/toplev.c index fd2ac4e..eb8b8ac 100644 --- gcc/toplev.c +++ gcc/toplev.c @@ -534,6 +534,7 @@ check_global_declaration (tree decl) to handle multiple external decls in different scopes. */ && ! (DECL_NAME (decl) && TREE_USED (DECL_NAME (decl))) && ! DECL_EXTERNAL (decl) + && ! DECL_ARTIFICIAL (decl) && ! TREE_PUBLIC (decl) /* A volatile variable might be used in some non-obvious way. */ && ! TREE_THIS_VOLATILE (decl)