From patchwork Fri Jan 17 19:58:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 312198 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 96B282C0091 for ; Sat, 18 Jan 2014 06:58:21 +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 :from:to:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=rz3s3GaGveTZYtxrIu5+yFzSti29L CGrIZYhGnVrIafgVoRlzwFBkT/ok5/84L5Qtbvkrucnhjp22PK34EPu0mwNlp6Gu o7E1nUWp0Auo9BKdLzwSgmQXrirsJE4jR1eJAt/tjxLjYzyi1FQS3GXFHshbv7+o LxH45iZS4/QsCM= 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:reply-to:mime-version :content-type; s=default; bh=8gNrlmlTWNlC0ndIFf/eawNW+20=; b=Dam E5bLb0R1vG0qRgWyH8l6x8mD+X8M3Rmvl7zUwIrfdO6VGZvDWBILme/gBw3gb7yL 8ODKFUukBnIQuIDThwBinqgDHgXl16vRXsSsYJmR3r80kJMAhXnvVCiF0IFTdt5v gIccOm7TIZ65zR3aYn8keLJHkx1i3ni8rAaHp8Zk= Received: (qmail 13787 invoked by alias); 17 Jan 2014 19:58:14 -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 13776 invoked by uid 89); 17 Jan 2014 19:58:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham 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 ESMTP; Fri, 17 Jan 2014 19:58:13 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0HJwBnM031960 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 17 Jan 2014 14:58:11 -0500 Received: from tucnak.zalov.cz (vpn1-7-114.ams2.redhat.com [10.36.7.114]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s0HJwA9W006775 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 17 Jan 2014 14:58:11 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.14.7/8.14.7) with ESMTP id s0HJw97R001699; Fri, 17 Jan 2014 20:58:09 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.14.7/8.14.7/Submit) id s0HJw8s9001698; Fri, 17 Jan 2014 20:58:08 +0100 Date: Fri, 17 Jan 2014 20:58:08 +0100 From: Jakub Jelinek To: Uros Bizjak , Tom Tromey , Richard Henderson Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Avoid -Wunused-macros warning for #pragma GCC target added macros (PR target/58944) Message-ID: <20140117195808.GM892@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Hi! It makes no sense to warn about unused macros that weren't defined by the user, but the compiler instead injected them, the user has no control on them. For macros predefined at the beginning of the CU we don't get warnings because they don't match MAIN_FILE_P, but macros added for #pragma GCC target get location_t from the location of the pragma (and without libcpp hacks that could possibly slow down preprocessing I don't see how to get around it), so the following hack seems to be easiest. All newly created macros when -Wunused-macros isn't on are initialized with macro->used = true, and never warned about for this warning, so this patch just arranges for all the cpp_define calls from #pragma GCC target to set that. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2014-01-17 Jakub Jelinek PR target/58944 * config/i386/i386-c.c (ix86_pragma_target_parse): Temporarily clear cpp_get_options (parse_in)->warn_unused_macros for ix86_target_macros_internal with cpp_define. * gcc.target/i386/pr58944.c: Drop -march=native from dg-options. Remove dg-prune-output lines. Jakub --- gcc/config/i386/i386-c.c.jj 2014-01-03 11:41:06.000000000 +0100 +++ gcc/config/i386/i386-c.c 2014-01-17 14:24:15.828447673 +0100 @@ -458,6 +458,13 @@ ix86_pragma_target_parse (tree args, tre (enum fpmath_unit) prev_opt->x_ix86_fpmath, cpp_undef); + /* For the definitions, ensure all newly defined macros are considered + as used for -Wunused-macros. There is no point warning about the + compiler predefined macros. */ + cpp_options *cpp_opts = cpp_get_options (parse_in); + unsigned char saved_warn_unused_macros = cpp_opts->warn_unused_macros; + cpp_opts->warn_unused_macros = 0; + /* Define all of the macros for new options that were just turned on. */ ix86_target_macros_internal (cur_isa & diff_isa, cur_arch, @@ -465,6 +472,8 @@ ix86_pragma_target_parse (tree args, tre (enum fpmath_unit) cur_opt->x_ix86_fpmath, cpp_define); + cpp_opts->warn_unused_macros = saved_warn_unused_macros; + return true; } --- gcc/testsuite/gcc.target/i386/pr58944.c.jj 2013-12-03 08:27:22.000000000 +0100 +++ gcc/testsuite/gcc.target/i386/pr58944.c 2014-01-17 14:29:53.288756542 +0100 @@ -1,11 +1,7 @@ /* { dg-do compile } */ -/* { dg-options "-Wunused-macros -march=native" } */ +/* { dg-options "-Wunused-macros" } */ #pragma GCC push_options #pragma GCC target("xsaveopt") void fn1(void) {} #pragma GCC pop_options - -/* { dg-prune-output "macro \"__code_model_" } */ -/* { dg-prune-output "macro \"__XSAVE__\" is not used" } */ -/* { dg-prune-output "macro \"__XSAVEOPT__\" is not used" } */