From patchwork Tue Jan 18 18:20:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 79337 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 0E59BB708B for ; Wed, 19 Jan 2011 05:20:58 +1100 (EST) Received: (qmail 24441 invoked by alias); 18 Jan 2011 18:20:56 -0000 Received: (qmail 24429 invoked by uid 22791); 18 Jan 2011 18:20:55 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_CX, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 18 Jan 2011 18:20:48 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0IIKlHY008408 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 18 Jan 2011 13:20:47 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p0IIKkiT027566; Tue, 18 Jan 2011 13:20:47 -0500 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p0IIKkba017201; Tue, 18 Jan 2011 13:20:46 -0500 Received: by opsy.redhat.com (Postfix, from userid 500) id DF1C0378326; Tue, 18 Jan 2011 11:20:45 -0700 (MST) From: Tom Tromey To: gcc-patches@gcc.gnu.org Subject: RFA: let __extension__ suppress overlength string warning Date: Tue, 18 Jan 2011 11:20:45 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 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 SystemTap has some macros that can cause long strings to be generated. See: http://sourceware.org/bugzilla/show_bug.cgi?id=12137 The usual system header exception does not suppress the overlength-string warning here because the string results from a macro expansion. While Dodji's pending patch series promises to be able to fix this, it seemed to me that __extension__ should also be able to do this directly. This patch changes the C parser to suppress the -Woverlength-strings warning when the string is preceded by __extension__. Built and regtested on x86-64 (compile farm). New tests included. Ok? If approved, I assume I need to wait for stage 1 to commit this. Tom 2011-01-18 Tom Tromey * c-parser.c (disable_extension_diagnostics): Save warn_overlength_strings. (restore_extension_diagnostics): Restore warn_overlength_strings. 2011-01-18 Tom Tromey * gcc.dg/Woverlength-strings-pedantic-c89-ext.c: New file. * gcc.dg/Woverlength-strings-pedantic-c90-ext.c: New file. * gcc.dg/Woverlength-strings-pedantic-c99-ext.c: New file. Index: c-parser.c =================================================================== --- c-parser.c (revision 168933) +++ c-parser.c (working copy) @@ -1045,13 +1045,15 @@ | (warn_traditional << 2) | (flag_iso << 3) | (warn_long_long << 4) - | (warn_cxx_compat << 5)); + | (warn_cxx_compat << 5) + | (warn_overlength_strings << 6)); cpp_opts->cpp_pedantic = pedantic = 0; warn_pointer_arith = 0; cpp_opts->cpp_warn_traditional = warn_traditional = 0; flag_iso = 0; cpp_opts->cpp_warn_long_long = warn_long_long = 0; warn_cxx_compat = 0; + warn_overlength_strings = 0; return ret; } @@ -1067,6 +1069,7 @@ flag_iso = (flags >> 3) & 1; cpp_opts->cpp_warn_long_long = warn_long_long = (flags >> 4) & 1; warn_cxx_compat = (flags >> 5) & 1; + warn_overlength_strings = (flags >> 6) & 1; } /* Possibly kinds of declarator to parse. */ Index: testsuite/gcc.dg/Woverlength-strings-pedantic-c89-ext.c =================================================================== --- testsuite/gcc.dg/Woverlength-strings-pedantic-c89-ext.c (revision 0) +++ testsuite/gcc.dg/Woverlength-strings-pedantic-c89-ext.c (revision 0) @@ -0,0 +1,19 @@ +/* -Woverlength-strings complains about string constants which are too long + for the C standard's "minimum maximum" limits. It is off by default, + but implied by -pedantic. */ + +/* { dg-options "-std=c89 -pedantic" } */ + +#define TEN "xxxxxxxxxx" +#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN +#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN + +/* C89's minimum-maximum is 509. */ +const char x510[] = __extension__ HUN HUN HUN HUN HUN TEN; + +/* C99's minimum-maximum is 4095. */ +const char x4096[] = __extension__ + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456"; Index: testsuite/gcc.dg/Woverlength-strings-pedantic-c90-ext.c =================================================================== --- testsuite/gcc.dg/Woverlength-strings-pedantic-c90-ext.c (revision 0) +++ testsuite/gcc.dg/Woverlength-strings-pedantic-c90-ext.c (revision 0) @@ -0,0 +1,19 @@ +/* -Woverlength-strings complains about string constants which are too long + for the C standard's "minimum maximum" limits. It is off by default, + but implied by -pedantic. */ + +/* { dg-options "-std=c90 -pedantic" } */ + +#define TEN "xxxxxxxxxx" +#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN +#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN + +/* C89's minimum-maximum is 509. */ +const char x510[] = __extension__ HUN HUN HUN HUN HUN TEN; + +/* C99's minimum-maximum is 4095. */ +const char x4096[] = __extension__ + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456"; Index: testsuite/gcc.dg/Woverlength-strings-pedantic-c99-ext.c =================================================================== --- testsuite/gcc.dg/Woverlength-strings-pedantic-c99-ext.c (revision 0) +++ testsuite/gcc.dg/Woverlength-strings-pedantic-c99-ext.c (revision 0) @@ -0,0 +1,19 @@ +/* -Woverlength-strings complains about string constants which are too long + for the C standard's "minimum maximum" limits. It is off by default, + but implied by -pedantic. */ + +/* { dg-options "-std=c99 -pedantic" } */ + +#define TEN "xxxxxxxxxx" +#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN +#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN + +/* C89's minimum-maximum is 509. */ +const char x510[] = HUN HUN HUN HUN HUN TEN; + +/* C99's minimum-maximum is 4095. */ +const char x4096[] = __extension__ + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456";