]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/cp/cp-tree.h
Update copyright years.
[thirdparty/gcc.git] / gcc / cp / cp-tree.h
index 225dbb67c635ce214613173978a849bf58e5980d..495ed6b9f56e7c6ee7555055b0d327094c9aaa3d 100644 (file)
@@ -1,5 +1,5 @@
 /* Definitions for C++ parsing and type checking.
-   Copyright (C) 1987-2019 Free Software Foundation, Inc.
+   Copyright (C) 1987-2020 Free Software Foundation, Inc.
    Contributed by Michael Tiemann (tiemann@cygnus.com)
 
 This file is part of GCC.
@@ -149,7 +149,6 @@ enum cp_tree_index
     CPTI_PFN_IDENTIFIER,
     CPTI_VPTR_IDENTIFIER,
     CPTI_GLOBAL_IDENTIFIER,
-    CPTI_STD_IDENTIFIER,
     CPTI_ANON_IDENTIFIER,
     CPTI_AUTO_IDENTIFIER,
     CPTI_DECLTYPE_AUTO_IDENTIFIER,
@@ -172,6 +171,9 @@ enum cp_tree_index
     CPTI_VALUE_IDENTIFIER,
     CPTI_FUN_IDENTIFIER,
     CPTI_CLOSURE_IDENTIFIER,
+    CPTI_HEAP_UNINIT_IDENTIFIER,
+    CPTI_HEAP_IDENTIFIER,
+    CPTI_HEAP_DELETED_IDENTIFIER,
 
     CPTI_LANG_NAME_C,
     CPTI_LANG_NAME_CPLUSPLUS,
@@ -202,6 +204,8 @@ enum cp_tree_index
 
     CPTI_ANY_TARG,
 
+    CPTI_SOURCE_LOCATION_IMPL,
+
     CPTI_MAX
 };
 
@@ -268,9 +272,6 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
    then deletes the entire object.  */
 #define deleting_dtor_identifier       cp_global_trees[CPTI_DELETING_DTOR_IDENTIFIER]
 
-#define ovl_op_identifier(ISASS, CODE)  (OVL_OP_INFO(ISASS, CODE)->identifier)
-#define assign_op_identifier (ovl_op_info[true][OVL_OP_NOP_EXPR].identifier)
-#define call_op_identifier (ovl_op_info[false][OVL_OP_CALL_EXPR].identifier)
 /* The name used for conversion operators -- but note that actual
    conversion functions use special identifiers outside the identifier
    table.  */
@@ -286,7 +287,6 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
 #define vptr_identifier                        cp_global_trees[CPTI_VPTR_IDENTIFIER]
 /* The name of the ::, std & anon namespaces.  */
 #define global_identifier              cp_global_trees[CPTI_GLOBAL_IDENTIFIER]
-#define std_identifier                 cp_global_trees[CPTI_STD_IDENTIFIER]
 #define anon_identifier                        cp_global_trees[CPTI_ANON_IDENTIFIER]
 /* auto and declspec(auto) identifiers.  */
 #define auto_identifier                        cp_global_trees[CPTI_AUTO_IDENTIFIER]
@@ -310,6 +310,9 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
 #define value_identifier               cp_global_trees[CPTI_VALUE_IDENTIFIER]
 #define fun_identifier                 cp_global_trees[CPTI_FUN_IDENTIFIER]
 #define closure_identifier             cp_global_trees[CPTI_CLOSURE_IDENTIFIER]
+#define heap_uninit_identifier         cp_global_trees[CPTI_HEAP_UNINIT_IDENTIFIER]
+#define heap_identifier                        cp_global_trees[CPTI_HEAP_IDENTIFIER]
+#define heap_deleted_identifier                cp_global_trees[CPTI_HEAP_DELETED_IDENTIFIER]
 #define lang_name_c                    cp_global_trees[CPTI_LANG_NAME_C]
 #define lang_name_cplusplus            cp_global_trees[CPTI_LANG_NAME_CPLUSPLUS]
 
@@ -355,6 +358,9 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
 /* A node which matches any template argument.  */
 #define any_targ_node                  cp_global_trees[CPTI_ANY_TARG]
 
+/* std::source_location::__impl class.  */
+#define source_location_impl           cp_global_trees[CPTI_SOURCE_LOCATION_IMPL]
+
 /* Node to indicate default access. This must be distinct from the
    access nodes in tree.h.  */
 
@@ -443,16 +449,18 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
       SWITCH_STMT_NO_BREAK_P (in SWITCH_STMT)
       LAMBDA_EXPR_CAPTURE_OPTIMIZED (in LAMBDA_EXPR)
       IMPLICIT_CONV_EXPR_BRACED_INIT (in IMPLICIT_CONV_EXPR)
+      TINFO_VAR_DECLARED_CONSTINIT (in TEMPLATE_INFO)
+      CALL_FROM_NEW_OR_DELETE_P (in CALL_EXPR)
    3: (TREE_REFERENCE_EXPR) (in NON_LVALUE_EXPR) (commented-out).
       ICS_BAD_FLAG (in _CONV)
       FN_TRY_BLOCK_P (in TRY_BLOCK)
       BIND_EXPR_BODY_BLOCK (in BIND_EXPR)
-      DECL_NONTRIVIALLY_INITIALIZED_P (in VAR_DECL)
       CALL_EXPR_ORDERED_ARGS (in CALL_EXPR, AGGR_INIT_EXPR)
       DECLTYPE_FOR_REF_CAPTURE (in DECLTYPE_TYPE)
       CONSTRUCTOR_C99_COMPOUND_LITERAL (in CONSTRUCTOR)
       OVL_NESTED_P (in OVERLOAD)
       LAMBDA_EXPR_INSTANTIATED (in LAMBDA_EXPR)
+      Reserved for DECL_MODULE_EXPORT (in DECL_)
    4: IDENTIFIER_MARKED (IDENTIFIER_NODEs)
       TREE_HAS_CONSTRUCTOR (in INDIRECT_REF, SAVE_EXPR, CONSTRUCTOR,
          CALL_EXPR, or FIELD_DECL).
@@ -461,13 +469,11 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
       OVL_LOOKUP_P (in OVERLOAD)
       LOOKUP_FOUND_P (in RECORD_TYPE, UNION_TYPE, NAMESPACE_DECL)
    5: IDENTIFIER_VIRTUAL_P (in IDENTIFIER_NODE)
-      DECL_VTABLE_OR_VTT_P (in VAR_DECL)
       FUNCTION_RVALUE_QUALIFIED (in FUNCTION_TYPE, METHOD_TYPE)
       CALL_EXPR_REVERSE_ARGS (in CALL_EXPR, AGGR_INIT_EXPR)
       CONSTRUCTOR_PLACEHOLDER_BOUNDARY (in CONSTRUCTOR)
-   6: IDENTIFIER_REPO_CHOSEN (in IDENTIFIER_NODE)
-      DECL_CONSTRUCTION_VTABLE_P (in VAR_DECL)
-      TYPE_MARKED_P (in _TYPE)
+   6: TYPE_MARKED_P (in _TYPE)
+      DECL_NON_TRIVIALLY_INITIALIZED_P (in VAR_DECL)
       RANGE_FOR_IVDEP (in RANGE_FOR_STMT)
       CALL_EXPR_OPERATOR_SYNTAX (in CALL_EXPR, AGGR_INIT_EXPR)
       CONSTRUCTOR_IS_DESIGNATED_INIT (in CONSTRUCTOR)
@@ -588,15 +594,46 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
   TREE_CHECK(NODE,BOUND_TEMPLATE_TEMPLATE_PARM)
 
 #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
+
+/* Returns t iff the node can have a TEMPLATE_INFO field.  */
+
+inline tree
+template_info_decl_check (const_tree t, const char* f, int l, const char* fn)
+{
+  switch (TREE_CODE (t))
+    {
+    case VAR_DECL:
+    case FUNCTION_DECL:
+    case FIELD_DECL:
+    case TYPE_DECL:
+    case CONCEPT_DECL:
+    case TEMPLATE_DECL:
+      return const_cast<tree>(t);
+    default:
+      break;
+    }
+  tree_check_failed (t, f, l, fn,
+                    VAR_DECL, FUNCTION_DECL, FIELD_DECL, TYPE_DECL,
+                    CONCEPT_DECL, TEMPLATE_DECL, 0);
+  gcc_unreachable ();
+}
+
+#define TEMPLATE_INFO_DECL_CHECK(NODE) \
+  template_info_decl_check ((NODE), __FILE__, __LINE__, __FUNCTION__)
+
 #define THUNK_FUNCTION_CHECK(NODE) __extension__                       \
 ({  __typeof (NODE) const __t = (NODE);                                        \
     if (TREE_CODE (__t) != FUNCTION_DECL || !__t->decl_common.lang_specific \
        || !__t->decl_common.lang_specific->u.fn.thunk_p)               \
       tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, 0);    \
      __t; })
-#else
+
+#else /* ENABLE_TREE_CHECKING */
+
+#define TEMPLATE_INFO_DECL_CHECK(NODE) (NODE)
 #define THUNK_FUNCTION_CHECK(NODE) (NODE)
-#endif
+
+#endif /* ENABLE_TREE_CHECKING */
 \f
 /* Language-dependent contents of an identifier.  */
 
