From patchwork Sun Mar 8 18:33:03 2015 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: 447813 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 B93B2140157 for ; Mon, 9 Mar 2015 05:33:30 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=p2Ta7vEX; dkim-adsp=none (unprotected policy); dkim-atps=neutral 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=U+8X+nqkwNY7FKuGoPVe+eeThaQtj4i4wyytR6/9+11t6J 3j3dtnQFAxRFU5I315Vsp17qcbh6X4NUapXQvoh/+sTV3f7ShAPt4ehNWm1QfIIZ OncMCIWebJH0rqVr5ilr8LRbL/EoHAK/3N6m7iUU4DuFcLJVDIKMEFpY3blvI= 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=SJDlfgYMya+sdVH4TlufwGwo4OE=; b=p2Ta7vEXWVZNy5CP4d52 n5bXQEYF7QTFj4o+NQQA8iYSBr5yZ5fiCQFGePiFYWVw1EG9SSveAdw4V2Sa4xjh 8i0rGTETVfawqpxiMZhmfvL+CReFVgFVLPM+EKnOOtm8dvG2mfW2wU8vV+QxgZBn srYiZdwQRfc/WekbiDjdXSA= Received: (qmail 112767 invoked by alias); 8 Mar 2015 18:33:23 -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 112755 invoked by uid 89); 8 Mar 2015 18:33:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: vms173009pub.verizon.net Received: from vms173009pub.verizon.net (HELO vms173009pub.verizon.net) (206.46.173.9) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sun, 08 Mar 2015 18:33:21 +0000 Received: from [192.168.1.3] ([71.244.154.245]) by vms173009.mailsrvcs.net (Oracle Communications Messaging Server 7.0.5.32.0 64bit (built Jul 16 2014)) with ESMTPA id <0NKW00KUAOV3SV70@vms173009.mailsrvcs.net> for gcc-patches@gcc.gnu.org; Sun, 08 Mar 2015 13:33:04 -0500 (CDT) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=e7Wxkht6 c=1 sm=1 tr=0 a=CGqIly+QJ6xYsK5laoxOPg==:117 a=XuYyiiJQKFMA:10 a=o1OHuDzbAAAA:8 a=oR5dmqMzAAAA:8 a=hTZS6uLwhHpx5LOQAS/v3KalXBI=:19 a=-9mUelKeXuEA:10 a=emO1SXQWCLwA:10 a=r77TgQKjGQsHNAKrUKIA:9 a=9iDbn-4jx3cA:10 a=cKsnjEOsciEA:10 a=gZbpxnkM3yUA:10 a=ObQViaurSDz0QnrbYZUA:9 a=QEXdDO2ut3YA:10 a=5ZwaShQKy28A:10 a=MNcD5PyRBEQA:10 a=D2QrpnhtEFwA:10 a=Vlvag_7ttcbxRk9nfJsA:9 a=BAHE0JW3TuIA:10 a=LaMkZWi3M0MA:10 a=RkLAVPlX_tQA:10 a=UfSvbLplxn0Xq9zEaLsA:9 Message-id: <54FC95DF.1000405@verizon.net> Date: Sun, 08 Mar 2015 14:33:03 -0400 From: Ed Smith-Rowland <3dw4rd@verizon.net> User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-version: 1.0 To: gcc-patches , =?UTF-8?B?RGFuaWVsIEtyw7xnbGVy?= , Jason Merrill , Paolo Carlini Subject: PR c++/64626 - C++14 single quote should not always be a digit separator Content-type: multipart/mixed; boundary=------------070006040006060008040200 I just look to see if a lexed number in libcpp ends in a '. If so, back up one character and let string processing handle it. I get one warning and one error for each instance but I'd rather not error when it should pass. Built and tests clean on x86_64-linux. OK? libcpp/ 2015-03-09 Edward Smith-Rowland <3dw4rd@verizon.net> PR c++/64626 * expr.c (parse_has_attribute): New function; (eval_token): Look for __has_attribute__ and route to parse_has_attribute. gcc/testsuite/ 2015-03-09 Edward Smith-Rowland <3dw4rd@verizon.net> PR c++/64626 g++.dg/cpp1y/pr64626.C: New. g++.dg/cpp1y/digit-sep-neg.C: Adjust errors and warnings. Index: libcpp/lex.c =================================================================== --- libcpp/lex.c (revision 221218) +++ libcpp/lex.c (working copy) @@ -1400,6 +1400,9 @@ NORMALIZE_STATE_UPDATE_IDNUM (nst, *cur); cur++; } + /* A number can't end with a digit separator. */ + if (DIGIT_SEP (cur[-1])) + --cur; pfile->buffer->cur = cur; } Index: gcc/testsuite/g++.dg/cpp1y/pr64626.C =================================================================== --- gcc/testsuite/g++.dg/cpp1y/pr64626.C (revision 0) +++ gcc/testsuite/g++.dg/cpp1y/pr64626.C (working copy) @@ -0,0 +1,20 @@ +// PR c++/64626 +// { dg-do compile { target c++14 } } + +#define STR(s) #s +int +main() +{ + int i = 1'2; + const char *s[3] + { + STR(1' '), + STR(..), + STR(%:%), + }; +} +#if 0 +1' ' +.. +%:% +#endif Index: gcc/testsuite/g++.dg/cpp1y/digit-sep-neg.C =================================================================== --- gcc/testsuite/g++.dg/cpp1y/digit-sep-neg.C (revision 221218) +++ gcc/testsuite/g++.dg/cpp1y/digit-sep-neg.C (working copy) @@ -10,7 +10,7 @@ i = 0004''000'000; // { dg-error "adjacent digit separators" } i = 0B1'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0; // OK i = 0b'0001'0000'0000'0000'0000'0000; // { dg-error "digit separator after base indicator" } - i = 0b0001'0000'0000'0000'0000'0000'; // { dg-error "digit separator outside digit sequence" } + i = 0b0001'0000'0000'0000'0000'0000'; // { dg-error "missing terminating" } unsigned u = 0b0001'0000'0000'0000'0000'0000'U; // { dg-error "digit separator outside digit sequence" } double d = 0.0; @@ -18,9 +18,15 @@ d = 1.'602'176'565e-19; // { dg-error "digit separator adjacent to decimal point" } d = 1.602''176'565e-19; // { dg-error "adjacent digit separators" } d = 1.602'176'565'e-19; // { dg-error "digit separator adjacent to exponent" } - d = 1.602'176'565e'-19; // { dg-error "digit separator adjacent to exponent" } + d = 1.602'176'565e'-19; // { dg-error "missing terminating" } d = 1.602'176'565e-'19; // { dg-error "digit separator adjacent to exponent" } d = 1.602'176'565e-1'9; // OK - d = 1.602'176'565e-19'; // { dg-error "digit separator outside digit sequence" } + d = 1.602'176'565e-19'; // { dg-error "missing terminating" } float f = 1.602'176'565e-19'F; // { dg-error "digit separator outside digit sequence" } } + +// { dg-warning "missing terminating" { target *-*-* } 13 } + +// { dg-warning "missing terminating" { target *-*-* } 21 } + +// { dg-warning "missing terminating" { target *-*-* } 24 }