From patchwork Wed Mar 21 05:07:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 147911 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 E360FB6EE7 for ; Wed, 21 Mar 2012 16:08:01 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1332911282; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=nL15EsX m9f5kXdmfr2/Z2Mv3i48=; b=QXfiMULpmW7Tz/ORjv0GzSZ0jiXSyHGA9Sw2krE uCfDuiBpEY6PYdaUy/Y0CsgMikxrauco4NBISEfuOkpNzKhcRooWGE8oyHDwMkqG mzOTnFwH5WzEvmf82fghkXQM/v5he97hj1AWtDNOpEf+oNlrMEQO8BxvQsgVhcS8 fa6c= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=PfzzvBiTcIvVfiuHrJZrwW6fn/On2llF5f64DMT+9+GRCEXAn6BVrqGvN/2VkY 4pcJzv9/cbrfB80hJp7xXjOChpTgxQESN1syX08C+XUaxEnjqexZkeCX3eLn5QyR cZ0hTC278u/pPp2OHq74shhCzOwzYVdlfQL3zFbV06FR8=; Received: (qmail 24225 invoked by alias); 21 Mar 2012 05:07:56 -0000 Received: (qmail 24094 invoked by uid 22791); 21 Mar 2012 05:07:53 -0000 X-SWARE-Spam-Status: No, hits=-6.6 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; Wed, 21 Mar 2012 05:07:25 +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.14.4/8.14.4) with ESMTP id q2L57O3N020937 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 21 Mar 2012 01:07:24 -0400 Received: from [10.3.113.2] ([10.3.113.2]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q2L57NFr007046 for ; Wed, 21 Mar 2012 01:07:24 -0400 Message-ID: <4F69620B.4050400@redhat.com> Date: Wed, 21 Mar 2012 01:07:23 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.1) Gecko/20120216 Thunderbird/10.0.1 MIME-Version: 1.0 To: gcc-patches List Subject: PATCH to add -std=c++1y 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 I've been working on a proposal for return type deduction for normal functions for the next C++ standard, and so I'm adding -std=c++1y to control it. Tested x86_64-pc-linux-gnu, applying to trunk. commit ef9ed182fec9249e396fdb0ed2bd0cc4d725e956 Author: Jason Merrill Date: Sat Mar 3 10:04:22 2012 -0500 * c-common.h (enum cxx_dialect): Add cxx1y. * c-common.c (c_common_nodes_and_builtins): Use >= for cxx_dialect test. * c-cppbuiltin.c (c_cpp_builtins): Likewise. * c-opts.c (c_common_post_options): Likewise. (set_std_cxx1y): New. (c_common_handle_option): Call it. * c.opt (-std=c++1y, -std=gnu++1y): New flags. cp/ * lex.c (init_reswords): Use >= for cxx_dialect test. * parser.c (cp_parser_exception_specification_opt): Likewise. testsuite/ * lib/target-supports.exp: Add { target c++1y }. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index b83f45b..fc83b04 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -4940,7 +4940,7 @@ c_common_nodes_and_builtins (void) { char16_type_node = make_unsigned_type (char16_type_size); - if (cxx_dialect == cxx0x) + if (cxx_dialect >= cxx0x) record_builtin_type (RID_CHAR16, "char16_t", char16_type_node); } @@ -4956,7 +4956,7 @@ c_common_nodes_and_builtins (void) { char32_type_node = make_unsigned_type (char32_type_size); - if (cxx_dialect == cxx0x) + if (cxx_dialect >= cxx0x) record_builtin_type (RID_CHAR32, "char32_t", char32_type_node); } diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 835b13b..8552f0c 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -649,7 +649,9 @@ enum cxx_dialect { cxx03 = cxx98, /* C++11 */ cxx0x, - cxx11 = cxx0x + cxx11 = cxx0x, + /* C++1y (C++17?) */ + cxx1y }; /* The C++ dialect being used. C++98 is the default. */ diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c index 40a0a62..49804f9 100644 --- a/gcc/c-family/c-cppbuiltin.c +++ b/gcc/c-family/c-cppbuiltin.c @@ -714,7 +714,7 @@ c_cpp_builtins (cpp_reader *pfile) cpp_define (pfile, "__DEPRECATED"); if (flag_rtti) cpp_define (pfile, "__GXX_RTTI"); - if (cxx_dialect == cxx0x) + if (cxx_dialect >= cxx0x) cpp_define (pfile, "__GXX_EXPERIMENTAL_CXX0X__"); } /* Note that we define this for C as well, so that we know if diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index f2a7971..0ee4390 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -111,6 +111,7 @@ static size_t include_cursor; static void handle_OPT_d (const char *); static void set_std_cxx98 (int); static void set_std_cxx11 (int); +static void set_std_cxx1y (int); static void set_std_c89 (int, int); static void set_std_c99 (int); static void set_std_c11 (int); @@ -774,6 +775,12 @@ c_common_handle_option (size_t scode, const char *arg, int value, set_std_cxx11 (code == OPT_std_c__11 /* ISO */); break; + case OPT_std_c__1y: + case OPT_std_gnu__1y: + if (!preprocessing_asm_p) + set_std_cxx1y (code == OPT_std_c__11 /* ISO */); + break; + case OPT_std_c90: case OPT_std_iso9899_199409: if (!preprocessing_asm_p) @@ -990,7 +997,7 @@ c_common_post_options (const char **pfilename) if (warn_implicit_function_declaration == -1) warn_implicit_function_declaration = flag_isoc99; - if (cxx_dialect == cxx0x) + if (cxx_dialect >= cxx0x) { /* If we're allowing C++0x constructs, don't warn about C++98 identifiers which are keywords in C++0x. */ @@ -1522,6 +1529,20 @@ set_std_cxx11 (int iso) cxx_dialect = cxx11; } +/* Set the C++ 201y draft standard (without GNU extensions if ISO). */ +static void +set_std_cxx1y (int iso) +{ + cpp_set_lang (parse_in, iso ? CLK_CXX11: CLK_GNUCXX11); + flag_no_gnu_keywords = iso; + flag_no_nonansi_builtin = iso; + flag_iso = iso; + /* C++11 includes the C99 standard library. */ + flag_isoc94 = 1; + flag_isoc99 = 1; + cxx_dialect = cxx1y; +} + /* Args to -d specify what to dump. Silently ignore unrecognized options; they may be aimed at toplev.c. */ static void diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 1ec5504..f785b60 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -1215,6 +1215,10 @@ std=c++0x C++ ObjC++ Alias(std=c++11) Deprecated in favor of -std=c++11 +std=c++1y +C++ ObjC++ +Conform to the ISO 201y(7?) C++ draft standard (experimental and incomplete support) + std=c11 C ObjC Conform to the ISO 2011 C standard (experimental and incomplete support) @@ -1257,6 +1261,10 @@ std=gnu++0x C++ ObjC++ Alias(std=gnu++11) Deprecated in favor of -std=gnu++11 +std=gnu++1y +C++ ObjC++ +Conform to the ISO 201y(7?) C++ draft standard with GNU extensions (experimental and incomplete support) + std=gnu11 C ObjC Conform to the ISO 2011 C standard with GNU extensions (experimental and incomplete support) diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index c11e3b3..a79448e 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -174,7 +174,7 @@ init_reswords (void) tree id; int mask = 0; - if (cxx_dialect != cxx0x) + if (cxx_dialect < cxx0x) mask |= D_CXX0X; if (flag_no_asm) mask |= D_ASM | D_EXT; diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index b3c87a8..75b7bdb 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -19594,7 +19594,7 @@ cp_parser_exception_specification_opt (cp_parser* parser) #if 0 /* Enable this once a lot of code has transitioned to noexcept? */ - if (cxx_dialect == cxx0x && !in_system_header) + if (cxx_dialect >= cxx0x && !in_system_header) warning (OPT_Wdeprecated, "dynamic exception specifications are " "deprecated in C++0x; use % instead"); #endif diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index c744cb9..aae37bc 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -1597,20 +1597,36 @@ GNU dialect of ISO C11. Support is incomplete and experimental. The name @samp{gnu1x} is deprecated. @item c++98 -The 1998 ISO C++ standard plus amendments. Same as @option{-ansi} for -C++ code. +@itemx c++03 +The 1998 ISO C++ standard plus the 2003 technical corrigendum and some +additional defect reports. Same as @option{-ansi} for C++ code. @item gnu++98 +@item gnu++03 GNU dialect of @option{-std=c++98}. This is the default for C++ code. @item c++11 +@item c++0x The 2011 ISO C++ standard plus amendments. Support for C++11 is still experimental, and may change in incompatible ways in future releases. +The name @samp{c++0x} is deprecated. @item gnu++11 +@item gnu++0x GNU dialect of @option{-std=c++11}. Support for C++11 is still experimental, and may change in incompatible ways in future releases. +The name @samp{gnu++0x} is deprecated. + +@item c++1y +The next revision of the ISO C++ standard, tentatively planned for +2017. Support is highly experimental, and will almost certainly +change in incompatible ways in future releases. + +@item gnu++1y +GNU dialect of @option{-std=c++1y}. Support is highly experimental, +and will almost certainly change in incompatible ways in future +releases. @end table @item -fgnu89-inline diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index b9a6601..23b6ea9 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -4431,11 +4431,18 @@ proc check_effective_target_c++11 { } { return [check-flags { { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 } }] } +proc check_effective_target_c++1y { } { + if ![check_effective_target_c++] { + return 0 + } + return [check-flags { { } { } { -std=c++1y -std=gnu++1y } }] +} + proc check_effective_target_c++98 { } { if ![check_effective_target_c++] { return 0 } - return [check-flags { { } { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 } }] + return [check-flags { { } { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 -std=c++1y -std=gnu++1y } }] } # Return 1 if expensive testcases should be run.