From patchwork Sat Apr 27 06:59:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 240089 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 9CE6A2C00FD for ; Sat, 27 Apr 2013 17:07:27 +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:date :from:to:cc:subject:message-id:reply-to:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=aosFgZwKTyT1Mow7M oAJs3Nhyed2sBhyj+OzzyJ+0F6gIu7BK70kwCIDV5++R0oiEy4MbQDK+Tl7yg0EJ +HsvHAMAhKAy5wf6xq3urZ6n6zwuzH9av0l//vNbwqSjW/vKvE2dpPhOGLyAotA8 GhhYT0puGsvRE/XcIb7Pt3RFmM= 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:date :from:to:cc:subject:message-id:reply-to:references:mime-version :content-type:in-reply-to; s=default; bh=M2YmdqHVKIviANgjv9LBqSW gTnQ=; b=Bd3CYAlopFqsbqdYKJYi/J0SCkAlUBJThrynLwElGgGW7ZoDTFsce7b CConf3x47VthlPvoMEcJVe2cHTtLrzaJNFAbGL7GVX80cqka+OsersIbGq56DyQ3 TouZJP6bmTnKg3wOW4sNATSErNMZmoYIDEZyZBssMYiAUNTRbUNs= Received: (qmail 15654 invoked by alias); 27 Apr 2013 07:07:20 -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 15643 invoked by uid 89); 27 Apr 2013 07:07:20 -0000 X-Spam-SWARE-Status: No, score=-6.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Sat, 27 Apr 2013 07:07:18 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3R77Gb7020414 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 27 Apr 2013 03:07:16 -0400 Received: from zalov.cz (vpn-60-150.rdu2.redhat.com [10.10.60.150]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r3R77ExY032026 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 27 Apr 2013 03:07:15 -0400 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.cz (8.14.5/8.14.5) with ESMTP id r3R77CL3019659; Sat, 27 Apr 2013 09:07:13 +0200 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id r3R6xVlC019521; Sat, 27 Apr 2013 08:59:31 +0200 Date: Sat, 27 Apr 2013 08:59:31 +0200 From: Jakub Jelinek To: Ed Smith-Rowland <3dw4rd@verizon.net>, Jason Merrill Cc: gcc-patches Subject: Re: [wwwdocs] C++14 support for binary literals says Noinstead of Yes Message-ID: <20130427065931.GW28963@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <517B5C15.1090008@verizon.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <517B5C15.1090008@verizon.net> User-Agent: Mutt/1.5.21 (2010-09-15) On Sat, Apr 27, 2013 at 01:03:17AM -0400, Ed Smith-Rowland wrote: > In htdocs/projects/cxx1y.html it says no for support of binary > literals. I think that's a Yes actually. > > Here is a little patchlet. > > Am I missing something? Given ./xg++ -B ./ a.C -std=c++1y -pedantic-errors -S a.C:1:9: error: binary constants are a GCC extension int i = 0b110101; ^ I'd say the fact that it is available as a GNU extension isn't sufficient to mark this as supported. I think you need something like (untested so far except for make check-g++ RUNTESTFLAGS=*binary_const*): 2013-04-27 Jakub Jelinek N3472 binary constants * include/cpplib.h (struct cpp_options): Fix a typo in user_literals field comment. Add binary_constants field. * init.c (struct lang_flags): Add binary_constants field. (lang_defaults): Add bin_cst column to the table. (cpp_set_lang): Initialize CPP_OPTION (pfile, binary_constants). * expr.c (cpp_classify_number): Talk about C++11 instead of C++0x in diagnostics. Accept binary constants if CPP_OPTION (pfile, binary_constants) even when pedantic. Adjust pedwarn message. * g++.dg/cpp/limits.C: Adjust warning wording. * g++.dg/system-binary-constants-1.C: Likewise. * g++.dg/cpp1y/system-binary-constants-1.C: New test. Jakub --- libcpp/include/cpplib.h.jj 2013-04-25 23:47:58.000000000 +0200 +++ libcpp/include/cpplib.h 2013-04-27 08:31:52.349122712 +0200 @@ -423,7 +423,7 @@ struct cpp_options /* True for traditional preprocessing. */ unsigned char traditional; - /* Nonzero for C++ 2011 Standard user-defnied literals. */ + /* Nonzero for C++ 2011 Standard user-defined literals. */ unsigned char user_literals; /* Nonzero means warn when a string or character literal is followed by a @@ -434,6 +434,9 @@ struct cpp_options literal number suffixes as user-defined literal number suffixes. */ unsigned char ext_numeric_literals; + /* Nonzero for C++ 2014 Standard binary constants. */ + unsigned char binary_constants; + /* Holds the name of the target (execution) character set. */ const char *narrow_charset; --- libcpp/init.c.jj 2013-04-25 23:47:58.000000000 +0200 +++ libcpp/init.c 2013-04-27 08:34:54.103120530 +0200 @@ -83,24 +83,25 @@ struct lang_flags char uliterals; char rliterals; char user_literals; + char binary_constants; }; static const struct lang_flags lang_defaults[] = -{ /* c99 c++ xnum xid std // digr ulit rlit user_literals */ - /* GNUC89 */ { 0, 0, 1, 0, 0, 1, 1, 0, 0, 0 }, - /* GNUC99 */ { 1, 0, 1, 0, 0, 1, 1, 1, 1, 0 }, - /* GNUC11 */ { 1, 0, 1, 0, 0, 1, 1, 1, 1, 0 }, - /* STDC89 */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 }, - /* STDC94 */ { 0, 0, 0, 0, 1, 0, 1, 0, 0, 0 }, - /* STDC99 */ { 1, 0, 1, 0, 1, 1, 1, 0, 0, 0 }, - /* STDC11 */ { 1, 0, 1, 0, 1, 1, 1, 1, 0, 0 }, - /* GNUCXX */ { 0, 1, 1, 0, 0, 1, 1, 0, 0, 0 }, - /* CXX98 */ { 0, 1, 1, 0, 1, 1, 1, 0, 0, 0 }, - /* GNUCXX11 */ { 1, 1, 1, 0, 0, 1, 1, 1, 1, 1 }, - /* CXX11 */ { 1, 1, 1, 0, 1, 1, 1, 1, 1, 1 }, - /* GNUCXX1Y */ { 1, 1, 1, 0, 0, 1, 1, 1, 1, 1 }, - /* CXX1Y */ { 1, 1, 1, 0, 1, 1, 1, 1, 1, 1 }, - /* ASM */ { 0, 0, 1, 0, 0, 1, 0, 0, 0, 0 } +{ /* c99 c++ xnum xid std // digr ulit rlit udlit bin_cst */ + /* GNUC89 */ { 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0 }, + /* GNUC99 */ { 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0 }, + /* GNUC11 */ { 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0 }, + /* STDC89 */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 }, + /* STDC94 */ { 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0 }, + /* STDC99 */ { 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0 }, + /* STDC11 */ { 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0 }, + /* GNUCXX */ { 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0 }, + /* CXX98 */ { 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0 }, + /* GNUCXX11 */ { 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0 }, + /* CXX11 */ { 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0 }, + /* GNUCXX1Y */ { 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1 }, + /* CXX1Y */ { 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1 }, + /* ASM */ { 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0 } /* xid should be 1 for GNUC99, STDC99, GNUCXX, CXX98, GNUCXX11, CXX11, GNUCXX1Y, and CXX1Y when no longer experimental (when all uses of identifiers in the compiler have been audited for correct handling @@ -126,6 +127,7 @@ cpp_set_lang (cpp_reader *pfile, enum c_ CPP_OPTION (pfile, uliterals) = l->uliterals; CPP_OPTION (pfile, rliterals) = l->rliterals; CPP_OPTION (pfile, user_literals) = l->user_literals; + CPP_OPTION (pfile, binary_constants) = l->binary_constants; } /* Initialize library global state. */ --- libcpp/expr.c.jj 2013-01-15 09:04:55.000000000 +0100 +++ libcpp/expr.c 2013-04-27 08:38:14.453026746 +0200 @@ -621,7 +621,7 @@ cpp_classify_number (cpp_reader *pfile, && CPP_OPTION (pfile, cpp_warn_long_long)) { const char *message = CPP_OPTION (pfile, cplusplus) - ? N_("use of C++0x long long integer constant") + ? N_("use of C++11 long long integer constant") : N_("use of C99 long long integer constant"); if (CPP_OPTION (pfile, c99)) @@ -639,9 +639,14 @@ cpp_classify_number (cpp_reader *pfile, if ((result & CPP_N_IMAGINARY) && CPP_PEDANTIC (pfile)) cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0, "imaginary constants are a GCC extension"); - if (radix == 2 && CPP_PEDANTIC (pfile)) + if (radix == 2 + && !CPP_OPTION (pfile, binary_constants) + && CPP_PEDANTIC (pfile)) cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0, - "binary constants are a GCC extension"); + CPP_OPTION (pfile, cplusplus) + ? "binary constants are a C++1y feature " + "or GCC extension" + : "binary constants are a GCC extension"); if (radix == 10) result |= CPP_N_DECIMAL; --- gcc/testsuite/g++.dg/cpp/limits.C.jj 2012-06-06 20:35:54.000000000 +0200 +++ gcc/testsuite/g++.dg/cpp/limits.C 2013-04-27 08:45:20.036719569 +0200 @@ -4,13 +4,13 @@ #include // Compiling this with -pedantic was wrongly triggering this error: -// libstdc++-v3/include/limits:1269:45: warning : use of C++0x long long integer constant [-Wlong-long] +// libstdc++-v3/include/limits:1269:45: warning : use of C++11 long long integer constant [-Wlong-long] // min() _GLIBCXX_USE_NOEXCEPT { return -__LONG_LONG_MAX__ - 1; } // ^ -// libstdc++-v3/include/limits:1272:44: warning : use of C++0x long long integer constant [-Wlong-long] +// libstdc++-v3/include/limits:1272:44: warning : use of C++11 long long integer constant [-Wlong-long] // max() _GLIBCXX_USE_NOEXCEPT { return __LONG_LONG_MAX__; } // ^ -// libstdc++-v3/include/limits:1342:44: warning : use of C++0x long long integer constant [-Wlong-long] +// libstdc++-v3/include/limits:1342:44: warning : use of C++11 long long integer constant [-Wlong-long] // max() _GLIBCXX_USE_NOEXCEPT { return __LONG_LONG_MAX__ * 2ULL + 1 // ^ --- gcc/testsuite/g++.dg/system-binary-constants-1.C.jj 2012-05-17 08:40:34.000000000 +0200 +++ gcc/testsuite/g++.dg/system-binary-constants-1.C 2013-04-27 08:47:50.600834156 +0200 @@ -14,5 +14,5 @@ foo (void) warning. */ return 23; #endif - return 0b1101; /* { dg-warning "binary constants are a GCC extension" } */ + return 0b1101; /* { dg-warning "binary constants are a C..1y feature or GCC extension" } */ } --- gcc/testsuite/g++.dg/cpp1y/system-binary-constants-1.C.jj 2013-04-27 08:43:44.084238188 +0200 +++ gcc/testsuite/g++.dg/cpp1y/system-binary-constants-1.C 2013-04-27 08:52:35.687230081 +0200 @@ -0,0 +1,14 @@ +// Origin: Dodji Seketeli +// { dg-options "-std=c++1y -pedantic-errors" } +// { dg-do compile } + +#include "../system-binary-constants-1.h" + +int +foo (void) +{ +#if BINARY_INT_CONSTANT_IN_SYSTEM_HEADER + return 23; +#endif + return 0b1101; // { dg-bogus "binary constants are a C..1y feature or GCC extension" } +}