From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29106 invoked by alias); 9 May 2015 21:54:52 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 29092 invoked by uid 89); 9 May 2015 21:54:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sat, 09 May 2015 21:54:50 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id E6D928E3C8 for ; Sat, 9 May 2015 21:54:47 +0000 (UTC) Received: from [10.3.112.2] ([10.3.112.2]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t49LsI7p006724 for ; Sat, 9 May 2015 17:54:32 -0400 Message-ID: <554E81E7.3000406@redhat.com> Date: Sat, 09 May 2015 21:54:00 -0000 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: gcc-patches List Subject: Re: PATCHes to help with C++11 bootstrap References: <554D8D79.9080502@redhat.com> In-Reply-To: <554D8D79.9080502@redhat.com> Content-Type: multipart/mixed; boundary="------------030901050503080801090206" X-SW-Source: 2015-05/txt/msg00834.txt.bz2 This is a multi-part message in MIME format. --------------030901050503080801090206 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 214 More patches: The first makes changing the default just a matter of changing two lines (in the compiler and testsuite). The second patch is a minor tidy of c.opt. Tested x86_64-pc-linux-gnu, applying to trunk. --------------030901050503080801090206 Content-Type: text/x-patch; name="default-set.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="default-set.patch" Content-length: 5188 commit 8c9891a3828dc6a4c91998b2437ef9fbf8659163 Author: Jason Merrill Date: Fri May 8 17:01:37 2015 -0500 gcc/c-family/ * c-common.h (enum cxx_dialect): Add cxx_unset. * c-common.c (cxx_dialect): Initialize to cxx_unset. * c-opts.c (c_common_post_options): Set C++ dialect to C++98 if unset. gcc/testsuite/ * lib/target-supports.exp (cxx_default): New global. (check_effective_target_c++11_only) (check_effective_target_c++14_only) (check_effective_target_c++98_only) (check_effective_target_c++1z_only): Check it. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 378f237..93b3060 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -256,9 +256,9 @@ const char *constant_string_class_name; int flag_use_repository; -/* The C++ dialect being used. C++98 is the default. */ +/* The C++ dialect being used. Default set in c_common_post_options. */ -enum cxx_dialect cxx_dialect = cxx98; +enum cxx_dialect cxx_dialect = cxx_unset; /* Maximum template instantiation depth. This limit exists to limit the time it takes to notice excessively recursive template instantiations. diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 603d3f0..5c1fa7b 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -671,6 +671,7 @@ extern int flag_use_repository; /* The supported C++ dialects. */ enum cxx_dialect { + cxx_unset, /* C++98 with TC1 */ cxx98, cxx03 = cxx98, diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 8b17674..bd99871 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -896,6 +896,10 @@ c_common_post_options (const char **pfilename) if (flag_abi_version == 0) flag_abi_version = 8; + /* Set C++ standard to C++98 if not specified on the command line. */ + if (c_dialect_cxx () && cxx_dialect == cxx_unset) + set_std_cxx98 (/*ISO*/false); + if (cxx_dialect >= cxx11) { /* If we're allowing C++0x constructs, don't warn about C++98 diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index d68b48b..3728927 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -5892,15 +5892,23 @@ proc check_effective_target_c++ { } { return 0 } +set cxx_default "c++98" # Check whether the current active language standard supports the features -# of C++11/C++14 by checking for the presence of one of the -std -# flags. This assumes that the default for the compiler is C++98, and that +# of C++11/C++14 by checking for the presence of one of the -std flags. +# This assumes that the default for the compiler is $cxx_default, and that # there will never be multiple -std= arguments on the command line. proc check_effective_target_c++11_only { } { + global cxx_default if ![check_effective_target_c++] { return 0 } - return [check-flags { { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 } }] + if [check-flags { { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 } }] { + return 1 + } + if { $cxx_default == "c++11" && [check-flags { { } { } { } { -std=* } }] } { + return 1 + } + return 0 } proc check_effective_target_c++11 { } { if [check_effective_target_c++11_only] { @@ -5912,14 +5920,21 @@ proc check_effective_target_c++11_down { } { if ![check_effective_target_c++] { return 0 } - return ![check_effective_target_c++14] + return [expr ![check_effective_target_c++14] ] } proc check_effective_target_c++14_only { } { + global cxx_default if ![check_effective_target_c++] { return 0 } - return [check-flags { { } { } { -std=c++14 -std=gnu++14 -std=c++14 -std=gnu++14 } }] + if [check-flags { { } { } { -std=c++14 -std=gnu++14 -std=c++14 -std=gnu++14 } }] { + return 1 + } + if { $cxx_default == "c++14" && [check-flags { { } { } { } { -std=* } }] } { + return 1 + } + return 0 } proc check_effective_target_c++14 { } { @@ -5932,21 +5947,35 @@ proc check_effective_target_c++14_down { } { if ![check_effective_target_c++] { return 0 } - return ![check_effective_target_c++1z] + return [expr ![check_effective_target_c++1z] ] } proc check_effective_target_c++98_only { } { + global cxx_default if ![check_effective_target_c++] { return 0 } - return ![check_effective_target_c++11] + if [check-flags { { } { } { -std=c++98 -std=gnu++98 -std=c++03 -std=gnu++03 } }] { + return 1 + } + if { $cxx_default == "c++98" && [check-flags { { } { } { } { -std=* } }] } { + return 1 + } + return 0 } proc check_effective_target_c++1z_only { } { + global cxx_default if ![check_effective_target_c++] { return 0 } - return [check-flags { { } { } { -std=c++1z -std=gnu++1z } }] + if [check-flags { { } { } { -std=c++17 -std=gnu++17 -std=c++1z -std=gnu++1z } }] { + return 1 + } + if { $cxx_default == "c++17" && [check-flags { { } { } { } { -std=* } }] } { + return 1 + } + return 0 } proc check_effective_target_c++1z { } { return [check_effective_target_c++1z_only] --------------030901050503080801090206 Content-Type: text/x-patch; name="opts-cleanup.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="opts-cleanup.patch" Content-length: 1093 commit 286834b6ec25e2b8587cf6481b8d99ab85cb845d Author: Jason Merrill Date: Sat May 9 00:07:08 2015 -0500 * c.opt (std=c++14): Remove Undocumented flag and experimental warning. (std=gnu++0x): Mark as Undocumented. (std=gnu++1y): Add deprecated message. diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index e244a6d..343a599 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -1591,8 +1591,8 @@ C++ ObjC++ Alias(std=c++14) Undocumented Deprecated in favor of -std=c++14 std=c++14 -C++ ObjC++ Undocumented -Conform to the ISO 2014 C++ standard (experimental and incomplete support) +C++ ObjC++ +Conform to the ISO 2014 C++ standard std=c++1z C++ ObjC++ @@ -1640,11 +1640,12 @@ C++ ObjC++ Conform to the ISO 2011 C++ standard with GNU extensions (experimental and incomplete support) std=gnu++0x -C++ ObjC++ Alias(std=gnu++11) +C++ ObjC++ Alias(std=gnu++11) Undocumented Deprecated in favor of -std=gnu++11 std=gnu++1y C++ ObjC++ Alias(std=gnu++14) Undocumented +Deprecated in favor of -std=gnu++14 std=gnu++14 C++ ObjC++ --------------030901050503080801090206--