@@ -1112,12 +1149,6 @@ enum cp_identifier_kind {
 #define IDENTIFIER_VIRTUAL_P(NODE) \
   TREE_LANG_FLAG_5 (IDENTIFIER_NODE_CHECK (NODE))
 
-/* True iff NAME is the DECL_ASSEMBLER_NAME for an entity with vague
-   linkage which the prelinker has assigned to this translation
-   unit.  */
-#define IDENTIFIER_REPO_CHOSEN(NAME) \
-  (TREE_LANG_FLAG_6 (IDENTIFIER_NODE_CHECK (NAME)))
-
 /* True if this identifier is a reserved word.  C_RID_CODE (node) is
    then the RID_* value of the keyword.  Value 1.  */
 #define IDENTIFIER_KEYWORD_P(NODE)             \
@@ -1294,10 +1325,14 @@ enum cp_trait_kind
 #define TRAIT_EXPR_KIND(NODE) \
   (((struct tree_trait_expr *)TRAIT_EXPR_CHECK (NODE))->kind)
 
+#define TRAIT_EXPR_LOCATION(NODE) \
+  (((struct tree_trait_expr *)TRAIT_EXPR_CHECK (NODE))->locus)
+
 struct GTY (()) tree_trait_expr {
   struct tree_common common;
   tree type1;
   tree type2;
+  location_t locus;
   enum cp_trait_kind kind;
 };
 
@@ -1435,6 +1470,11 @@ typedef struct qualified_typedef_usage_s qualified_typedef_usage_t;
 #define TINFO_USED_TEMPLATE_ID(NODE) \
   (TREE_LANG_FLAG_1 (TEMPLATE_INFO_CHECK (NODE)))
 
+/* Non-zero if this variable template specialization was declared with the
+   `constinit' specifier.  */
+#define TINFO_VAR_DECLARED_CONSTINIT(NODE) \
+  (TREE_LANG_FLAG_2 (TEMPLATE_INFO_CHECK (NODE)))
+
 struct GTY(()) tree_template_info {
   struct tree_base base;
   tree tmpl;
@@ -1468,7 +1508,7 @@ check_nonnull (T* p)
   return p;
 }
 
-// Returns true iff T is non-null and represents constraint info.
+/* Returns true iff T is non-null and represents constraint info.  */
 inline tree_constraint_info *
 check_constraint_info (tree t)
 {
@@ -1477,35 +1517,35 @@ check_constraint_info (tree t)
   return NULL;
 }
 
-// Access the expression describing the template constraints. This may be
-// null if no constraints were introduced in the template parameter list,
-// a requirements clause after the template parameter list, or constraints
-// through a constrained-type-specifier.
+/* Access the expression describing the template constraints. This may be
+   null if no constraints were introduced in the template parameter list,
+   a requirements clause after the template parameter list, or constraints
+   through a constrained-type-specifier.  */
 #define CI_TEMPLATE_REQS(NODE) \
-  check_constraint_info (check_nonnull(NODE))->template_reqs
+  check_constraint_info (check_nonnull (NODE))->template_reqs
 
-// Access the expression describing the trailing constraints. This is non-null
-// for any implicit instantiation of a constrained declaration. For a
-// templated declaration it is non-null only when a trailing requires-clause
-// was specified.
+/* Access the expression describing the trailing constraints. This is non-null
+   for any implicit instantiation of a constrained declaration. For a
+   templated declaration it is non-null only when a trailing requires-clause
+   was specified.  */
 #define CI_DECLARATOR_REQS(NODE) \
-  check_constraint_info (check_nonnull(NODE))->declarator_reqs
+  check_constraint_info (check_nonnull (NODE))->declarator_reqs
 
-// The computed associated constraint expression for a declaration.
+/* The computed associated constraint expression for a declaration.  */
 #define CI_ASSOCIATED_CONSTRAINTS(NODE) \
-  check_constraint_info (check_nonnull(NODE))->associated_constr
+  check_constraint_info (check_nonnull (NODE))->associated_constr
 
-// Access the logical constraints on the template parameters introduced
-// at a given template parameter list level indicated by NODE.
+/* Access the constraint-expression introduced by the requires-clause
+   associate the template parameter list NODE.  */
 #define TEMPLATE_PARMS_CONSTRAINTS(NODE) \
   TREE_TYPE (TREE_LIST_CHECK (NODE))
 
-// Access the logical constraints on the template parameter declaration
-// indicated by NODE.
+/* Access the logical constraints on the template parameter declaration
+   indicated by NODE.  */
 #define TEMPLATE_PARM_CONSTRAINTS(NODE) \
   TREE_TYPE (TREE_LIST_CHECK (NODE))
 
-/* Non-zero if the noexcept is present in a compound requirement. */
+/* Non-zero if the noexcept is present in a compound requirement.  */
 #define COMPOUND_REQ_NOEXCEPT_P(NODE) \
   TREE_LANG_FLAG_0 (TREE_CHECK (NODE, COMPOUND_REQ))
 
@@ -1514,57 +1554,51 @@ check_constraint_info (tree t)
 #define PLACEHOLDER_TYPE_CONSTRAINTS(NODE) \
   DECL_SIZE_UNIT (TYPE_NAME (NODE))
 
-/* The expression evaluated by the predicate constraint. */
-#define PRED_CONSTR_EXPR(NODE) \
-  TREE_OPERAND (TREE_CHECK (NODE, PRED_CONSTR), 0)
+/* True if NODE is a constraint.  */
+#define CONSTR_P(NODE)                  \
+  (TREE_CODE (NODE) == ATOMIC_CONSTR    \
+   || TREE_CODE (NODE) == CONJ_CONSTR   \
+   || TREE_CODE (NODE) == DISJ_CONSTR)
 
-/* The concept of a concept check. */
-#define CHECK_CONSTR_CONCEPT(NODE) \
-  TREE_OPERAND (TREE_CHECK (NODE, CHECK_CONSTR), 0)
+/* Valid for any normalized constraint.  */
+#define CONSTR_CHECK(NODE) \
+  TREE_CHECK3 (NODE, ATOMIC_CONSTR, CONJ_CONSTR, DISJ_CONSTR)
 
-/* The template arguments of a concept check. */
-#define CHECK_CONSTR_ARGS(NODE) \
-  TREE_OPERAND (TREE_CHECK (NODE, CHECK_CONSTR), 1)
-
-/* The expression validated by the predicate constraint. */
-#define EXPR_CONSTR_EXPR(NODE) \
-  TREE_OPERAND (TREE_CHECK (NODE, EXPR_CONSTR), 0)
-
-/* The type validated by the predicate constraint. */
-#define TYPE_CONSTR_TYPE(NODE) \
-  TREE_OPERAND (TREE_CHECK (NODE, TYPE_CONSTR), 0)
-
-/* In an implicit conversion constraint, the source expression. */
-#define ICONV_CONSTR_EXPR(NODE) \
-  TREE_OPERAND (TREE_CHECK (NODE, ICONV_CONSTR), 0)
+/* The CONSTR_INFO stores normalization data for a constraint. It refers to
+   the original expression and the expression or declaration
+   from which the constraint was normalized.
 
-/* In an implicit conversion constraint, the target type. */
-#define ICONV_CONSTR_TYPE(NODE) \
-  TREE_OPERAND (TREE_CHECK (NODE, ICONV_CONSTR), 1)
+   This is TREE_LIST whose TREE_PURPOSE is the original expression and whose
+   TREE_VALUE is a list of contexts.  */
+#define CONSTR_INFO(NODE) \
+  TREE_TYPE (CONSTR_CHECK (NODE))
 
-/* In an argument deduction constraint, the source expression. */
-#define DEDUCT_CONSTR_EXPR(NODE) \
-  TREE_OPERAND (TREE_CHECK (NODE, DEDUCT_CONSTR), 0)
+/* The expression evaluated by the constraint.  */
+#define CONSTR_EXPR(NODE) \
+  TREE_PURPOSE (CONSTR_INFO (NODE))
 
-/* In an argument deduction constraint, the target type pattern. */
-#define DEDUCT_CONSTR_PATTERN(NODE) \
-  TREE_OPERAND (TREE_CHECK (NODE, DEDUCT_CONSTR), 1)
+/* The expression or declaration from which this constraint was normalized.
+   This is a TREE_LIST whose TREE_VALUE is either a template-id expression
+   denoting a concept check or the declaration introducing the constraint.
+   These are chained to other context objects.  */
+#define CONSTR_CONTEXT(NODE) \
+  TREE_VALUE (CONSTR_INFO (NODE))
 
-/* In an argument deduction constraint, the list of placeholder nodes. */
-#define DEDUCT_CONSTR_PLACEHOLDER(NODE) \
-  TREE_OPERAND (TREE_CHECK (NODE, DEDUCT_CONSTR), 2)
+/* The parameter mapping for an atomic constraint. */
+#define ATOMIC_CONSTR_MAP(NODE) \
+  TREE_OPERAND (TREE_CHECK (NODE, ATOMIC_CONSTR), 0)
 
-/* The expression of an exception constraint. */
-#define EXCEPT_CONSTR_EXPR(NODE) \
-  TREE_OPERAND (TREE_CHECK (NODE, EXCEPT_CONSTR), 0)
+/* The expression of an atomic constraint. */
+#define ATOMIC_CONSTR_EXPR(NODE) \
+  CONSTR_EXPR (ATOMIC_CONSTR_CHECK (NODE))
 
-/* In a parameterized constraint, the local parameters. */
-#define PARM_CONSTR_PARMS(NODE) \
-  TREE_OPERAND (TREE_CHECK (NODE, PARM_CONSTR), 0)
+/* The concept of a concept check. */
+#define CHECK_CONSTR_CONCEPT(NODE) \
+  TREE_OPERAND (TREE_CHECK (NODE, CHECK_CONSTR), 0)
 
-/* In a parameterized constraint, the operand. */
-#define PARM_CONSTR_OPERAND(NODE) \
-  TREE_OPERAND (TREE_CHECK (NODE, PARM_CONSTR), 1)
+/* The template arguments of a concept check. */
+#define CHECK_CONSTR_ARGS(NODE) \
+  TREE_OPERAND (TREE_CHECK (NODE, CHECK_CONSTR), 1)
 
 /* Whether a PARM_DECL represents a local parameter in a
    requires-expression.  */
@@ -1655,6 +1689,7 @@ struct GTY(()) saved_scope {
 
   int x_processing_template_decl;
   int x_processing_specialization;
+  int x_processing_constraint;
   int suppress_location_wrappers;
   BOOL_BITFIELD x_processing_explicit_instantiation : 1;
   BOOL_BITFIELD need_pop_function_context : 1;
@@ -1760,6 +1795,24 @@ public:
   ~warning_sentinel() { flag = val; }
 };
 
+/* RAII sentinel to temporarily override input_location.  This will not set
+   input_location to UNKNOWN_LOCATION or BUILTINS_LOCATION.  */
+
+class iloc_sentinel
+{
+  location_t saved_loc;
+public:
+  iloc_sentinel (location_t loc): saved_loc (input_location)
+  {
+    if (loc >= RESERVED_LOCATION_COUNT)
+      input_location = loc;
+  }
+  ~iloc_sentinel ()
+  {
+    input_location = saved_loc;
+  }
+};
+
 /* RAII sentinel that saves the value of a variable, optionally
    overrides it right away, and restores its value when the sentinel
    id destructed.  */
@@ -2106,7 +2159,6 @@ struct GTY(()) lang_type {
   unsigned fields_readonly : 1;
   unsigned ptrmemfunc_flag : 1;
 
-  unsigned was_anonymous : 1;
   unsigned lazy_default_ctor : 1;
   unsigned lazy_copy_ctor : 1;
   unsigned lazy_copy_assign : 1;
@@ -2114,8 +2166,8 @@ struct GTY(()) lang_type {
   unsigned has_const_copy_ctor : 1;
   unsigned has_complex_copy_ctor : 1;
   unsigned has_complex_copy_assign : 1;
-
   unsigned non_aggregate : 1;
+
   unsigned has_complex_dflt : 1;
   unsigned has_list_ctor : 1;
   unsigned non_std_layout : 1;
@@ -2123,8 +2175,8 @@ struct GTY(()) lang_type {
   unsigned lazy_move_ctor : 1;
   unsigned lazy_move_assign : 1;
   unsigned has_complex_move_ctor : 1;
-
   unsigned has_complex_move_assign : 1;
+
   unsigned has_constexpr_ctor : 1;
   unsigned unique_obj_representations : 1;
   unsigned unique_obj_representations_set : 1;
@@ -2136,7 +2188,7 @@ struct GTY(()) lang_type {
   /* There are some bits left to fill out a 32-bit word.  Keep track
      of this by updating the size of this bitfield whenever you add or
      remove a flag.  */
-  unsigned dummy : 4;
+  unsigned dummy : 5;
 
   tree primary_base;
   vec<tree_pair_s, va_gc> *vcall_indices;
@@ -2581,7 +2633,6 @@ struct GTY(()) lang_decl_base {
   unsigned use_template : 2;
   unsigned not_really_extern : 1;         /* var or fn */
   unsigned initialized_in_class : 1;      /* var or fn */
-  unsigned repo_available_p : 1;          /* var or fn */
   unsigned threadprivate_or_deleted_p : 1; /* var or fn */
   unsigned anticipated_p : 1;             /* fn, type or template */
   /* anticipated_p reused as DECL_OMP_PRIVATIZED_MEMBER in var */
@@ -2592,7 +2643,7 @@ struct GTY(()) lang_decl_base {
   unsigned concept_p : 1;                  /* applies to vars and functions */
   unsigned var_declared_inline_p : 1;     /* var */
   unsigned dependent_init_p : 1;          /* var */
-  /* 1 spare bit */
+  /* 2 spare bits */
 };
 
 /* True for DECL codes which have template info and access.  */
@@ -2602,7 +2653,8 @@ struct GTY(()) lang_decl_base {
    || TREE_CODE (NODE) == CONST_DECL           \
    || TREE_CODE (NODE) == TYPE_DECL            \
    || TREE_CODE (NODE) == TEMPLATE_DECL                \
-   || TREE_CODE (NODE) == USING_DECL)
+   || TREE_CODE (NODE) == USING_DECL            \
+   || TREE_CODE (NODE) == CONCEPT_DECL)
 
 /* DECL_LANG_SPECIFIC for the above codes.  */
 
@@ -2647,7 +2699,9 @@ struct GTY(()) lang_decl_fn {
   unsigned hidden_friend_p : 1;
   unsigned omp_declare_reduction_p : 1;
   unsigned has_dependent_explicit_spec_p : 1;
-  unsigned spare : 12;
+  unsigned immediate_fn_p : 1;
+  unsigned maybe_deleted : 1;
+  unsigned spare : 10;
 
   /* 32-bits padding on 64-bit host.  */
 
@@ -2873,13 +2927,17 @@ struct GTY(()) lang_decl {
   (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (NODE)            \
    || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (NODE))
 
-/* Nonzero if NODE (a FUNCTION_DECL) is a cloned constructor or
+/* Nonzero if NODE (a _DECL) is a cloned constructor or
    destructor.  */
-#define DECL_CLONED_FUNCTION_P(NODE) (!!decl_cloned_function_p (NODE, true))
+#define DECL_CLONED_FUNCTION_P(NODE)           \
+  (DECL_NAME (NODE)                            \
+   && IDENTIFIER_CDTOR_P (DECL_NAME (NODE))    \
+   && !DECL_MAYBE_IN_CHARGE_CDTOR_P (NODE))
 
 /* If DECL_CLONED_FUNCTION_P holds, this is the function that was
    cloned.  */
-#define DECL_CLONED_FUNCTION(NODE) (*decl_cloned_function_p (NODE, false))
+#define DECL_CLONED_FUNCTION(NODE)             \
+  (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (NODE))->u.fn.u5.cloned_function)
 
 /* Perform an action for each clone of FN, if FN is a function with
    clones.  This macro should be used like:
@@ -2992,7 +3050,7 @@ struct GTY(()) lang_decl {
 /* Nonzero for a VAR_DECL iff an explicit initializer was provided
    or a non-trivial constructor is called.  */
 #define DECL_NONTRIVIALLY_INITIALIZED_P(NODE)  \
-   (TREE_LANG_FLAG_3 (VAR_DECL_CHECK (NODE)))
+   (TREE_LANG_FLAG_6 (VAR_DECL_CHECK (NODE)))
 
 /* Nonzero for a VAR_DECL that was initialized with a
    constant-expression.  */
@@ -3085,6 +3143,11 @@ struct GTY(()) lang_decl {
 #define DECL_HAS_DEPENDENT_EXPLICIT_SPEC_P(NODE) \
   (LANG_DECL_FN_CHECK (NODE)->has_dependent_explicit_spec_p)
 
+/* Nonzero for a defaulted FUNCTION_DECL for which we haven't decided yet if
+   it's deleted.  */
+#define DECL_MAYBE_DELETED(NODE) \
+  (LANG_DECL_FN_CHECK (NODE)->maybe_deleted)
+
 /* True (in a FUNCTION_DECL) if NODE is a virtual function that is an
    invalid overrider for a function from a base class.  Once we have
    complained about an invalid overrider we avoid complaining about it
@@ -3153,15 +3216,19 @@ struct GTY(()) lang_decl {
 #define DECL_EXTERN_C_FUNCTION_P(NODE) \
   (DECL_NON_THUNK_FUNCTION_P (NODE) && DECL_EXTERN_C_P (NODE))
 
-/* True iff DECL is an entity with vague linkage whose definition is
-   available in this translation unit.  */
-#define DECL_REPO_AVAILABLE_P(NODE) \
-  (DECL_LANG_SPECIFIC (NODE)->u.base.repo_available_p)
-
 /* True if DECL is declared 'constexpr'.  */
 #define DECL_DECLARED_CONSTEXPR_P(DECL) \
   DECL_LANG_FLAG_8 (VAR_OR_FUNCTION_DECL_CHECK (STRIP_TEMPLATE (DECL)))
 
+/* True if FNDECL is an immediate function.  */
+#define DECL_IMMEDIATE_FUNCTION_P(NODE) \
+  (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (STRIP_TEMPLATE (NODE)))    \
+   ? LANG_DECL_FN_CHECK (NODE)->immediate_fn_p                         \
+   : false)
+#define SET_DECL_IMMEDIATE_FUNCTION_P(NODE) \
+  (retrofit_lang_decl (FUNCTION_DECL_CHECK (NODE)),                    \
+   LANG_DECL_FN_CHECK (NODE)->immediate_fn_p = true)
+
 // True if NODE was declared as 'concept'.  The flag implies that the
 // declaration is constexpr, that the declaration cannot be specialized or
 // refined, and that the result type must be convertible to bool.
@@ -3248,8 +3315,10 @@ struct GTY(()) lang_decl {
    both the primary typeinfo object and the associated NTBS name.  */
 #define DECL_TINFO_P(NODE) TREE_LANG_FLAG_4 (VAR_DECL_CHECK (NODE))
 
-/* 1 iff VAR_DECL node NODE is virtual table or VTT.  */
-#define DECL_VTABLE_OR_VTT_P(NODE) TREE_LANG_FLAG_5 (VAR_DECL_CHECK (NODE))
+/* 1 iff VAR_DECL node NODE is virtual table or VTT.  We forward to
+   DECL_VIRTUAL_P from the common code, as that has the semantics we
+   need.  But we want a more descriptive name.  */
+#define DECL_VTABLE_OR_VTT_P(NODE) DECL_VIRTUAL_P (VAR_DECL_CHECK (NODE))
 
 /* 1 iff FUNCTION_TYPE or METHOD_TYPE has a ref-qualifier (either & or &&). */
 #define FUNCTION_REF_QUALIFIED(NODE) \
@@ -3259,12 +3328,6 @@ struct GTY(()) lang_decl {
 #define FUNCTION_RVALUE_QUALIFIED(NODE) \
   TREE_LANG_FLAG_5 (FUNC_OR_METHOD_CHECK (NODE))
 
-/* Returns 1 iff VAR_DECL is a construction virtual table.
-   DECL_VTABLE_OR_VTT_P will be true in this case and must be checked
-   before using this macro.  */
-#define DECL_CONSTRUCTION_VTABLE_P(NODE) \
-  TREE_LANG_FLAG_6 (VAR_DECL_CHECK (NODE))
-
 /* 1 iff NODE is function-local, but for types.  */
 #define LOCAL_CLASS_P(NODE)                            \
   (decl_function_context (TYPE_MAIN_DECL (NODE)) != NULL_TREE)
@@ -3295,9 +3358,7 @@ struct GTY(()) lang_decl {
 
 /* Nonzero if NODE is the std namespace.  */
 #define DECL_NAMESPACE_STD_P(NODE)                     \
-  (TREE_CODE (NODE) == NAMESPACE_DECL                  \
-   && CP_DECL_CONTEXT (NODE) == global_namespace       \
-   && DECL_NAME (NODE) == std_identifier)
+  ((NODE) == std_node)
 
 /* In a TREE_LIST in an attribute list, indicates that the attribute
    must be applied at instantiation time.  */
@@ -3347,8 +3408,8 @@ struct GTY(()) lang_decl {
    && TREE_CODE (TYPE_NAME (NODE)) == TYPE_DECL        \
    && TYPE_DECL_ALIAS_P (TYPE_NAME (NODE)))
 
-/* If non-NULL for a VAR_DECL, FUNCTION_DECL, TYPE_DECL or
-   TEMPLATE_DECL, the entity is either a template specialization (if
+/* If non-NULL for a VAR_DECL, FUNCTION_DECL, TYPE_DECL, TEMPLATE_DECL,
+   or CONCEPT_DECL, the entity is either a template specialization (if
    DECL_USE_TEMPLATE is nonzero) or the abstract instance of the
    template itself.
 
@@ -3367,7 +3428,7 @@ struct GTY(()) lang_decl {
    global function f.  In this case, DECL_TEMPLATE_INFO for S<int>::f
    will be non-NULL, but DECL_USE_TEMPLATE will be zero.  */
 #define DECL_TEMPLATE_INFO(NODE) \
-  (DECL_LANG_SPECIFIC (VAR_TEMPL_TYPE_FIELD_OR_FUNCTION_DECL_CHECK (NODE)) \
+  (DECL_LANG_SPECIFIC (TEMPLATE_INFO_DECL_CHECK (NODE)) \
    ->u.min.template_info)
 
 /* For a lambda capture proxy, its captured variable.  */
@@ -3749,6 +3810,11 @@ struct GTY(()) lang_decl {
    should be performed at instantiation time.  */
 #define KOENIG_LOOKUP_P(NODE) TREE_LANG_FLAG_0 (CALL_EXPR_CHECK (NODE))
 
+/* In a CALL_EXPR, true for allocator calls from new or delete
+   expressions.  */
+#define CALL_FROM_NEW_OR_DELETE_P(NODE) \
+  TREE_LANG_FLAG_2 (CALL_EXPR_CHECK (NODE))
+
 /* True if the arguments to NODE should be evaluated in left-to-right
    order regardless of PUSH_ARGS_REVERSED.  */
 #define CALL_EXPR_ORDERED_ARGS(NODE) \
@@ -4188,9 +4254,9 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
    As an extension, we also treat vectors as aggregates.  Keep these
    checks in ascending code order.  */
 #define CP_AGGREGATE_TYPE_P(TYPE)                              \
-  (TREE_CODE (TYPE) == VECTOR_TYPE                             \
+  (gnu_vector_type_p (TYPE)                                    \
    || TREE_CODE (TYPE) == ARRAY_TYPE                           \
-   || (CLASS_TYPE_P (TYPE) && !CLASSTYPE_NON_AGGREGATE (TYPE)))
+   || (CLASS_TYPE_P (TYPE) && COMPLETE_TYPE_P (TYPE) && !CLASSTYPE_NON_AGGREGATE (TYPE)))
 
 /* Nonzero for a class type means that the class type has a
    user-declared constructor.  */
@@ -4264,6 +4330,11 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
 #define CONSTRUCTOR_IS_DESIGNATED_INIT(NODE) \
   (TREE_LANG_FLAG_6 (CONSTRUCTOR_CHECK (NODE)))
 
+/* True if this CONSTRUCTOR comes from a parenthesized list of values, e.g.
+   A(1, 2, 3).  */
+#define CONSTRUCTOR_IS_PAREN_INIT(NODE) \
+  (CONSTRUCTOR_CHECK(NODE)->base.private_flag)
+
 /* True if NODE represents a conversion for direct-initialization in a
    template.  Set by perform_implicit_conversion_flags.  */
 #define IMPLICIT_CONV_EXPR_DIRECT_INIT(NODE) \
@@ -4544,8 +4615,12 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
 
 /* Define fields and accessors for nodes representing declared names.  */
 
-/* Nonzero if TYPE is an unnamed class with a typedef for linkage purposes.  */
-#define TYPE_WAS_UNNAMED(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->was_anonymous)
+/* True if TYPE is an unnamed structured type with a typedef for
+   linkage purposes.  In that case TYPE_NAME and TYPE_STUB_DECL of the
+   MAIN-VARIANT are different. */
+#define TYPE_WAS_UNNAMED(NODE)                         \
+  (TYPE_NAME (TYPE_MAIN_VARIANT (NODE))                        \
+   != TYPE_STUB_DECL (TYPE_MAIN_VARIANT (NODE)))
 
 /* C++: all of these are overloaded!  These apply only to TYPE_DECLs.  */
 
@@ -5144,6 +5219,7 @@ enum special_function_kind {
                              destroyed.  */
   sfk_conversion,         /* A conversion operator.  */
   sfk_deduction_guide,    /* A class template deduction guide.  */
+  sfk_comparison,         /* A comparison operator (e.g. ==, <, <=>).  */
   sfk_virtual_destructor   /* Used by member synthesis fns.  */
 };
 
@@ -5202,6 +5278,8 @@ enum tsubst_flags {
                                declaration.  */
   tf_no_cleanup = 1 << 10,   /* Do not build a cleanup
                                (build_target_expr and friends) */
+  tf_norm = 1 << 11,            /* Build diagnostic information during
+                                   constraint normalization.  */
   /* Convenient substitution flags combinations.  */
   tf_warning_or_error = tf_warning | tf_error
 };
@@ -5502,6 +5580,21 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, TYPENAME_FLAG };
 #define LOOKUP_DELEGATING_CONS (LOOKUP_NO_NON_INTEGRAL << 1)
 /* Allow initialization of a flexible array members.  */
 #define LOOKUP_ALLOW_FLEXARRAY_INIT (LOOKUP_DELEGATING_CONS << 1)
+/* Require constant initialization of a non-constant variable.  */
+#define LOOKUP_CONSTINIT (LOOKUP_ALLOW_FLEXARRAY_INIT << 1)
+/* We're looking for either a rewritten comparison operator candidate or the
+   operator to use on the former's result.  We distinguish between the two by
+   knowing that comparisons other than == and <=> must be the latter, as must
+   a <=> expression trying to rewrite to <=> without reversing.  */
+#define LOOKUP_REWRITTEN (LOOKUP_CONSTINIT << 1)
+/* Reverse the order of the two arguments for comparison rewriting.  First we
+   swap the arguments in add_operator_candidates, then we swap the conversions
+   in add_candidate (so that they correspond to the original order of the
+   args), then we swap the conversions back in build_new_op_1 (so they
+   correspond to the order of the args in the candidate).  */
+#define LOOKUP_REVERSED (LOOKUP_REWRITTEN << 1)
+/* We're initializing an aggregate from a parenthesized list of values.  */
+#define LOOKUP_AGGREGATE_PAREN_INIT (LOOKUP_REVERSED << 1)
 
 #define LOOKUP_NAMESPACES_ONLY(F)  \
   (((F) & LOOKUP_PREFER_NAMESPACES) && !((F) & LOOKUP_PREFER_TYPES))
@@ -5674,6 +5767,18 @@ enum auto_deduction_context
 #define TFF_NO_TEMPLATE_BINDINGS               (1 << 13)
 #define TFF_POINTER                            (1 << 14)
 
+/* These constants can be used as bit flags to control strip_typedefs.
+
+   STF_USER_VISIBLE: use heuristics to try to avoid stripping user-facing
+       aliases of internal details.  This is intended for diagnostics,
+       where it should (for example) give more useful "aka" types.
+
+   STF_STRIP_DEPENDENT: allow the stripping of aliases with dependent
+       template parameters, relying on code elsewhere to report any
+       appropriate diagnostics.  */
+const unsigned int STF_USER_VISIBLE = 1U;
+const unsigned int STF_STRIP_DEPENDENT = 1U << 1;
+
 /* Returns the TEMPLATE_DECL associated to a TEMPLATE_TEMPLATE_PARM
    node.  */
 #define TEMPLATE_TEMPLATE_PARM_TEMPLATE_DECL(NODE)     \
@@ -5743,6 +5848,12 @@ extern GTY(()) unsigned char ovl_op_alternate[OVL_OP_MAX];
 #define IDENTIFIER_OVL_OP_FLAGS(NODE) \
   (IDENTIFIER_OVL_OP_INFO (NODE)->flags)
 
+inline tree ovl_op_identifier (bool isass, tree_code code)
+{ return OVL_OP_INFO(isass, code)->identifier; }
+inline tree ovl_op_identifier (tree_code code) { return ovl_op_identifier (false, code); }
+#define assign_op_identifier (ovl_op_info[true][OVL_OP_NOP_EXPR].identifier)
+#define call_op_identifier (ovl_op_info[false][OVL_OP_CALL_EXPR].identifier)
+
 /* A type-qualifier, or bitmask therefore, using the TYPE_QUAL
    constants.  */
 
@@ -5815,6 +5926,8 @@ enum cp_decl_spec {
   ds_alias,
   ds_constexpr,
   ds_complex,
+  ds_constinit,
+  ds_consteval,
   ds_thread,
   ds_type_spec,
   ds_redefined_builtin_type_spec,
@@ -6074,6 +6187,7 @@ struct GTY((chain_next ("%h.next"))) tinst_level {
 enum cp_built_in_function {
   CP_BUILT_IN_IS_CONSTANT_EVALUATED,
   CP_BUILT_IN_INTEGER_PACK,
+  CP_BUILT_IN_SOURCE_LOCATION,
   CP_BUILT_IN_LAST
 };
 
@@ -6098,43 +6212,6 @@ class_of_this_parm (const_tree fntype)
   return TREE_TYPE (type_of_this_parm (fntype));
 }
 
-/* True iff T is a variable template declaration. */
-inline bool
-variable_template_p (tree t)
-{
-  if (TREE_CODE (t) != TEMPLATE_DECL)
-    return false;
-  if (!PRIMARY_TEMPLATE_P (t))
-    return false;
-  if (tree r = DECL_TEMPLATE_RESULT (t))
-    return VAR_P (r);
-  return false;
-}
-
-/* True iff T is a variable concept definition. That is, T is
-   a variable template declared with the concept specifier. */
-inline bool
-variable_concept_p (tree t)
-{
-  if (TREE_CODE (t) != TEMPLATE_DECL)
-    return false;
-  if (tree r = DECL_TEMPLATE_RESULT (t))
-    return VAR_P (r) && DECL_DECLARED_CONCEPT_P (r);
-  return false;
-}
-
-/* True iff T is a concept definition. That is, T is a variable or function
-   template declared with the concept specifier. */
-inline bool
-concept_template_p (tree t)
-{
-  if (TREE_CODE (t) != TEMPLATE_DECL)
-    return false;
-  if (tree r = DECL_TEMPLATE_RESULT (t))
-    return VAR_OR_FUNCTION_DECL_P (r) && DECL_DECLARED_CONCEPT_P (r);
-  return false;
-}
-
 /* A parameter list indicating for a function with no parameters,
    e.g  "int f(void)".  */
 extern cp_parameter_declarator *no_parameters;
@@ -6244,7 +6321,9 @@ extern tree convert_for_arg_passing               (tree, tree, tsubst_flags_t);
 extern bool is_properly_derived_from           (tree, tree);
 extern tree initialize_reference               (tree, tree, int,
                                                 tsubst_flags_t);
-extern tree extend_ref_init_temps              (tree, tree, vec<tree, va_gc>**);
+extern tree extend_ref_init_temps              (tree, tree,
+                                                vec<tree, va_gc>**,
+                                                tree * = NULL);
 extern tree make_temporary_var_for_ref_to_temp (tree, tree);
 extern bool type_has_extended_temps            (tree);
 extern tree strip_top_quals                    (tree);
@@ -6256,9 +6335,11 @@ extern tree build_converted_constant_expr        (tree, tree, tsubst_flags_t);
 extern tree build_converted_constant_bool_expr (tree, tsubst_flags_t);
 extern tree perform_direct_initialization_if_possible (tree, tree, bool,
                                                        tsubst_flags_t);
+extern vec<tree,va_gc> *resolve_args (vec<tree,va_gc>*, tsubst_flags_t);
 extern tree in_charge_arg_for_name             (tree);
 extern tree build_cxx_call                     (tree, int, tree *,
-                                                tsubst_flags_t);
+                                                tsubst_flags_t,
+                                                tree = NULL_TREE);
 extern bool is_std_init_list                   (tree);
 extern bool is_list_ctor                       (tree);
 extern void validate_conversion_obstack                (void);
@@ -6324,10 +6405,13 @@ extern bool vbase_has_user_provided_move_assign (tree);
 extern tree default_init_uninitialized_part (tree);
 extern bool trivial_default_constructor_is_constexpr (tree);
 extern bool type_has_constexpr_default_constructor (tree);
+extern bool type_has_constexpr_destructor      (tree);
 extern bool type_has_virtual_destructor                (tree);
 extern bool classtype_has_move_assign_or_move_ctor_p (tree, bool user_declared);
 extern bool classtype_has_non_deleted_move_ctor (tree);
 extern tree classtype_has_depr_implicit_copy   (tree);
+extern bool classtype_has_op (tree, tree_code);
+extern tree classtype_has_defaulted_op (tree, tree_code);
 extern bool type_build_ctor_call               (tree);
 extern bool type_build_dtor_call               (tree);
 extern void explain_non_literal_class          (tree);
@@ -6338,7 +6422,6 @@ extern void check_abi_tags                        (tree);
 extern tree missing_abi_tags                   (tree);
 extern void fixup_type_variants                        (tree);
 extern void fixup_attribute_variants           (tree);
-extern tree* decl_cloned_function_p            (const_tree, bool);
 extern void clone_function_decl                        (tree, bool);
 extern void adjust_clone_args                  (tree);
 extern void deduce_noexcept_on_destructor       (tree);
@@ -6413,6 +6496,7 @@ extern tree groktypename                  (cp_decl_specifier_seq *, const cp_declarator *, bool
 extern tree start_decl                         (const cp_declarator *, cp_decl_specifier_seq *, int, tree, tree, tree *);
 extern void start_decl_1                       (tree, bool);
 extern bool check_array_initializer            (tree, tree, tree);
+extern void omp_declare_variant_finalize       (tree, tree);
 extern void cp_finish_decl                     (tree, tree, bool, tree, int);
 extern tree lookup_decomp_type                 (tree);
 extern void cp_maybe_mangle_decomp             (tree, tree, unsigned int);
@@ -6463,13 +6547,14 @@ extern tmpl_spec_kind current_tmpl_spec_kind    (int);
 extern tree cp_fname_init                      (const char *, tree *);
 extern tree cxx_builtin_function               (tree decl);
 extern tree cxx_builtin_function_ext_scope     (tree decl);
+extern tree cxx_simulate_builtin_function_decl (tree);
 extern tree check_elaborated_type_specifier    (enum tag_types, tree, bool);
 extern void warn_extern_redeclared_static      (tree, tree);
 extern tree cxx_comdat_group                   (tree);
 extern bool cp_missing_noreturn_ok_p           (tree);
 extern bool is_direct_enum_init                        (tree, tree);
 extern void initialize_artificial_var          (tree, vec<constructor_elt, va_gc> *);
-extern tree check_var_type                     (tree, tree);
+extern tree check_var_type                     (tree, tree, location_t);
 extern tree reshape_init                        (tree, tree, tsubst_flags_t);
 extern tree next_initializable_field (tree);
 extern tree fndecl_declared_return_type                (tree);
@@ -6498,7 +6583,8 @@ extern bool vague_linkage_p                       (tree);
 extern void grokclassfn                                (tree, tree,
                                                 enum overload_flags);
 extern tree grok_array_decl                    (location_t, tree, tree, bool);
-extern tree delete_sanity                      (tree, tree, bool, int, tsubst_flags_t);
+extern tree delete_sanity                      (location_t, tree, tree, bool,
+                                                int, tsubst_flags_t);
 extern tree check_classfn                      (tree, tree, tree);
 extern void check_member_template              (tree);
 extern tree grokfield (const cp_declarator *, cp_decl_specifier_seq *,
@@ -6572,7 +6658,7 @@ extern void init_exception_processing             (void);
 extern tree expand_start_catch_block           (tree);
 extern void expand_end_catch_block             (void);
 extern tree build_exc_ptr                      (void);
-extern tree build_throw                                (tree);
+extern tree build_throw                                (location_t, tree);
 extern int nothrow_libfn_p                     (const_tree);
 extern void check_handlers                     (tree);
 extern tree finish_noexcept_expr               (tree, tsubst_flags_t);
@@ -6589,7 +6675,9 @@ extern tree begin_eh_spec_block                   (void);
 extern void finish_eh_spec_block               (tree, tree);
 extern tree build_eh_type_type                 (tree);
 extern tree cp_protect_cleanup_actions         (void);
-extern tree create_try_catch_expr               (tree, tree);
+extern tree template_parms_to_args             (tree);
+extern tree template_parms_level_to_args       (tree);
+extern tree generic_targs_for                  (tree);
 
 /* in expr.c */
 extern tree cplus_expand_constant              (tree);
@@ -6631,17 +6719,18 @@ extern tree build_offset_ref                    (tree, tree, bool,
 extern tree throw_bad_array_new_length         (void);
 extern bool type_has_new_extended_alignment    (tree);
 extern unsigned malloc_alignment               (void);
+extern tree build_new_constexpr_heap_type      (tree, tree, tree);
 extern tree build_new                          (vec<tree, va_gc> **, tree, tree,
                                                 vec<tree, va_gc> **, int,
                                                  tsubst_flags_t);
 extern tree get_temp_regvar                    (tree, tree);
 extern tree build_vec_init                     (tree, tree, tree, bool, int,
                                                  tsubst_flags_t);
-extern tree build_delete                       (tree, tree,
+extern tree build_delete                       (location_t, tree, tree,
                                                 special_function_kind,
                                                 int, int, tsubst_flags_t);
 extern void push_base_cleanups                 (void);
-extern tree build_vec_delete                   (tree, tree,
+extern tree build_vec_delete                   (location_t, tree, tree,
                                                 special_function_kind, int,
                                                 tsubst_flags_t);
 extern tree create_temporary_var               (tree);
@@ -6722,6 +6811,8 @@ extern void maybe_show_extern_c_location (void);
 extern bool literal_integer_zerop (const_tree);
 
 /* in pt.c */
+extern void push_access_scope                  (tree);
+extern void pop_access_scope                   (tree);
 extern bool check_template_shadow              (tree);
 extern bool check_auto_in_tmpl_args             (tree, tree);
 extern tree get_innermost_template_args                (tree, int);
@@ -6741,8 +6832,11 @@ extern int num_template_headers_for_class        (tree);
 extern void check_template_variable            (tree);
 extern tree make_auto                          (void);
 extern tree make_decltype_auto                 (void);
+extern tree make_constrained_auto              (tree, tree);
+extern tree make_constrained_decltype_auto     (tree, tree);
 extern tree make_template_placeholder          (tree);
 extern bool template_placeholder_p             (tree);
+extern bool ctad_template_p                    (tree);
 extern tree do_auto_deduction                   (tree, tree, tree,
                                                  tsubst_flags_t
                                                 = tf_warning_or_error,
@@ -6767,6 +6861,7 @@ extern bool check_default_tmpl_args             (tree, tree, bool, bool, int);
 extern tree push_template_decl                 (tree);
 extern tree push_template_decl_real            (tree, bool);
 extern tree add_inherited_template_parms       (tree, tree);
+extern void template_parm_level_and_index      (tree, int*, int*);
 extern bool redeclare_class_template           (tree, tree, tree);
 extern tree lookup_template_class              (tree, tree, tree, tree,
                                                 int, tsubst_flags_t);
@@ -6791,6 +6886,7 @@ extern bool always_instantiate_p          (tree);
 extern bool maybe_instantiate_noexcept         (tree, tsubst_flags_t = tf_warning_or_error);
 extern tree instantiate_decl                   (tree, bool, bool);
 extern int comp_template_parms                 (const_tree, const_tree);
+extern bool template_heads_equivalent_p                (const_tree, const_tree);
 extern bool builtin_pack_fn_p                  (tree);
 extern tree uses_parameter_packs                (tree);
 extern bool template_parameter_pack_p           (const_tree);
@@ -6819,7 +6915,11 @@ extern tree tsubst_copy_and_build                (tree, tree, tsubst_flags_t,
                                                 tree, bool, bool);
 extern tree tsubst_expr                         (tree, tree, tsubst_flags_t,
                                                  tree, bool);
-extern tree tsubst_pack_expansion               (tree, tree, tsubst_flags_t, tree);
+extern tree tsubst_pack_expansion              (tree, tree, tsubst_flags_t, tree);
+extern tree tsubst_argument_pack               (tree, tree, tsubst_flags_t, tree);
+extern tree tsubst_template_args               (tree, tree, tsubst_flags_t, tree);
+extern tree tsubst_template_arg                        (tree, tree, tsubst_flags_t, tree);
+extern tree tsubst_function_parms              (tree, tree, tsubst_flags_t, tree);
 extern tree most_general_template              (tree);
 extern tree get_mostly_instantiated_function_type (tree);
 extern bool problematic_instantiation_changed  (void);
@@ -6855,8 +6955,9 @@ extern tree instantiate_non_dependent_expr_internal (tree, tsubst_flags_t);
 extern tree instantiate_non_dependent_or_null   (tree);
 extern bool variable_template_specialization_p  (tree);
 extern bool alias_type_or_template_p            (tree);
-extern bool alias_template_specialization_p     (const_tree);
-extern bool dependent_alias_template_spec_p     (const_tree);
+enum { nt_opaque = false, nt_transparent = true };
+extern tree alias_template_specialization_p     (const_tree, bool);
+extern tree dependent_alias_template_spec_p     (const_tree, bool);
 extern bool template_parm_object_p             (const_tree);
 extern bool explicit_class_specialization_p     (tree);
 extern bool push_tinst_level                    (tree);
@@ -6888,12 +6989,7 @@ extern bool deduction_guide_p                    (const_tree);
 extern bool copy_guide_p                       (const_tree);
 extern bool template_guide_p                   (const_tree);
 extern void store_explicit_specifier           (tree, tree);
-
-/* in repo.c */
-extern void init_repo                          (void);
-extern int repo_emit_p                         (tree);
-extern bool repo_export_class_p                        (const_tree);
-extern void finish_repo                                (void);
+extern tree add_outermost_template_args                (tree, tree);
 
 /* in rtti.c */
 /* A vector of all tinfo decls that haven't been emitted yet.  */
@@ -6904,7 +7000,8 @@ extern tree build_typeid                  (tree, tsubst_flags_t);
 extern tree get_tinfo_decl                     (tree);
 extern tree get_typeid                         (tree, tsubst_flags_t);
 extern tree build_headof                       (tree);
-extern tree build_dynamic_cast                 (tree, tree, tsubst_flags_t);
+extern tree build_dynamic_cast                 (location_t, tree, tree,
+                                                tsubst_flags_t);
 extern void emit_support_tinfos                        (void);
 extern bool emit_tinfo_decl                    (tree);
 
@@ -7058,7 +7155,9 @@ extern tree finish_asm_stmt                       (location_t, int, tree, tree,
 extern tree finish_label_stmt                  (tree);
 extern void finish_label_decl                  (tree);
 extern cp_expr finish_parenthesized_expr       (cp_expr);
-extern tree force_paren_expr                   (tree);
+extern tree force_paren_expr                   (tree, bool = false);
+inline tree force_paren_expr_uneval            (tree t)
+{ return force_paren_expr (t, true); }
 extern tree maybe_undo_parenthesized_ref       (tree);
 extern tree maybe_strip_ref_conversion         (tree);
 extern tree finish_non_static_data_member       (tree, tree, tree);
@@ -7165,7 +7264,7 @@ extern tree baselink_for_fns                    (tree);
 extern void finish_static_assert                (tree, tree, location_t,
                                                  bool);
 extern tree finish_decltype_type                (tree, bool, tsubst_flags_t);
-extern tree finish_trait_expr                  (enum cp_trait_kind, tree, tree);
+extern tree finish_trait_expr                  (location_t, enum cp_trait_kind, tree, tree);
 extern tree build_lambda_expr                   (void);
 extern tree build_lambda_object                        (tree);
 extern tree begin_lambda_type                   (tree);
@@ -7227,6 +7326,7 @@ extern bool trivial_type_p                        (const_tree);
 extern bool trivially_copyable_p               (const_tree);
 extern bool type_has_unique_obj_representations (const_tree);
 extern bool scalarish_type_p                   (const_tree);
+extern bool structural_type_p                  (tree, bool = false);
 extern bool type_has_nontrivial_default_init   (const_tree);
 extern bool type_has_nontrivial_copy_init      (const_tree);
 extern void maybe_warn_parm_abi                        (tree, location_t);
@@ -7235,8 +7335,10 @@ extern int zero_init_p                           (const_tree);
 extern bool check_abi_tag_redeclaration                (const_tree, const_tree,
                                                 const_tree);
 extern bool check_abi_tag_args                 (tree, tree);
-extern tree strip_typedefs                     (tree, bool * = NULL);
-extern tree strip_typedefs_expr                        (tree, bool * = NULL);
+extern tree strip_typedefs                     (tree, bool * = NULL,
+                                                unsigned int = 0);
+extern tree strip_typedefs_expr                        (tree, bool * = NULL,
+                                                unsigned int = 0);
 extern tree copy_binfo                         (tree, tree, tree,
                                                 tree *, int);
 extern int member_p                            (const_tree);
@@ -7257,6 +7359,8 @@ extern tree build_min_nt_call_vec (tree, vec<tree, va_gc> *);
 extern tree build_min_non_dep_call_vec         (tree, tree, vec<tree, va_gc> *);
 extern vec<tree, va_gc>* vec_copy_and_insert    (vec<tree, va_gc>*, tree, unsigned);
 extern tree build_cplus_new                    (tree, tree, tsubst_flags_t);
+extern tree build_local_temp                   (tree);
+extern bool is_local_temp                      (tree);
 extern tree build_aggr_init_expr               (tree, tree);
 extern tree get_target_expr                    (tree);
 extern tree get_target_expr_sfinae             (tree, tsubst_flags_t);
@@ -7344,6 +7448,11 @@ extern tree cxx_copy_lang_qualifiers             (const_tree, const_tree);
 
 extern void cxx_print_statistics               (void);
 extern bool maybe_warn_zero_as_null_pointer_constant (tree, location_t);
+/* Analogous to initializer_zerop but also examines the type for
+   which the initializer is being used.  Unlike initializer_zerop,
+   considers empty strings to be zero initializers for arrays and
+   non-zero for pointers.  */
+extern bool type_initializer_zero_p            (tree, tree);
 
 /* in ptree.c */
 extern void cxx_print_xnode                    (FILE *, tree, int);
@@ -7355,9 +7464,14 @@ extern void cxx_print_error_function             (diagnostic_context *,
                                                 struct diagnostic_info *);
 
 /* in typeck.c */
+/* Says how we should behave when comparing two arrays one of which
+   has unknown bounds.  */
+enum compare_bounds_t { bounds_none, bounds_either, bounds_first };
+
 extern bool cxx_mark_addressable               (tree, bool = false);
 extern int string_conv_p                       (const_tree, const_tree, int);
-extern tree cp_truthvalue_conversion           (tree);
+extern tree cp_truthvalue_conversion           (tree, tsubst_flags_t);
+extern tree contextual_conv_bool               (tree, tsubst_flags_t);
 extern tree condition_conversion               (tree);
 extern tree require_complete_type              (tree);
 extern tree require_complete_type_sfinae       (tree, tsubst_flags_t);
@@ -7369,12 +7483,15 @@ enum { ce_derived, ce_type, ce_normal, ce_exact };
 extern bool comp_except_specs                  (const_tree, const_tree, int);
 extern bool comptypes                          (tree, tree, int);
 extern bool same_type_ignoring_top_level_qualifiers_p (tree, tree);
+extern bool similar_type_p                     (tree, tree);
 extern bool compparms                          (const_tree, const_tree);
 extern int comp_cv_qualification               (const_tree, const_tree);
 extern int comp_cv_qualification               (int, int);
 extern int comp_cv_qual_signature              (tree, tree);
-extern tree cxx_sizeof_or_alignof_expr         (tree, enum tree_code, bool);
-extern tree cxx_sizeof_or_alignof_type         (tree, enum tree_code, bool, bool);
+extern tree cxx_sizeof_or_alignof_expr         (location_t, tree,
+                                                enum tree_code, bool);
+extern tree cxx_sizeof_or_alignof_type         (location_t, tree,
+                                                enum tree_code, bool, bool);
 extern tree cxx_alignas_expr                    (tree);
 extern tree cxx_sizeof_nowarn                   (tree);
 extern tree is_bitfield_expr_with_lowered_type  (const_tree);
@@ -7386,10 +7503,13 @@ extern tree build_class_member_access_expr      (cp_expr, tree, tree, bool,
                                                 tsubst_flags_t);
 extern tree finish_class_member_access_expr     (cp_expr, tree, bool,
                                                 tsubst_flags_t);
+extern tree lookup_destructor                  (tree, tree, tree, tsubst_flags_t);
 extern tree build_x_indirect_ref               (location_t, tree,
-                                                ref_operator, tsubst_flags_t);
-extern tree cp_build_indirect_ref              (tree, ref_operator,
-                                                 tsubst_flags_t);
+                                                ref_operator,
+                                                tsubst_flags_t);
+extern tree cp_build_indirect_ref              (location_t, tree,
+                                                ref_operator,
+                                                tsubst_flags_t);
 extern tree cp_build_fold_indirect_ref         (tree);
 extern tree build_array_ref                    (location_t, tree, tree);
 extern tree cp_build_array_ref                 (location_t, tree, tree,
@@ -7398,12 +7518,20 @@ extern tree get_member_function_from_ptrfunc    (tree *, tree, tsubst_flags_t);
 extern tree cp_build_function_call_nary         (tree, tsubst_flags_t, ...)
                                                ATTRIBUTE_SENTINEL;
 extern tree cp_build_function_call_vec         (tree, vec<tree, va_gc> **,
-                                                tsubst_flags_t);
+                                                tsubst_flags_t,
+                                                tree = NULL_TREE);
 extern tree build_x_binary_op                  (const op_location_t &,
                                                 enum tree_code, tree,
                                                 enum tree_code, tree,
                                                 enum tree_code, tree *,
                                                 tsubst_flags_t);
+inline tree build_x_binary_op (const op_location_t &loc,
+                              enum tree_code code, tree arg1, tree arg2,
+                              tsubst_flags_t complain)
+{
+  return build_x_binary_op (loc, code, arg1, TREE_CODE (arg1), arg2,
+                           TREE_CODE (arg2), NULL, complain);
+}
 extern tree build_x_array_ref                  (location_t, tree, tree,
                                                 tsubst_flags_t);
 extern tree build_x_unary_op                   (location_t,
@@ -7426,13 +7554,17 @@ extern tree build_x_compound_expr               (location_t, tree, tree,
                                                 tsubst_flags_t);
 extern tree build_compound_expr                 (location_t, tree, tree);
 extern tree cp_build_compound_expr             (tree, tree, tsubst_flags_t);
-extern tree build_static_cast                  (tree, tree, tsubst_flags_t);
-extern tree build_reinterpret_cast             (tree, tree, tsubst_flags_t);
-extern tree build_const_cast                   (tree, tree, tsubst_flags_t);
+extern tree build_static_cast                  (location_t, tree, tree,
+                                                tsubst_flags_t);
+extern tree build_reinterpret_cast             (location_t, tree, tree,
+                                                tsubst_flags_t);
+extern tree build_const_cast                   (location_t, tree, tree,
+                                                tsubst_flags_t);
 extern tree build_c_cast                       (location_t, tree, tree);
 extern cp_expr build_c_cast                    (location_t loc, tree type,
                                                 cp_expr expr);
-extern tree cp_build_c_cast                    (tree, tree, tsubst_flags_t);
+extern tree cp_build_c_cast                    (location_t, tree, tree,
+                                                tsubst_flags_t);
 extern cp_expr build_x_modify_expr             (location_t, tree,
                                                 enum tree_code, tree,
                                                 tsubst_flags_t);
@@ -7443,7 +7575,7 @@ extern tree convert_for_initialization            (tree, tree, tree, int,
                                                 impl_conv_rhs, tree, int,
                                                  tsubst_flags_t);
 extern int comp_ptr_ttypes                     (tree, tree);
-extern bool comp_ptr_ttypes_const              (tree, tree);
+extern bool comp_ptr_ttypes_const              (tree, tree, compare_bounds_t);
 extern bool error_type_p                       (const_tree);
 extern bool ptr_reasonably_similar             (const_tree, const_tree);
 extern tree build_ptrmemfunc                   (tree, tree, int, bool,
@@ -7460,19 +7592,22 @@ extern tree build_ptrmemfunc1                   (tree, tree, tree);
 extern void expand_ptrmemfunc_cst              (tree, tree *, tree *);
 extern tree type_after_usual_arithmetic_conversions (tree, tree);
 extern tree common_pointer_type                 (tree, tree);
-extern tree composite_pointer_type             (tree, tree, tree, tree,
+extern tree composite_pointer_type             (const op_location_t &,
+                                                tree, tree, tree, tree,
                                                 composite_pointer_operation,
                                                 tsubst_flags_t);
 extern tree merge_types                                (tree, tree);
 extern tree strip_array_domain                 (tree);
 extern tree check_return_expr                  (tree, bool *);
+extern tree spaceship_type                     (tree, tsubst_flags_t = tf_warning_or_error);
+extern tree genericize_spaceship               (tree, tree, tree);
 extern tree cp_build_binary_op                  (const op_location_t &,
                                                 enum tree_code, tree, tree,
                                                 tsubst_flags_t);
 extern tree build_x_vec_perm_expr               (location_t,
                                                 tree, tree, tree,
                                                 tsubst_flags_t);
-#define cxx_sizeof(T)  cxx_sizeof_or_alignof_type (T, SIZEOF_EXPR, false, true)
+#define cxx_sizeof(T)  cxx_sizeof_or_alignof_type (input_location, T, SIZEOF_EXPR, false, true)
 extern tree build_simple_component_ref         (tree, tree);
 extern tree build_ptrmemfunc_access_expr       (tree, tree);
 extern tree build_address                      (tree);
@@ -7489,7 +7624,8 @@ extern int lvalue_or_else                 (tree, enum lvalue_use,
 extern void check_template_keyword             (tree);
 extern bool check_raw_literal_operator         (const_tree decl);
 extern bool check_literal_operator_args                (const_tree, bool *, bool *);
-extern void maybe_warn_about_useless_cast       (tree, tree, tsubst_flags_t);
+extern void maybe_warn_about_useless_cast       (location_t, tree, tree,
+                                                tsubst_flags_t);
 extern tree cp_perform_integral_promotions      (tree, tsubst_flags_t);
 
 extern tree finish_left_unary_fold_expr      (tree, int);
@@ -7557,7 +7693,8 @@ extern tree build_scoped_ref                      (tree, tree, tree *);
 extern tree build_x_arrow                      (location_t, tree,
                                                 tsubst_flags_t);
 extern tree build_m_component_ref              (tree, tree, tsubst_flags_t);
-extern tree build_functional_cast              (tree, tree, tsubst_flags_t);
+extern tree build_functional_cast              (location_t, tree, tree,
+                                                tsubst_flags_t);
 extern tree add_exception_specifier            (tree, tree, tsubst_flags_t);
 extern tree merge_exception_specifiers         (tree, tree);
 
@@ -7617,6 +7754,7 @@ extern void clear_fold_cache                      (void);
 extern tree lookup_hotness_attribute           (tree);
 extern tree process_stmt_hotness_attribute     (tree, location_t);
 extern bool simple_empty_class_p               (tree, tree, tree_code);
+extern tree fold_builtin_source_location       (location_t);
 
 /* in name-lookup.c */
 extern tree strip_using_decl                    (tree);
@@ -7640,69 +7778,100 @@ typedef void cp_binding_oracle_function (enum cp_oracle_request, tree identifier
 
 extern cp_binding_oracle_function *cp_binding_oracle;
 
+/* Set during diagnostics to record the failed constraint. This is a
+   TREE_LIST whose VALUE is the constraint and whose PURPOSE are the
+   instantiation arguments Defined in pt.c.  */
+
+extern tree current_failed_constraint;
+
+/* An RAII class to manage the failed constraint.  */
+
+struct diagnosing_failed_constraint
+{
+  diagnosing_failed_constraint (tree, tree, bool);
+  ~diagnosing_failed_constraint ();
+
+  bool diagnosing_error;
+};
+
 /* in constraint.cc */
-extern void init_constraint_processing          ();
-extern bool constraint_p                        (tree);
-extern tree conjoin_constraints                 (tree, tree);
-extern tree conjoin_constraints                 (tree);
-extern tree get_constraints                     (tree);
+
+extern cp_expr finish_constraint_or_expr       (location_t, cp_expr, cp_expr);
+extern cp_expr finish_constraint_and_expr      (location_t, cp_expr, cp_expr);
+extern cp_expr finish_constraint_primary_expr  (cp_expr);
+extern tree finish_concept_definition          (cp_expr, tree);
+extern tree combine_constraint_expressions      (tree, tree);
+extern tree append_constraint                  (tree, tree);
+extern tree get_constraints                     (const_tree);
 extern void set_constraints                     (tree, tree);
 extern void remove_constraints                  (tree);
 extern tree current_template_constraints       (void);
 extern tree associate_classtype_constraints     (tree);
 extern tree build_constraints                   (tree, tree);
+extern tree get_template_head_requirements     (tree);
+extern tree get_trailing_function_requirements (tree);
 extern tree get_shorthand_constraints           (tree);
-extern tree build_concept_check                 (tree, tree, tree = NULL_TREE);
+
+extern tree build_concept_id                   (tree);
+extern tree build_type_constraint              (tree, tree, tsubst_flags_t);
+extern tree build_concept_check                 (tree, tree, tsubst_flags_t);
+extern tree build_concept_check                 (tree, tree, tree, tsubst_flags_t);
+
+extern tree_pair finish_type_constraints       (tree, tree, tsubst_flags_t);
 extern tree build_constrained_parameter         (tree, tree, tree = NULL_TREE);
-extern tree make_constrained_auto               (tree, tree);
 extern void placeholder_extract_concept_and_args (tree, tree&, tree&);
 extern bool equivalent_placeholder_constraints  (tree, tree);
 extern hashval_t hash_placeholder_constraint   (tree);
 extern bool deduce_constrained_parameter        (tree, tree&, tree&);
 extern tree resolve_constraint_check            (tree);
 extern tree check_function_concept              (tree);
-extern tree finish_template_introduction        (tree, tree);
+extern tree finish_template_introduction        (tree, tree, location_t loc);
 extern bool valid_requirements_p                (tree);
 extern tree finish_concept_name                 (tree);
 extern tree finish_shorthand_constraint         (tree, tree);
-extern tree finish_requires_expr                (tree, tree);
-extern tree finish_simple_requirement           (tree);
-extern tree finish_type_requirement             (tree);
-extern tree finish_compound_requirement         (tree, tree, bool);
-extern tree finish_nested_requirement           (tree);
+extern tree finish_requires_expr                (location_t, tree, tree);
+extern tree finish_simple_requirement           (location_t, tree);
+extern tree finish_type_requirement             (location_t, tree);
+extern tree finish_compound_requirement         (location_t, tree, tree, bool);
+extern tree finish_nested_requirement           (location_t, tree);
 extern void check_constrained_friend            (tree, tree);
 extern tree tsubst_requires_expr                (tree, tree, tsubst_flags_t, tree);
 extern tree tsubst_constraint                   (tree, tree, tsubst_flags_t, tree);
 extern tree tsubst_constraint_info              (tree, tree, tsubst_flags_t, tree);
-extern bool function_concept_check_p            (tree);
-extern tree normalize_expression                (tree);
-extern tree expand_concept                      (tree, tree);
-extern bool expanding_concept                   ();
-extern tree evaluate_constraints                (tree, tree);
-extern tree evaluate_function_concept           (tree, tree);
-extern tree evaluate_variable_concept           (tree, tree);
-extern tree evaluate_constraint_expression      (tree, tree);
-extern bool constraints_satisfied_p             (tree);
-extern bool constraints_satisfied_p             (tree, tree);
-extern tree lookup_constraint_satisfaction      (tree, tree);
-extern tree memoize_constraint_satisfaction     (tree, tree, tree);
-extern tree lookup_concept_satisfaction         (tree, tree);
-extern tree memoize_concept_satisfaction        (tree, tree, tree);
-extern tree get_concept_expansion               (tree, tree);
-extern tree save_concept_expansion              (tree, tree, tree);
+extern tree tsubst_parameter_mapping           (tree, tree, tsubst_flags_t, tree);
+extern tree get_mapped_args                    (tree);
+
+struct processing_constraint_expression_sentinel
+{
+  processing_constraint_expression_sentinel ();
+  ~processing_constraint_expression_sentinel ();
+};
+
+extern bool processing_constraint_expression_p ();
+
+extern tree unpack_concept_check               (tree);
+extern tree evaluate_concept_check              (tree, tsubst_flags_t);
+extern tree satisfy_constraint_expression      (tree);
+extern bool constraints_satisfied_p            (tree);
+extern bool constraints_satisfied_p            (tree, tree);
+extern void clear_satisfaction_cache           ();
 extern bool* lookup_subsumption_result          (tree, tree);
 extern bool save_subsumption_result             (tree, tree, bool);
-
+extern tree find_template_parameters           (tree, int);
 extern bool equivalent_constraints              (tree, tree);
 extern bool equivalently_constrained            (tree, tree);
 extern bool subsumes_constraints                (tree, tree);
-extern bool strictly_subsumes                  (tree, tree);
+extern bool strictly_subsumes                  (tree, tree, tree);
+extern bool weakly_subsumes                    (tree, tree, tree);
 extern int more_constrained                     (tree, tree);
-
+extern bool at_least_as_constrained             (tree, tree);
+extern bool constraints_equivalent_p            (tree, tree);
+extern bool atomic_constraints_identical_p     (tree, tree);
+extern hashval_t iterative_hash_constraint      (tree, hashval_t);
+extern hashval_t hash_atomic_constraint         (tree);
 extern void diagnose_constraints                (location_t, tree, tree);
 
 /* in logic.cc */
-extern tree decompose_conclusions               (tree);
 extern bool subsumes                            (tree, tree);
 
 /* In class.c */
@@ -7734,12 +7903,13 @@ extern bool require_constant_expression (tree);
 extern bool require_rvalue_constant_expression (tree);
 extern bool require_potential_rvalue_constant_expression (tree);
 extern tree cxx_constant_value                 (tree, tree = NULL_TREE);
+extern void cxx_constant_dtor                  (tree, tree);
 extern tree cxx_constant_init                  (tree, tree = NULL_TREE);
 extern tree maybe_constant_value               (tree, tree = NULL_TREE, bool = false);
 extern tree maybe_constant_init                        (tree, tree = NULL_TREE, bool = false);
 extern tree fold_non_dependent_expr            (tree,
                                                 tsubst_flags_t = tf_warning_or_error,
-                                                bool = false);
+                                                bool = false, tree = NULL_TREE);
 extern tree fold_non_dependent_init            (tree,
                                                 tsubst_flags_t = tf_warning_or_error,
                                                 bool = false);
@@ -7751,7 +7921,7 @@ extern bool var_in_maybe_constexpr_fn           (tree);
 extern void explain_invalid_constexpr_fn        (tree);
 extern vec<tree> cx_error_context               (void);
 extern tree fold_sizeof_expr                   (tree);
-extern void clear_cv_and_fold_caches           (void);
+extern void clear_cv_and_fold_caches           (bool = true);
 extern tree unshare_constructor                        (tree CXX_MEM_STAT_INFO);
 
 /* In cp-ubsan.c */
@@ -7798,6 +7968,104 @@ null_node_p (const_tree expr)
   return expr == null_node;
 }
 
+/* True iff T is a variable template declaration. */
+inline bool
+variable_template_p (tree t)
+{
+  if (TREE_CODE (t) != TEMPLATE_DECL)
+    return false;
+  if (!PRIMARY_TEMPLATE_P (t))
+    return false;
+  if (tree r = DECL_TEMPLATE_RESULT (t))
+    return VAR_P (r);
+  return false;
+}
+
+/* True iff T is a standard concept definition. This will return
+   true for both the template and underlying declaration.  */
+
+inline bool
+standard_concept_p (tree t)
+{
+  if (TREE_CODE (t) == TEMPLATE_DECL)
+    t = DECL_TEMPLATE_RESULT (t);
+  return TREE_CODE (t) == CONCEPT_DECL;
+}
+
+/* True iff T is a variable concept definition. This will return
+   true for both the template and the underlying declaration.  */
+
+inline bool
+variable_concept_p (tree t)
+{
+  if (TREE_CODE (t) == TEMPLATE_DECL)
+    t = DECL_TEMPLATE_RESULT (t);
+  return VAR_P (t) && DECL_DECLARED_CONCEPT_P (t);
+}
+
+/* True iff T is a function concept definition or an overload set
+   containing multiple function concepts. This will return true for
+   both the template and the underlying declaration.  */
+
+inline bool
+function_concept_p (tree t)
+{
+  if (TREE_CODE (t) == OVERLOAD)
+    t = OVL_FIRST (t);
+  if (TREE_CODE (t) == TEMPLATE_DECL)
+    t = DECL_TEMPLATE_RESULT (t);
+  return TREE_CODE (t) == FUNCTION_DECL && DECL_DECLARED_CONCEPT_P (t);
+}
+
+/* True iff T is a standard, variable, or function concept.  */
+
+inline bool
+concept_definition_p (tree t)
+{
+  if (t == error_mark_node)
+    return false;
+
+  /* Adjust for function concept overloads.  */
+  if (TREE_CODE (t) == OVERLOAD)
+    t = OVL_FIRST (t);
+
+  /* See through templates. */
+  if (TREE_CODE (t) == TEMPLATE_DECL)
+    t = DECL_TEMPLATE_RESULT (t);
+
+  /* The obvious and easy case.  */
+  if (TREE_CODE (t) == CONCEPT_DECL)
+    return true;
+
+  /* Definitely not a concept.  */
+  if (!VAR_OR_FUNCTION_DECL_P (t))
+    return false;
+  if (!DECL_LANG_SPECIFIC (t))
+    return false;
+
+  return DECL_DECLARED_CONCEPT_P (t);
+}
+
+/* Same as above, but for const trees.  */
+
+inline bool
+concept_definition_p (const_tree t)
+{
+  return concept_definition_p (const_cast<tree> (t));
+}
+
+/* True if t is an expression that checks a concept.  */
+
+inline bool
+concept_check_p (const_tree t)
+{
+  if (TREE_CODE (t) == CALL_EXPR)
+    t = CALL_EXPR_FN (t);
+  if (t && TREE_CODE (t) == TEMPLATE_ID_EXPR)
+    return concept_definition_p (TREE_OPERAND (t, 0));
+  return false;
+}
+
 #if CHECKING_P
 namespace selftest {
   extern void run_cp_tests (void);