* c-common.h (cxx_dialect): Add cxx2a as a dialect.
* opt.c: Add options for -std=c++2a and -std=gnu++2a.
* c-opts.c (set_std_cxx2a): New.
(c_common_handle_option): Set options when -std=c++2a is enabled.
(c_common_post_options): Adjust comments.
(set_std_cxx14, set_std_cxx17): Likewise.
* doc/cpp.texi (__cplusplus): Document value for -std=c++2a
or -std=gnu+2a.
* doc/invoke.texi: Document -std=c++2a and -std=gnu++2a.
* lib/target-supports.exp (check_effective_target_c++17): Return
1 also if check_effective_target_c++2a.
(check_effective_target_c++17_down): New.
(check_effective_target_c++2a_only): New.
(check_effective_target_c++2a): New.
* g++.dg/cpp2a/cplusplus.C: New.
* include/cpplib.h (c_lang): Add CXX2A and GNUCXX2A.
* init.c (lang_defaults): Add rows for CXX2A and GNUCXX2A.
(cpp_init_builtins): Set __cplusplus to 201709L for C++2a.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r252850
+2017-09-15 Andrew Sutton <andrew.n.sutton@gmail.com>
+ Jakub Jelinek <jakub@redhat.com>
+
+ Add support for -std=c++2a.
+ * doc/cpp.texi (__cplusplus): Document value for -std=c++2a
+ or -std=gnu+2a.
+ * doc/invoke.texi: Document -std=c++2a and -std=gnu++2a.
+
2017-09-15 Steve Ellcey <sellcey@cavium.com>
PR target/82066
+2017-09-15 Andrew Sutton <andrew.n.sutton@gmail.com>
+ Jakub Jelinek <jakub@redhat.com>
+
+ Add support for -std=c++2a.
+ * c-common.h (cxx_dialect): Add cxx2a as a dialect.
+ * opt.c: Add options for -std=c++2a and -std=gnu++2a.
+ * c-opts.c (set_std_cxx2a): New.
+ (c_common_handle_option): Set options when -std=c++2a is enabled.
+ (c_common_post_options): Adjust comments.
+ (set_std_cxx14, set_std_cxx17): Likewise.
+
2017-09-15 Eric Botcazou <ebotcazou@adacore.com>
* c-pragma.c (handle_pragma_scalar_storage_order): Expand on error
/* C++14 */
cxx14,
/* C++17 */
- cxx17
+ cxx17,
+ /* C++2a (C++20?) */
+ cxx2a
};
/* The C++ dialect being used. C++98 is the default. */
static void set_std_cxx11 (int);
static void set_std_cxx14 (int);
static void set_std_cxx17 (int);
+static void set_std_cxx2a (int);
static void set_std_c89 (int, int);
static void set_std_c99 (int);
static void set_std_c11 (int);
set_std_cxx17 (code == OPT_std_c__17 /* ISO */);
break;
+ case OPT_std_c__2a:
+ case OPT_std_gnu__2a:
+ if (!preprocessing_asm_p)
+ set_std_cxx2a (code == OPT_std_c__2a /* ISO */);
+ break;
+
case OPT_std_c90:
case OPT_std_iso9899_199409:
if (!preprocessing_asm_p)
warn_narrowing = 1;
/* Unless -f{,no-}ext-numeric-literals has been used explicitly,
- for -std=c++{11,14,17} default to -fno-ext-numeric-literals. */
+ for -std=c++{11,14,17,2a} default to -fno-ext-numeric-literals. */
if (flag_iso && !global_options_set.x_flag_ext_numeric_literals)
cpp_opts->ext_numeric_literals = 0;
}
flag_no_gnu_keywords = iso;
flag_no_nonansi_builtin = iso;
flag_iso = iso;
- /* C++11 includes the C99 standard library. */
+ /* C++14 includes the C99 standard library. */
flag_isoc94 = 1;
flag_isoc99 = 1;
cxx_dialect = cxx14;
flag_no_gnu_keywords = iso;
flag_no_nonansi_builtin = iso;
flag_iso = iso;
- /* C++11 includes the C99 standard library. */
+ /* C++17 includes the C11 standard library. */
flag_isoc94 = 1;
flag_isoc99 = 1;
flag_isoc11 = 1;
lang_hooks.name = "GNU C++17";
}
+/* Set the C++ 202a draft standard (without GNU extensions if ISO). */
+static void
+set_std_cxx2a (int iso)
+{
+ cpp_set_lang (parse_in, iso ? CLK_CXX2A: CLK_GNUCXX2A);
+ flag_no_gnu_keywords = iso;
+ flag_no_nonansi_builtin = iso;
+ flag_iso = iso;
+ /* C++17 includes the C11 standard library. */
+ flag_isoc94 = 1;
+ flag_isoc99 = 1;
+ flag_isoc11 = 1;
+ cxx_dialect = cxx2a;
+ lang_hooks.name = "GNU C++17"; /* Pretend C++17 until standardization. */
+}
+
/* Args to -d specify what to dump. Silently ignore
unrecognized options; they may be aimed at toplev.c. */
static void
C++ ObjC++
Conform to the ISO 2017 C++ standard.
+std=c++2a
+C++ ObjC++
+Conform to the ISO 2020(?) C++ draft standard (experimental and incomplete support).
+
std=c11
C ObjC
Conform to the ISO 2011 C standard.
C++ ObjC++
Conform to the ISO 2017 C++ standard with GNU extensions.
+std=gnu++2a
+C++ ObjC++
+Conform to the ISO 2020(?) C++ draft standard with GNU extensions (experimental and incomplete support).
+
std=gnu11
C ObjC
Conform to the ISO 2011 C standard with GNU extensions.
@code{199711L} for the 1998 C++ standard,
@code{201103L} for the 2011 C++ standard,
@code{201402L} for the 2014 C++ standard,
-@code{201703L} for the 2017 C++ standard.
+@code{201703L} for the 2017 C++ standard,
+or an unspecified value strictly larger than @code{201703L} for the
+experimental languages enabled by @option{-std=c++2a} and
+@option{-std=gnu++2a}.
@item __OBJC__
This macro is defined, with value 1, when the Objective-C compiler is in
@itemx gnu++1z
GNU dialect of @option{-std=c++17}.
The name @samp{gnu++1z} is deprecated.
+
+@item c++2a
+The next revision of the ISO C++ standard, tentatively planned for
+2020. Support is highly experimental, and will almost certainly
+change in incompatible ways in future releases.
+
+@item gnu++2a
+GNU dialect of @option{-std=c++2a}. Support is highly experimental,
+and will almost certainly change in incompatible ways in future
+releases.
@end table
@item -fgnu89-inline
+2017-09-15 Andrew Sutton <andrew.n.sutton@gmail.com>
+ Jakub Jelinek <jakub@redhat.com>
+
+ Add support for -std=c++2a.
+ * lib/target-supports.exp (check_effective_target_c++17): Return
+ 1 also if check_effective_target_c++2a.
+ (check_effective_target_c++17_down): New.
+ (check_effective_target_c++2a_only): New.
+ (check_effective_target_c++2a): New.
+ * g++.dg/cpp2a/cplusplus.C: New.
+
2017-09-15 Joseph Myers <joseph@codesourcery.com>
PR c/82071
--- /dev/null
+// { dg-do compile }
+// { dg-options "-std=c++2a" }
+
+static_assert(__cplusplus > 201703L);
}
return 0
}
+
proc check_effective_target_c++17 { } {
- return [check_effective_target_c++17_only]
+ if [check_effective_target_c++17_only] {
+ return 1
+ }
+ return [check_effective_target_c++2a]
+}
+proc check_effective_target_c++17_down { } {
+ if ![check_effective_target_c++] {
+ return 0
+ }
+ return [expr ![check_effective_target_c++2a] ]
+}
+
+proc check_effective_target_c++2a_only { } {
+ global cxx_default
+ if ![check_effective_target_c++] {
+ return 0
+ }
+ if [check-flags { { } { } { -std=c++2a -std=gnu++2a } }] {
+ return 1
+ }
+ if { $cxx_default == "c++20" && [check-flags { { } { } { } { -std=* } }] } {
+ return 1
+ }
+ return 0
+}
+proc check_effective_target_c++2a { } {
+ return [check_effective_target_c++2a_only]
}
# Check for C++ Concepts TS support, i.e. -fconcepts flag.
+2017-09-15 Andrew Sutton <andrew.n.sutton@gmail.com>
+ Jakub Jelinek <jakub@redhat.com>
+
+ Add support for -std=c++2a.
+ * include/cpplib.h (c_lang): Add CXX2A and GNUCXX2A.
+ * init.c (lang_defaults): Add rows for CXX2A and GNUCXX2A.
+ (cpp_init_builtins): Set __cplusplus to 201709L for C++2a.
+
2017-09-15 Jakub Jelinek <jakub@redhat.com>
* include/cpplib.h (enum c_lang): Rename CLK_GNUCXX1Z
enum c_lang {CLK_GNUC89 = 0, CLK_GNUC99, CLK_GNUC11,
CLK_STDC89, CLK_STDC94, CLK_STDC99, CLK_STDC11,
CLK_GNUCXX, CLK_CXX98, CLK_GNUCXX11, CLK_CXX11,
- CLK_GNUCXX14, CLK_CXX14, CLK_GNUCXX17, CLK_CXX17, CLK_ASM};
+ CLK_GNUCXX14, CLK_CXX14, CLK_GNUCXX17, CLK_CXX17,
+ CLK_GNUCXX2A, CLK_CXX2A, CLK_ASM};
/* Payload of a NUMBER, STRING, CHAR or COMMENT token. */
struct GTY(()) cpp_string {
/* CXX14 */ { 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
/* GNUCXX17 */ { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1 },
/* CXX17 */ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1 },
+ /* GNUCXX2A */ { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1 },
+ /* CXX2A */ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1 },
/* ASM */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
if (CPP_OPTION (pfile, cplusplus))
{
- if (CPP_OPTION (pfile, lang) == CLK_CXX17
+ if (CPP_OPTION (pfile, lang) == CLK_CXX2A
+ || CPP_OPTION (pfile, lang) == CLK_GNUCXX2A)
+ _cpp_define_builtin (pfile, "__cplusplus 201709L");
+ else if (CPP_OPTION (pfile, lang) == CLK_CXX17
|| CPP_OPTION (pfile, lang) == CLK_GNUCXX17)
_cpp_define_builtin (pfile, "__cplusplus 201703L");
else if (CPP_OPTION (pfile, lang) == CLK_CXX14