From patchwork Wed Nov 10 16:43:40 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bingfeng Mei X-Patchwork-Id: 70648 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]) by ozlabs.org (Postfix) with SMTP id CFC12B70F6 for ; Thu, 11 Nov 2010 03:44:35 +1100 (EST) Received: (qmail 14166 invoked by alias); 10 Nov 2010 16:44:29 -0000 Received: (qmail 14146 invoked by uid 22791); 10 Nov 2010 16:44:27 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mms3.broadcom.com (HELO MMS3.broadcom.com) (216.31.210.19) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 10 Nov 2010 16:43:59 +0000 Received: from [10.16.192.224] by MMS3.broadcom.com with ESMTP (Broadcom SMTP Relay (Email Firewall v6.3.2)); Wed, 10 Nov 2010 08:43:46 -0800 X-Server-Uuid: B55A25B1-5D7D-41F8-BC53-C57E7AD3C201 Received: from SJEXCHCCR02.corp.ad.broadcom.com ([10.16.192.130]) by SJEXCHHUB01.corp.ad.broadcom.com ([10.16.192.224]) with mapi; Wed, 10 Nov 2010 08:43:46 -0800 From: "Bingfeng Mei" To: "gcc-patches@gcc.gnu.org" Date: Wed, 10 Nov 2010 08:43:40 -0800 Subject: [PATCH]: issue warning about -f(no-)strict-aliasing in function optimize attribute Message-ID: <7FB04A5C213E9943A72EE127DB74F0ADA69190944C@SJEXCHCCR02.corp.ad.broadcom.com> x-cr-puzzleid: {9F92608E-64FA-4C0E-9A8A-CE3F6A90B135} x-cr-hashedpuzzle: itE= ABa3 AKky A8Di CDlA CGe9 CnMj Dk0C DlgE GAuv Ga2a HQnm HQ/+ IPcF JES6 LHlQ; 1; ZwBjAGMALQBwAGEAdABjAGgAZQBzAEAAZwBjAGMALgBnAG4AdQAuAG8AcgBnAA==; Sosha1_v1; 7; {9F92608E-64FA-4C0E-9A8A-CE3F6A90B135}; YgBtAGUAaQBAAGIAcgBvAGEAZABjAG8AbQAuAGMAbwBtAA==; Wed, 10 Nov 2010 16:43:40 GMT; WwBQAEEAVABDAEgAXQA6ACAAaQBzAHMAdQBlACAAdwBhAHIAbgBpAG4AZwAgAGEAYgBvAHUAdAAgAC0AZgAoAG4AbwAtACkAcwB0AHIAaQBjAHQALQBhAGwAaQBhAHMAaQBuAGcAIABpAG4AIABmAHUAbgBjAHQAaQBvAG4AIABvAHAAdABpAG0AaQB6AGUAIABhAHQAdAByAGkAYgB1AHQAZQA= MIME-Version: 1.0 X-IsSubscribed: yes 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 Hello, Currently, if we specify a different -f(no-)strict-aliasing option in function optimize attribute. GCC just quietly ignores it. http://gcc.gnu.org/ml/gcc/2010-11/msg00091.html It is error-prone as it is not expected by a programmer. The patch issues a warning in such situation. One thing I am not sure is that different optimizing levels also have different setting for strict-aliasing. Should I also warn that (will make some existing tests fail), or make it an exception? This patch ignores such case. Bootstrapped and tested with x86_64-unknown-linux-gnu. Thanks, Bingfeng Mei 2010-11-10 Bingfeng Mei * c-family/c-common.c (parse_optimize_options): Issue warning about -f(no-)strict-aliasing in optimize attribute. Index: c-family/c-common.c =================================================================== --- c-family/c-common.c (revision 166523) +++ c-family/c-common.c (working copy) @@ -7808,6 +7808,16 @@ parse_optimize_options (tree args, bool targetm.override_options_after_change(); + /* Currently GCC doesn't support function-specific -f(no-)strict-aliasing + Issue a warning under such case. + Ignore cases where difference is caused by different optimization + levels. (strict aliasing is disabled < -O2 ) + */ + if ((!flag_strict_aliasing && saved_flag_strict_aliasing && optimize >= 2) + || (flag_strict_aliasing && !saved_flag_strict_aliasing && optimize < 2)) + warning (OPT_Wattributes, + "-f(no-)strict-aliasing option in optimize attribute ignored"); + /* Don't allow changing -fstrict-aliasing. */ flag_strict_aliasing = saved_flag_strict_aliasing;