From patchwork Wed Feb 2 20:04:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 81528 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 AD6A0B7101 for ; Thu, 3 Feb 2011 07:04:23 +1100 (EST) Received: (qmail 13480 invoked by alias); 2 Feb 2011 20:04:21 -0000 Received: (qmail 13472 invoked by uid 22791); 2 Feb 2011 20:04:19 -0000 X-SWARE-Spam-Status: No, hits=-6.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, 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; Wed, 02 Feb 2011 20:04:14 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p12K4D3J012901 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 2 Feb 2011 15:04:13 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p12K4CRX018896; Wed, 2 Feb 2011 15:04:13 -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 p12K4Bev011154; Wed, 2 Feb 2011 15:04:12 -0500 Received: by opsy.redhat.com (Postfix, from userid 500) id AA2FA3783AD; Wed, 2 Feb 2011 13:04:11 -0700 (MST) From: Tom Tromey To: gcc-patches@gcc.gnu.org Subject: Patch: suppress -Woverlength-strings in asm() Date: Wed, 02 Feb 2011 13:04:11 -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 This is a supplement to my previous patch to allow __extension__ to suppress -Woverlength-strings. This patch changes `asm' to disable -Woverlength-strings implicitly. The rationale for this is that (1) asm is a gcc extension, so the pedantic rule need not apply, and (2) that __extension__ __asm__ may suppress too much. Jakub regtested this for me. New test cases included. Tom 2011-02-02 Tom Tromey * c-parser.c (c_parser_asm_string_literal): Clear warn_overlength_strings. 2011-02-02 Tom Tromey * gcc.dg/Woverlength-strings-pedantic-c90-asm.c: New file. * gcc.dg/Woverlength-strings-pedantic-c89-asm.c: New file. * gcc.dg/Woverlength-strings-pedantic-c99-asm.c: New file. diff --git a/gcc/c-parser.c b/gcc/c-parser.c index b0ef249..dd4c535 100644 --- a/gcc/c-parser.c +++ b/gcc/c-parser.c @@ -3264,6 +3264,8 @@ static tree c_parser_asm_string_literal (c_parser *parser) { tree str; + int save_flag = warn_overlength_strings; + warn_overlength_strings = 0; if (c_parser_next_token_is (parser, CPP_STRING)) { str = c_parser_peek_token (parser)->value; @@ -3281,6 +3283,7 @@ c_parser_asm_string_literal (c_parser *parser) c_parser_error (parser, "expected string literal"); str = NULL_TREE; } + warn_overlength_strings = save_flag; return str; } diff --git a/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c89-asm.c b/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c89-asm.c new file mode 100644 index 0000000..45373bc --- /dev/null +++ b/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c89-asm.c @@ -0,0 +1,47 @@ +/* -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 " " +#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. */ +__asm__ (HUN HUN HUN HUN HUN TEN); + +/* C99's minimum-maximum is 4095. */ +__asm__ ( + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456"); + +void +f (void) +{ + /* C89's minimum-maximum is 509. */ + __asm__ (HUN HUN HUN HUN HUN TEN); + __asm__ (HUN HUN HUN HUN HUN TEN : : ); + __asm__ goto (HUN HUN HUN HUN HUN TEN : : : : label); + + /* C99's minimum-maximum is 4095. */ + __asm__ ( + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456"); + __asm__ ( + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456" : : ); + __asm__ goto ( + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456" : : : : label); + + label: ; +} diff --git a/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c90-asm.c b/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c90-asm.c new file mode 100644 index 0000000..b5523bc --- /dev/null +++ b/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c90-asm.c @@ -0,0 +1,48 @@ +/* -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 " " +#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. */ +__asm__ (HUN HUN HUN HUN HUN TEN); + +/* C99's minimum-maximum is 4095. */ +__asm__ ( + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456"); + +void +f (void) +{ + /* C89's minimum-maximum is 509. */ + __asm__ (HUN HUN HUN HUN HUN TEN); + __asm__ (HUN HUN HUN HUN HUN TEN : :); + __asm__ goto (HUN HUN HUN HUN HUN TEN : : : : label); + + /* C99's minimum-maximum is 4095. */ + __asm__ ( + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456"); + __asm__ ( + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456" : :); + __asm__ goto ( + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456" : : : : label); + + label: ; +} + diff --git a/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c99-asm.c b/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c99-asm.c new file mode 100644 index 0000000..8840e38 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c99-asm.c @@ -0,0 +1,48 @@ +/* -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 " " +#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. */ +__asm__ (HUN HUN HUN HUN HUN TEN); + +/* C99's minimum-maximum is 4095. */ +__asm__ ( + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456"); + +void +f (void) +{ + /* C89's minimum-maximum is 509. */ + __asm__ (HUN HUN HUN HUN HUN TEN); + __asm__ (HUN HUN HUN HUN HUN TEN : :); + __asm__ goto (HUN HUN HUN HUN HUN TEN : : : : label); + + /* C99's minimum-maximum is 4095. */ + __asm__ ( + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456"); + __asm__ ( + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456" : :); + __asm__ goto ( + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456" : : : : label); + + label: ; +} +