diff options
author | Jason Merrill <jason@redhat.com> | 2015-05-09 20:47:12 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2015-05-09 20:47:12 -0400 |
commit | 129211bc889a6ea7109b4391a3640f42b7c050c6 (patch) | |
tree | abc6b9a35cdb67ca394fce8184e12cc975701e3b | |
parent | 381bf11ee990736088f97d64e10ed1a406b4e28a (diff) | |
download | gcc-129211bc889a6ea7109b4391a3640f42b7c050c6.zip gcc-129211bc889a6ea7109b4391a3640f42b7c050c6.tar.gz gcc-129211bc889a6ea7109b4391a3640f42b7c050c6.tar.bz2 |
c-common.h (enum cxx_dialect): Add cxx_unset.
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.
From-SVN: r222977
-rw-r--r-- | gcc/c-family/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/c-family/c-common.c | 4 | ||||
-rw-r--r-- | gcc/c-family/c-common.h | 1 | ||||
-rw-r--r-- | gcc/c-family/c-opts.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/lib/target-supports.exp | 45 |
6 files changed, 56 insertions, 10 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 9900643..568b2c6 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,5 +1,9 @@ 2015-05-09 Jason Merrill <jason@redhat.com> + * 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. + * 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-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/ChangeLog b/gcc/testsuite/ChangeLog index 53fd152..49b758e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2015-05-09 Jason Merrill <jason@redhat.com> + + * 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. + 2015-05-09 Marc Glisse <marc.glisse@inria.fr> PR tree-optimization/64454 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] |