@@ -536,6 +536,11 @@ const struct c_common_resword c_common_reswords[] =
{ "concept", RID_CONCEPT, D_CXX_CONCEPTS_FLAGS | D_CXXWARN },
{ "requires", RID_REQUIRES, D_CXX_CONCEPTS_FLAGS | D_CXXWARN },
+ /* Coroutines-related keywords */
+ { "co_await", RID_CO_AWAIT, D_CXX_COROUTINES_FLAGS | D_CXXWARN },
+ { "co_yield", RID_CO_YIELD, D_CXX_COROUTINES_FLAGS | D_CXXWARN },
+ { "co_return", RID_CO_RETURN, D_CXX_COROUTINES_FLAGS | D_CXXWARN },
+
/* These Objective-C keywords are recognized only immediately after
an '@'. */
{ "compatibility_alias", RID_AT_ALIAS, D_OBJC },
@@ -189,6 +189,9 @@ enum rid
/* C++ concepts */
RID_CONCEPT, RID_REQUIRES,
+ /* C++ coroutines */
+ RID_CO_AWAIT, RID_CO_YIELD, RID_CO_RETURN,
+
/* C++ transactional memory. */
RID_ATOMIC_NOEXCEPT, RID_ATOMIC_CANCEL, RID_SYNCHRONIZED,
@@ -433,9 +436,11 @@ extern machine_mode c_default_pointer_mode;
#define D_TRANSMEM 0X0800 /* C++ transactional memory TS. */
#define D_CXX_CHAR8_T 0X1000 /* In C++, only with -fchar8_t. */
#define D_CXX20 0x2000 /* In C++, C++20 only. */
+#define D_CXX_COROUTINES 0x4000 /* In C++, only with coroutines. */
#define D_CXX_CONCEPTS_FLAGS D_CXXONLY | D_CXX_CONCEPTS
#define D_CXX_CHAR8_T_FLAGS D_CXXONLY | D_CXX_CHAR8_T
+#define D_CXX_COROUTINES_FLAGS (D_CXXONLY | D_CXX_COROUTINES)
/* The reserved keyword table. */
extern const struct c_common_resword c_common_reswords[];
@@ -1000,6 +1000,8 @@ c_cpp_builtins (cpp_reader *pfile)
else
cpp_define (pfile, "__cpp_concepts=201507L");
}
+ if (flag_coroutines)
+ cpp_define (pfile, "__cpp_coroutines=201902L"); /* n4835, C++20 CD */
if (flag_tm)
/* Use a value smaller than the 201505 specified in
the TS, since we don't yet support atomic_cancel. */
@@ -1469,6 +1469,10 @@ fconstexpr-ops-limit=
C++ ObjC++ Joined RejectNegative Host_Wide_Int Var(constexpr_ops_limit) Init(33554432)
-fconstexpr-ops-limit=<number> Specify maximum number of constexpr operations during a single constexpr evaluation.
+fcoroutines
+C++ LTO Var(flag_coroutines)
+Enable C++ coroutines (experimental).
+
fdebug-cpp
C ObjC C++ ObjC++
Emit debug annotations during preprocessing.
@@ -2696,7 +2696,9 @@ struct GTY(()) lang_decl_fn {
unsigned has_dependent_explicit_spec_p : 1;
unsigned immediate_fn_p : 1;
unsigned maybe_deleted : 1;
- unsigned spare : 10;
+ unsigned coroutine_p : 1;
+
+ unsigned spare : 9;
/* 32-bits padding on 64-bit host. */
@@ -4982,6 +4984,13 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
#define QUALIFIED_NAME_IS_TEMPLATE(NODE) \
(TREE_LANG_FLAG_1 (SCOPE_REF_CHECK (NODE)))
+/* [coroutines]
+*/
+
+/* True if NODE is a co-routine FUNCTION_DECL. */
+#define DECL_COROUTINE_P(NODE) \
+ (LANG_DECL_FN_CHECK (DECL_COMMON_CHECK (NODE))->coroutine_p)
+
/* True for an OMP_ATOMIC that has dependent parameters. These are stored
as an expr in operand 1, and integer_zero_node or clauses in operand 0. */
#define OMP_ATOMIC_DEPENDENT_P(NODE) \
@@ -7892,6 +7901,12 @@ extern tree cp_ubsan_maybe_instrument_downcast (location_t, tree, tree, tree);
extern tree cp_ubsan_maybe_instrument_cast_to_vbase (location_t, tree, tree);
extern void cp_ubsan_maybe_initialize_vtbl_ptrs (tree);
+/* In coroutines.cc */
+extern tree finish_co_return_stmt (location_t, tree);
+extern tree finish_co_await_expr (location_t, tree);
+extern tree finish_co_yield_expr (location_t, tree);
+extern bool morph_fn_to_coro (tree, tree *, tree *);
+
/* Inline bodies. */
inline tree
@@ -233,6 +233,8 @@ init_reswords (void)
mask |= D_CXX20;
if (!flag_concepts)
mask |= D_CXX_CONCEPTS;
+ if (!flag_coroutines)
+ mask |= D_CXX_COROUTINES;
if (!flag_tm)
mask |= D_TRANSMEM;
if (!flag_char8_t)
@@ -87,6 +87,7 @@ DEF_OPERATOR ("++", PREINCREMENT_EXPR, "pp", OVL_OP_FLAG_UNARY)
DEF_OPERATOR ("--", PREDECREMENT_EXPR, "mm", OVL_OP_FLAG_UNARY)
DEF_OPERATOR ("->", COMPONENT_REF, "pt", OVL_OP_FLAG_UNARY)
DEF_OPERATOR ("sizeof", SIZEOF_EXPR, "sz", OVL_OP_FLAG_UNARY)
+DEF_OPERATOR ("co_await", CO_AWAIT_EXPR, "aw", OVL_OP_FLAG_UNARY)
/* These are extensions. */
DEF_OPERATOR ("alignof", ALIGNOF_EXPR, "az", OVL_OP_FLAG_UNARY)
@@ -2567,6 +2567,10 @@ of a loop too many expressions need to be evaluated, the resulting constexpr
evaluation might take too long.
The default is 33554432 (1<<25).
+@item -fcoroutines
+@opindex fcoroutines
+Enable support for the C++ coroutines extension (experimental).
+
@item -fno-elide-constructors
@opindex fno-elide-constructors
@opindex felide-constructors