From patchwork Mon Jul 7 14:20:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ed Smith-Rowland <3dw4rd@verizon.net> X-Patchwork-Id: 367581 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 11C14140087 for ; Tue, 8 Jul 2014 00:20:43 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=pcvFOAf1D6ykwrsj4spwIk7Kr2pkIaThzJvMFzXlAum8n2 tQE1TVYdlmkUUvFsNxnjbqqHLpoK5UugWaomCq/85O+ierhbAqox52kki4IfoTw+ I+7Xey6mLb/oPvyyGsAU30N7BisFR5euPJ44haZVIwvY270oQXZzo+SJlWTQY= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=Pl2j8TxovJOq+wsoa3LKcM9jPDk=; b=y6/kWYfGe1NoDP+4i3Yg aT7EAWpbqgg6dYtTVDX5KBqvjeBHkymj0i48UmEAxZB6PHlvKtu8yYHFdaE6ggIY qUMApz1Lw3cI5uxsm3UtR4wgOEoqMnVowBLzMFK2Txd1/jrR2luxMekEfIdHOrzc dcYKpjzKwc1jkRbII0vU1/0= Received: (qmail 16306 invoked by alias); 7 Jul 2014 14:20:36 -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 16276 invoked by uid 89); 7 Jul 2014 14:20:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: vms173001pub.verizon.net Received: from vms173001pub.verizon.net (HELO vms173001pub.verizon.net) (206.46.173.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 07 Jul 2014 14:20:31 +0000 Received: from [192.168.1.4] ([unknown] [173.69.187.216]) by vms173001.mailsrvcs.net (Sun Java(tm) System Messaging Server 7u2-7.02 32bit (built Apr 16 2009)) with ESMTPA id <0N8C002Q6IHNSB90@vms173001.mailsrvcs.net> for gcc-patches@gcc.gnu.org; Mon, 07 Jul 2014 09:20:11 -0500 (CDT) Message-id: <53BAAC9B.70305@verizon.net> Date: Mon, 07 Jul 2014 10:20:11 -0400 From: Ed Smith-Rowland <3dw4rd@verizon.net> User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-version: 1.0 To: gcc-patches , Jason Merrill Subject: [C++ Patch] PR 58155 - -Wliteral-suffix warns about tokens which are skipped Content-type: multipart/mixed; boundary=------------040206040202080107020806 This patch addresses an old issue of warning about macro touching string literal even if the code is skipped: #define BAZ "baz" #if 0 "bar"BAZ #endif Just skip the warning Wliteral-suffix if the preprocessor is skipping. Built and tested on x86_64-linux. OK? And for 4.9? Thanks, Ed Smith-Rowland libcpp/ 2014-07-07 Edward Smith-Rowland <3dw4rd@verizon.net> PR c++/58155 - -Wliteral-suffix warns about tokens which are skipped by preprocessor * lex.c (lex_raw_string ()): Do not warn about invalid suffix if skipping. (lex_string ()): Ditto. gcc/testsuite/ 2014-07-07 Edward Smith-Rowland <3dw4rd@verizon.net> PR c++/58155 - -Wliteral-suffix warns about tokens which are skipped g++.dg/cpp0x/pr58155.C: New. Index: libcpp/lex.c =================================================================== --- libcpp/lex.c (revision 212209) +++ libcpp/lex.c (working copy) @@ -1646,7 +1646,7 @@ if (is_macro (pfile, cur)) { /* Raise a warning, but do not consume subsequent tokens. */ - if (CPP_OPTION (pfile, warn_literal_suffix)) + if (CPP_OPTION (pfile, warn_literal_suffix) && !pfile->state.skipping) cpp_warning_with_line (pfile, CPP_W_LITERAL_SUFFIX, token->src_loc, 0, "invalid suffix on literal; C++11 requires " @@ -1775,7 +1775,7 @@ if (is_macro (pfile, cur)) { /* Raise a warning, but do not consume subsequent tokens. */ - if (CPP_OPTION (pfile, warn_literal_suffix)) + if (CPP_OPTION (pfile, warn_literal_suffix) && !pfile->state.skipping) cpp_warning_with_line (pfile, CPP_W_LITERAL_SUFFIX, token->src_loc, 0, "invalid suffix on literal; C++11 requires " Index: gcc/testsuite/g++.dg/cpp0x/pr58155.C =================================================================== --- gcc/testsuite/g++.dg/cpp0x/pr58155.C (revision 0) +++ gcc/testsuite/g++.dg/cpp0x/pr58155.C (revision 0) @@ -0,0 +1,13 @@ +// { dg-do compile { target c++11 } } + +#define BAZ "baz" + +#if 0 + +"bar"BAZ + +R"( + bar +)"BAZ + +#endif