OSDN Git Service

gcc/ada/
[pf3gnuchains/gcc-fork.git] / gcc / cp / cp-tree.h
index 9253764..f954da5 100644 (file)
@@ -1,13 +1,14 @@
 /* Definitions for C++ parsing and type checking.
    Copyright (C) 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+   Free Software Foundation, Inc.
    Contributed by Michael Tiemann (tiemann@cygnus.com)
 
 This file is part of GCC.
 
 GCC is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
 any later version.
 
 GCC is distributed in the hope that it will be useful,
@@ -16,9 +17,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING.  If not, write to
-the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA.  */
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
 
 #ifndef GCC_CP_TREE_H
 #define GCC_CP_TREE_H
@@ -32,6 +32,7 @@ Boston, MA 02110-1301, USA.  */
 #include "c-common.h"
 #include "name-lookup.h"
 struct diagnostic_context;
+struct diagnostic_info;
 
 /* Usage of TREE_LANG_FLAG_?:
    0: IDENTIFIER_MARKED (IDENTIFIER_NODEs)
@@ -52,9 +53,12 @@ struct diagnostic_context;
       TYPENAME_IS_ENUM_P (in TYPENAME_TYPE)
       REFERENCE_REF_P (in INDIRECT_EXPR)
       QUALIFIED_NAME_IS_TEMPLATE (in SCOPE_REF)
-      OMP_ATOMIC_DEPENDENT_P (in OMP_ATOMIC)
       OMP_FOR_GIMPLIFYING_P (in OMP_FOR)
       BASELINK_QUALIFIED_P (in BASELINK)
+      TARGET_EXPR_IMPLICIT_P (in TARGET_EXPR)
+      TEMPLATE_PARM_PARAMETER_PACK (in TEMPLATE_PARM_INDEX)
+      TYPE_REF_IS_RVALUE (in REFERENCE_TYPE)
+      ATTR_IS_DEPENDENT (in the TREE_LIST for an attribute)
    1: IDENTIFIER_VIRTUAL_P (in IDENTIFIER_NODE)
       TI_PENDING_TEMPLATE_FLAG.
       TEMPLATE_PARMS_FOR_INLINE.
@@ -68,6 +72,7 @@ struct diagnostic_context;
       ICS_THIS_FLAG (in _CONV)
       DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (in VAR_DECL)
       STATEMENT_LIST_TRY_BLOCK (in STATEMENT_LIST)
+      TYPENAME_IS_RESOLVING_P (in TYPE_NAME_TYPE)
    3: (TREE_REFERENCE_EXPR) (in NON_LVALUE_EXPR) (commented-out).
       ICS_BAD_FLAG (in _CONV)
       FN_TRY_BLOCK_P (in TRY_BLOCK)
@@ -102,11 +107,12 @@ struct diagnostic_context;
    1: C_TYPEDEF_EXPLICITLY_SIGNED (in TYPE_DECL).
       DECL_TEMPLATE_INSTANTIATED (in a VAR_DECL or a FUNCTION_DECL)
       DECL_MEMBER_TEMPLATE_P (in TEMPLATE_DECL)
+      FUNCTION_PARAMETER_PACK_P (in PARM_DECL)
    2: DECL_THIS_EXTERN (in VAR_DECL or FUNCTION_DECL).
       DECL_IMPLICIT_TYPEDEF_P (in a TYPE_DECL)
    3: DECL_IN_AGGR_P.
    4: DECL_C_BIT_FIELD (in a FIELD_DECL)
-      DECL_VAR_MARKED_P (in a VAR_DECL)
+      DECL_ANON_UNION_VAR_P (in a VAR_DECL)
       DECL_SELF_REFERENCE_P (in a TYPE_DECL)
       DECL_INVALID_OVERRIDER_P (in a FUNCTION_DECL)
    5: DECL_INTERFACE_KNOWN.
@@ -177,17 +183,17 @@ struct diagnostic_context;
 
 #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
 #define NON_THUNK_FUNCTION_CHECK(NODE) __extension__                   \
-({  const tree __t = (NODE);                                           \
+({  __typeof(NODE) const __t = (NODE);                                 \
     if (TREE_CODE (__t) != FUNCTION_DECL &&                            \
-       TREE_CODE (__t) != TEMPLATE_DECL && __t->decl_common.lang_specific      \
+       TREE_CODE (__t) != TEMPLATE_DECL && __t->decl_common.lang_specific      \
        && __t->decl_common.lang_specific->decl_flags.thunk_p)                  \
       tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, 0);    \
     __t; })
 #define THUNK_FUNCTION_CHECK(NODE) __extension__                       \
-({  const tree __t = (NODE);                                           \
+({  __typeof (NODE) const __t = (NODE);                                        \
     if (TREE_CODE (__t) != FUNCTION_DECL || !__t->decl_common.lang_specific    \
        || !__t->decl_common.lang_specific->decl_flags.thunk_p)         \
-      tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, 0);    \
+      tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, 0);    \
      __t; })
 #else
 #define NON_THUNK_FUNCTION_CHECK(NODE) (NODE)
@@ -217,22 +223,13 @@ struct lang_identifier GTY(())
 struct template_parm_index_s GTY(())
 {
   struct tree_common common;
-  HOST_WIDE_INT index;
-  HOST_WIDE_INT level;
-  HOST_WIDE_INT orig_level;
+  int index;
+  int level;
+  int orig_level;
   tree decl;
 };
 typedef struct template_parm_index_s template_parm_index;
 
-struct tinst_level_s GTY(())
-{
-  struct tree_common common;
-  tree decl;
-  location_t locus;
-  int in_system_header_p;
-};
-typedef struct tinst_level_s * tinst_level_t;
-
 struct ptrmem_cst GTY(())
 {
   struct tree_common common;
@@ -300,7 +297,8 @@ typedef struct ptrmem_cst * ptrmem_cst_t;
 #define DECL_MAIN_P(NODE)                              \
    (DECL_EXTERN_C_FUNCTION_P (NODE)                    \
     && DECL_NAME (NODE) != NULL_TREE                   \
-    && MAIN_NAME_P (DECL_NAME (NODE)))
+    && MAIN_NAME_P (DECL_NAME (NODE)))                  \
+    && flag_hosted
 
 /* The overloaded FUNCTION_DECL.  */
 #define OVL_FUNCTION(NODE) \
@@ -344,7 +342,7 @@ struct tree_overload GTY(())
    requested.  */
 #define BASELINK_OPTYPE(NODE) \
   (TREE_CHAIN (BASELINK_CHECK (NODE)))
-/* Non-zero if this baselink was from a qualified lookup.  */
+/* Nonzero if this baselink was from a qualified lookup.  */
 #define BASELINK_QUALIFIED_P(NODE) \
   TREE_LANG_FLAG_0 (BASELINK_CHECK (NODE))
 
@@ -445,33 +443,112 @@ struct tree_default_arg GTY (())
   VEC(tree,gc) *instantiations;
 };
 
+/* The condition associated with the static assertion.  This must be
+   an integral constant expression.  */
+#define STATIC_ASSERT_CONDITION(NODE) \
+  (((struct tree_static_assert *)STATIC_ASSERT_CHECK (NODE))->condition)
+
+/* The message associated with the static assertion.  This must be a
+   string constant, which will be emitted as an error message when the
+   static assert condition is false.  */
+#define STATIC_ASSERT_MESSAGE(NODE) \
+  (((struct tree_static_assert *)STATIC_ASSERT_CHECK (NODE))->message)
+
+/* Source location information for a static assertion.  */
+#define STATIC_ASSERT_SOURCE_LOCATION(NODE) \
+  (((struct tree_static_assert *)STATIC_ASSERT_CHECK (NODE))->location)
+
+struct tree_static_assert GTY (())
+{
+  struct tree_common common;
+  tree condition;
+  tree message;
+  location_t location;
+};
+
+struct tree_argument_pack_select GTY (())
+{
+  struct tree_common common;
+  tree argument_pack;
+  int index;
+};
+
+/* The different kinds of traits that we encounter.  */
+
+typedef enum cp_trait_kind
+{
+  CPTK_HAS_NOTHROW_ASSIGN,
+  CPTK_HAS_NOTHROW_CONSTRUCTOR,
+  CPTK_HAS_NOTHROW_COPY,
+  CPTK_HAS_TRIVIAL_ASSIGN,
+  CPTK_HAS_TRIVIAL_CONSTRUCTOR,
+  CPTK_HAS_TRIVIAL_COPY,
+  CPTK_HAS_TRIVIAL_DESTRUCTOR,
+  CPTK_HAS_VIRTUAL_DESTRUCTOR,
+  CPTK_IS_ABSTRACT,
+  CPTK_IS_BASE_OF,
+  CPTK_IS_CLASS,
+  CPTK_IS_CONVERTIBLE_TO,
+  CPTK_IS_EMPTY,
+  CPTK_IS_ENUM,
+  CPTK_IS_POD,
+  CPTK_IS_POLYMORPHIC,
+  CPTK_IS_UNION
+} cp_trait_kind;
+
+/* The types that we are processing.  */
+#define TRAIT_EXPR_TYPE1(NODE) \
+  (((struct tree_trait_expr *)TRAIT_EXPR_CHECK (NODE))->type1)
+
+#define TRAIT_EXPR_TYPE2(NODE) \
+  (((struct tree_trait_expr *)TRAIT_EXPR_CHECK (NODE))->type2)
+
+/* The specific trait that we are processing.  */
+#define TRAIT_EXPR_KIND(NODE) \
+  (((struct tree_trait_expr *)TRAIT_EXPR_CHECK (NODE))->kind)
+
+struct tree_trait_expr GTY (())
+{
+  struct tree_common common;
+  tree type1;
+  tree type2;  
+  enum cp_trait_kind kind;
+};
+
 enum cp_tree_node_structure_enum {
   TS_CP_GENERIC,
   TS_CP_IDENTIFIER,
   TS_CP_TPI,
-  TS_CP_TINST_LEVEL,
   TS_CP_PTRMEM,
   TS_CP_BINDING,
   TS_CP_OVERLOAD,
   TS_CP_BASELINK,
   TS_CP_WRAPPER,
   TS_CP_DEFAULT_ARG,
+  TS_CP_STATIC_ASSERT,
+  TS_CP_ARGUMENT_PACK_SELECT,
+  TS_CP_TRAIT_EXPR,
   LAST_TS_CP_ENUM
 };
 
 /* The resulting tree type.  */
 union lang_tree_node GTY((desc ("cp_tree_node_structure (&%h)"),
-       chain_next ("(union lang_tree_node *)TREE_CHAIN (&%h.generic)")))
+       chain_next ("(union lang_tree_node *)GENERIC_NEXT (&%h.generic)")))
 {
   union tree_node GTY ((tag ("TS_CP_GENERIC"),
                        desc ("tree_node_structure (&%h)"))) generic;
   struct template_parm_index_s GTY ((tag ("TS_CP_TPI"))) tpi;
-  struct tinst_level_s GTY ((tag ("TS_CP_TINST_LEVEL"))) tinst_level;
   struct ptrmem_cst GTY ((tag ("TS_CP_PTRMEM"))) ptrmem;
   struct tree_overload GTY ((tag ("TS_CP_OVERLOAD"))) overload;
   struct tree_baselink GTY ((tag ("TS_CP_BASELINK"))) baselink;
   struct tree_default_arg GTY ((tag ("TS_CP_DEFAULT_ARG"))) default_arg;
   struct lang_identifier GTY ((tag ("TS_CP_IDENTIFIER"))) identifier;
+  struct tree_static_assert GTY ((tag ("TS_CP_STATIC_ASSERT"))) 
+    static_assertion;
+  struct tree_argument_pack_select GTY ((tag ("TS_CP_ARGUMENT_PACK_SELECT")))
+    argument_pack_select;
+  struct tree_trait_expr GTY ((tag ("TS_CP_TRAIT_EXPR")))
+    trait_expression;
 };
 
 \f
@@ -529,6 +606,7 @@ enum cp_tree_index
     CPTI_JCLASS,
     CPTI_TERMINATE,
     CPTI_CALL_UNEXPECTED,
+    CPTI_ATEXIT_FN_PTR_TYPE,
     CPTI_ATEXIT,
     CPTI_DSO_HANDLE,
     CPTI_DCAST,
@@ -618,6 +696,10 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
 /* The declaration for "__cxa_call_unexpected".  */
 #define call_unexpected_node           cp_global_trees[CPTI_CALL_UNEXPECTED]
 
+/* The type of the function-pointer argument to "__cxa_atexit" (or
+   "std::atexit", if "__cxa_atexit" is not being used).  */
+#define atexit_fn_ptr_type_node         cp_global_trees[CPTI_ATEXIT_FN_PTR_TYPE]
+
 /* A pointer to `std::atexit'.  */
 #define atexit_node                    cp_global_trees[CPTI_ATEXIT]
 
@@ -661,11 +743,11 @@ struct saved_scope GTY(())
   struct cp_binding_level *x_previous_class_level;
   tree x_saved_tree;
 
-  HOST_WIDE_INT x_processing_template_decl;
+  int x_processing_template_decl;
   int x_processing_specialization;
-  bool x_processing_explicit_instantiation;
-  int need_pop_function_context;
-  bool skip_evaluation;
+  BOOL_BITFIELD x_processing_explicit_instantiation : 1;
+  BOOL_BITFIELD need_pop_function_context : 1;
+  BOOL_BITFIELD skip_evaluation : 1;
 
   struct stmt_tree_s x_stmt_tree;
 
@@ -703,8 +785,12 @@ struct saved_scope GTY(())
 #define current_lang_base scope_chain->lang_base
 #define current_lang_name scope_chain->lang_name
 
-/* Parsing a function declarator leaves a list of parameter names
-   or a chain or parameter decls here.  */
+/* When parsing a template declaration, a TREE_LIST represents the
+   active template parameters.  Each node in the list represents one
+   level of template parameters.  The innermost level is first in the
+   list.  The depth of each level is stored as an INTEGER_CST in the
+   TREE_PURPOSE of each node.  The parameters for that level are
+   stored in the TREE_VALUE.  */
 
 #define current_template_parms scope_chain->template_parms
 
@@ -721,6 +807,15 @@ struct saved_scope GTY(())
 
 extern GTY(()) struct saved_scope *scope_chain;
 
+struct cxx_int_tree_map GTY(())
+{
+  unsigned int uid;
+  tree to;
+};
+
+extern unsigned int cxx_int_tree_map_hash (const void *);
+extern int cxx_int_tree_map_eq (const void *, const void *);
+
 /* Global state pertinent to the current function.  */
 
 struct language_function GTY(())
@@ -735,11 +830,11 @@ struct language_function GTY(())
   tree x_vtt_parm;
   tree x_return_value;
 
-  int returns_value;
-  int returns_null;
-  int returns_abnormally;
-  int in_function_try_handler;
-  int in_base_initializer;
+  BOOL_BITFIELD returns_value : 1;
+  BOOL_BITFIELD returns_null : 1;
+  BOOL_BITFIELD returns_abnormally : 1;
+  BOOL_BITFIELD in_function_try_handler : 1;
+  BOOL_BITFIELD in_base_initializer : 1;
 
   /* True if this function can throw an exception.  */
   BOOL_BITFIELD can_throw : 1;
@@ -747,6 +842,7 @@ struct language_function GTY(())
   htab_t GTY((param_is(struct named_label_entry))) x_named_labels;
   struct cp_binding_level *bindings;
   VEC(tree,gc) *x_local_names;
+  htab_t GTY((param_is (struct cxx_int_tree_map))) extern_decl_map;
 };
 
 /* The current C++-specific per-function global variables.  */
@@ -871,6 +967,7 @@ enum languages { lang_c, lang_cplusplus, lang_java };
    || TREE_CODE (T) == TYPENAME_TYPE                   \
    || TREE_CODE (T) == TYPEOF_TYPE                     \
    || TREE_CODE (T) == BOUND_TEMPLATE_TEMPLATE_PARM    \
+   || TREE_CODE (T) == DECLTYPE_TYPE                   \
    || TYPE_LANG_FLAG_5 (T))
 
 /* Set IS_AGGR_TYPE for T to VAL.  T must be a class, struct, or
@@ -883,6 +980,10 @@ enum languages { lang_c, lang_cplusplus, lang_java };
 #define CLASS_TYPE_P(T) \
   (IS_AGGR_TYPE_CODE (TREE_CODE (T)) && TYPE_LANG_FLAG_5 (T))
 
+/* Nonzero if T is a class type but not an union.  */
+#define NON_UNION_CLASS_TYPE_P(T) \
+  (CLASS_TYPE_P (T) && TREE_CODE (T) != UNION_TYPE)
+
 /* Keep these checks in ascending code order.  */
 #define IS_AGGR_TYPE_CODE(T)   \
   ((T) == RECORD_TYPE || (T) == UNION_TYPE)
@@ -1040,6 +1141,7 @@ struct lang_type_class GTY(())
   unsigned has_complex_init_ref : 1;
   unsigned has_complex_assign_ref : 1;
   unsigned non_aggregate : 1;
+  unsigned has_complex_dflt : 1;
 
   /* When adding a flag here, consider whether or not it ought to
      apply to a template instance if it applies to the template.  If
@@ -1048,7 +1150,7 @@ struct lang_type_class GTY(())
   /* 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 : 12;
+  unsigned dummy : 11;
 
   tree primary_base;
   VEC(tree_pair_s,gc) *vcall_indices;
@@ -1107,14 +1209,6 @@ struct lang_type GTY(())
 
 #endif /* ENABLE_TREE_CHECKING */
 
-/* Indicates whether or not (and how) a template was expanded for this class.
-     0=no information yet/non-template class
-     1=implicit template instantiation
-     2=explicit template specialization
-     3=explicit template instantiation  */
-#define CLASSTYPE_USE_TEMPLATE(NODE) \
-  (LANG_TYPE_CLASS_CHECK (NODE)->use_template)
-
 /* Fields used for storing information before the class is defined.
    After the class is defined, these fields hold other information.  */
 
@@ -1663,6 +1757,10 @@ struct lang_decl GTY(())
 #define DECL_COPY_CONSTRUCTOR_P(NODE) \
   (DECL_CONSTRUCTOR_P (NODE) && copy_fn_p (NODE) > 0)
 
+/* Nonzero if NODE (a FUNCTION_DECL) is a move constructor.  */
+#define DECL_MOVE_CONSTRUCTOR_P(NODE) \
+  (DECL_CONSTRUCTOR_P (NODE) && move_fn_p (NODE))
+
 /* Nonzero if NODE is a destructor.  */
 #define DECL_DESTRUCTOR_P(NODE)                                \
   (DECL_LANG_SPECIFIC (NODE)->decl_flags.destructor_attr)
@@ -1973,9 +2071,6 @@ struct lang_decl GTY(())
   (!DECL_TEMPLATE_PARM_P (NODE)                                        \
    && TREE_CODE (CP_DECL_CONTEXT (NODE)) == NAMESPACE_DECL)
 
-#define TYPE_NAMESPACE_SCOPE_P(NODE)                           \
-  (TREE_CODE (CP_TYPE_CONTEXT (NODE)) == NAMESPACE_DECL)
-
 /* 1 iff NODE is a class member.  */
 #define DECL_CLASS_SCOPE_P(NODE) \
   (DECL_CONTEXT (NODE) && TYPE_P (DECL_CONTEXT (NODE)))
@@ -1988,10 +2083,6 @@ struct lang_decl GTY(())
   (DECL_CONTEXT (NODE) \
    && TREE_CODE (DECL_CONTEXT (NODE)) == FUNCTION_DECL)
 
-#define TYPE_FUNCTION_SCOPE_P(NODE) \
-  (TYPE_CONTEXT (NODE) \
-   && TREE_CODE (TYPE_CONTEXT (NODE)) == FUNCTION_DECL)
-
 /* 1 iff VAR_DECL node NODE is a type-info decl.  This flag is set for
    both the primary typeinfo object and the associated NTBS name.  */
 #define DECL_TINFO_P(NODE) TREE_LANG_FLAG_4 (VAR_DECL_CHECK (NODE))
@@ -2038,7 +2129,11 @@ struct lang_decl GTY(())
 
 /* In a TREE_LIST concatenating using directives, indicate indirect
    directives  */
-#define TREE_INDIRECT_USING(NODE) (TREE_LIST_CHECK (NODE)->common.lang_flag_0)
+#define TREE_INDIRECT_USING(NODE) (TREE_LIST_CHECK (NODE)->base.lang_flag_0)
+
+/* In a TREE_LIST in an attribute list, indicates that the attribute
+   must be applied at instantiation time.  */
+#define ATTR_IS_DEPENDENT(NODE) (TREE_LIST_CHECK (NODE)->base.lang_flag_0)
 
 extern tree decl_shadowed_for_var_lookup (tree);
 extern void decl_shadowed_for_var_insert (tree, tree);
@@ -2086,15 +2181,15 @@ extern void decl_shadowed_for_var_insert (tree, tree);
   (DECL_LANG_SPECIFIC (DECL)->decl_flags.deferred)
 
 /* If non-NULL for a VAR_DECL, FUNCTION_DECL, TYPE_DECL or
-   TEMPLATE_DECL, the entity is a template specialization.  In that
-   case, DECL_TEMPLATE_INFO is a TREE_LIST, whose TREE_PURPOSE is the
-   TEMPLATE_DECL of which this entity is a specialization.  The TREE_
-   TREE_VALUE is the template arguments used to specialize the
-   template.  
-
-   In general, DECL_TEMPLATE_INFO is non-NULL only if
-   DECL_USE_TEMPLATE is nonzero.  However, for friends, we sometimes
-   have DECL_TEMPLATE_INFO even when DECL_USE_TEMPLATE is zero.
+   TEMPLATE_DECL, the entity is either a template specialization (if
+   DECL_USE_TEMPLATE is nonzero) or the abstract instance of the
+   template itself.
+
+   In either case, DECL_TEMPLATE_INFO is a TREE_LIST, whose
+   TREE_PURPOSE is the TEMPLATE_DECL of which this entity is a
+   specialization or abstract instance.  The TREE_VALUE is the
+   template arguments used to specialize the template.
+   
    Consider:
 
       template <typename T> struct S { friend void f(T) {} };
@@ -2102,15 +2197,16 @@ extern void decl_shadowed_for_var_insert (tree, tree);
    In this case, S<int>::f is, from the point of view of the compiler,
    an instantiation of a template -- but, from the point of view of
    the language, each instantiation of S results in a wholly unrelated
-   global function f.  */ 
+   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_OR_FUNCTION_DECL_CHECK (NODE)) \
    ->decl_flags.u.template_info)
 
-/* For a VAR_DECL, indicates that the variable has been processed.
-   This flag is set and unset throughout the code; it is always
-   used for a temporary purpose.  */
-#define DECL_VAR_MARKED_P(NODE) \
+/* For a VAR_DECL, indicates that the variable is actually a
+   non-static data member of anonymous union that has been promoted to
+   variable status.  */
+#define DECL_ANON_UNION_VAR_P(NODE) \
   (DECL_LANG_FLAG_4 (VAR_DECL_CHECK (NODE)))
 
 /* Template information for a RECORD_TYPE or UNION_TYPE.  */
@@ -2165,7 +2261,7 @@ extern void decl_shadowed_for_var_insert (tree, tree);
 /* Nonzero if the template arguments is actually a vector of vectors,
    rather than just a vector.  */
 #define TMPL_ARGS_HAVE_MULTIPLE_LEVELS(NODE)           \
-  (NODE && TREE_VEC_ELT (NODE, 0)                      \
+  (NODE && TREE_VEC_ELT (NODE, 0)                       \
    && TREE_CODE (TREE_VEC_ELT (NODE, 0)) == TREE_VEC)
 
 /* The depth of a template argument vector.  When called directly by
@@ -2230,6 +2326,16 @@ extern void decl_shadowed_for_var_insert (tree, tree);
    are always the full set of arguments required to instantiate this
    declaration from the most general template specialized here.  */
 #define DECL_TI_ARGS(NODE)         TI_ARGS (DECL_TEMPLATE_INFO (NODE))
+
+/* The TEMPLATE_DECL associated with NODE, a class type.  Even if NODE
+   will be generated from a partial specialization, the TEMPLATE_DECL
+   referred to here will be the original template.  For example,
+   given:
+
+      template <typename T> struct S {};
+      template <typename T> struct S<T*> {};
+      
+   the CLASSTPYE_TI_TEMPLATE for S<int*> will be S, not the S<T*>.  */
 #define CLASSTYPE_TI_TEMPLATE(NODE) TI_TEMPLATE (CLASSTYPE_TEMPLATE_INFO (NODE))
 #define CLASSTYPE_TI_ARGS(NODE)     TI_ARGS (CLASSTYPE_TEMPLATE_INFO (NODE))
 
@@ -2242,7 +2348,7 @@ extern void decl_shadowed_for_var_insert (tree, tree);
                                      (CLASSTYPE_TI_TEMPLATE ((TYPE))))) \
    : (TYPE))
 
-/* Like DECL_TI_TEMPLATE, but for an ENUMERAL_, RECORD_, or UNION_TYPE.  */
+/* Like CLASS_TI_TEMPLATE, but also works for ENUMERAL_TYPEs.  */
 #define TYPE_TI_TEMPLATE(NODE)                 \
   (TI_TEMPLATE (TYPE_TEMPLATE_INFO (NODE)))
 
@@ -2262,6 +2368,84 @@ extern void decl_shadowed_for_var_insert (tree, tree);
    the class definition is complete.  */
 #define TEMPLATE_PARMS_FOR_INLINE(NODE) TREE_LANG_FLAG_1 (NODE)
 
+/* Determine if a parameter (i.e., a PARM_DECL) is a function
+   parameter pack.  */
+#define FUNCTION_PARAMETER_PACK_P(NODE) \
+  (DECL_LANG_FLAG_1 (PARM_DECL_CHECK (NODE)))
+
+/* Determines if NODE is an expansion of one or more parameter packs,
+   e.g., a TYPE_PACK_EXPANSION or EXPR_PACK_EXPANSION.  */
+#define PACK_EXPANSION_P(NODE)                 \
+  (TREE_CODE (NODE) == TYPE_PACK_EXPANSION     \
+   || TREE_CODE (NODE) == EXPR_PACK_EXPANSION)
+
+/* Extracts the type or expression pattern from a TYPE_PACK_EXPANSION or
+   EXPR_PACK_EXPANSION.  */
+#define PACK_EXPANSION_PATTERN(NODE)                            \
+  (TREE_CODE (NODE) == TYPE_PACK_EXPANSION? TREE_TYPE (NODE)    \
+   : TREE_OPERAND (NODE, 0))
+
+/* Sets the type or expression pattern for a TYPE_PACK_EXPANSION or
+   EXPR_PACK_EXPANSION.  */
+#define SET_PACK_EXPANSION_PATTERN(NODE,VALUE)  \
+  if (TREE_CODE (NODE) == TYPE_PACK_EXPANSION)  \
+    TREE_TYPE (NODE) = VALUE;                   \
+  else                                          \
+    TREE_OPERAND (NODE, 0) = VALUE
+
+/* The list of parameter packs used in the PACK_EXPANSION_* node. The
+   TREE_VALUE of each TREE_LIST contains the parameter packs.  */
+#define PACK_EXPANSION_PARAMETER_PACKS(NODE) TREE_CHAIN (NODE)
+
+/* Determine if this is an argument pack.  */
+#define ARGUMENT_PACK_P(NODE)                          \
+  (TREE_CODE (NODE) == TYPE_ARGUMENT_PACK              \
+   || TREE_CODE (NODE) == NONTYPE_ARGUMENT_PACK)
+
+/* The arguments stored in an argument pack. Arguments are stored in a
+   TREE_VEC, which may have length zero.  */
+#define ARGUMENT_PACK_ARGS(NODE)                               \
+  (TREE_CODE (NODE) == TYPE_ARGUMENT_PACK? TREE_TYPE (NODE)    \
+   : TREE_OPERAND (NODE, 0))
+
+/* Set the arguments stored in an argument pack. VALUE must be a
+   TREE_VEC.  */
+#define SET_ARGUMENT_PACK_ARGS(NODE,VALUE)     \
+  if (TREE_CODE (NODE) == TYPE_ARGUMENT_PACK)  \
+    TREE_TYPE (NODE) = VALUE;                           \
+  else                                                  \
+    TREE_OPERAND (NODE, 0) = VALUE
+
+/* Whether the argument pack is "incomplete", meaning that more
+   arguments can still be deduced. Incomplete argument packs are only
+   used when the user has provided an explicit template argument list
+   for a variadic function template. Some of the explicit template
+   arguments will be placed into the beginning of the argument pack,
+   but additional arguments might still be deduced.  */
+#define ARGUMENT_PACK_INCOMPLETE_P(NODE)        \
+  TREE_LANG_FLAG_0 (ARGUMENT_PACK_ARGS (NODE))
+
+/* When ARGUMENT_PACK_INCOMPLETE_P, stores the explicit template
+   arguments used to fill this pack.  */
+#define ARGUMENT_PACK_EXPLICIT_ARGS(NODE)       \
+  TREE_TYPE (ARGUMENT_PACK_ARGS (NODE))
+
+/* In an ARGUMENT_PACK_SELECT, the argument pack from which an
+   argument will be selected.  */
+#define ARGUMENT_PACK_SELECT_FROM_PACK(NODE)                           \
+  (((struct tree_argument_pack_select *)ARGUMENT_PACK_SELECT_CHECK (NODE))->argument_pack)
+
+/* In an ARGUMENT_PACK_SELECT, the index of the argument we want to
+   select.  */
+#define ARGUMENT_PACK_SELECT_INDEX(NODE)                               \
+  (((struct tree_argument_pack_select *)ARGUMENT_PACK_SELECT_CHECK (NODE))->index)
+  
+/* In an ARGUMENT_PACK_SELECT, the actual underlying argument that the
+   ARGUMENT_PACK_SELECT represents. */
+#define ARGUMENT_PACK_SELECT_ARG(NODE)                                 \
+  TREE_VEC_ELT (ARGUMENT_PACK_ARGS (ARGUMENT_PACK_SELECT_FROM_PACK (NODE)), \
+               ARGUMENT_PACK_SELECT_INDEX (NODE));
+
 /* In a FUNCTION_DECL, the saved language-specific per-function data.  */
 #define DECL_SAVED_FUNCTION_DATA(NODE)                 \
   (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (NODE))     \
@@ -2298,6 +2482,85 @@ extern void decl_shadowed_for_var_insert (tree, tree);
 #define AGGR_INIT_VIA_CTOR_P(NODE) \
   TREE_LANG_FLAG_0 (AGGR_INIT_EXPR_CHECK (NODE))
 
+/* AGGR_INIT_EXPR accessors.  These are equivalent to the CALL_EXPR
+   accessors, except for AGGR_INIT_EXPR_SLOT (which takes the place of
+   CALL_EXPR_STATIC_CHAIN).  */
+
+#define AGGR_INIT_EXPR_FN(NODE) TREE_OPERAND (AGGR_INIT_EXPR_CHECK (NODE), 1)
+#define AGGR_INIT_EXPR_SLOT(NODE) \
+  TREE_OPERAND (AGGR_INIT_EXPR_CHECK (NODE), 2)
+#define AGGR_INIT_EXPR_ARG(NODE, I) \
+  TREE_OPERAND (AGGR_INIT_EXPR_CHECK (NODE), (I) + 3)
+#define aggr_init_expr_nargs(NODE) (VL_EXP_OPERAND_LENGTH(NODE) - 3)
+
+/* AGGR_INIT_EXPR_ARGP returns a pointer to the argument vector for NODE.
+   We can't use &AGGR_INIT_EXPR_ARG (NODE, 0) because that will complain if
+   the argument count is zero when checking is enabled.  Instead, do
+   the pointer arithmetic to advance past the 3 fixed operands in a
+   AGGR_INIT_EXPR.  That produces a valid pointer to just past the end of
+   the operand array, even if it's not valid to dereference it.  */
+#define AGGR_INIT_EXPR_ARGP(NODE) \
+  (&(TREE_OPERAND (AGGR_INIT_EXPR_CHECK (NODE), 0)) + 3)
+
+/* Abstract iterators for AGGR_INIT_EXPRs.  */
+
+/* Structure containing iterator state.  */
+typedef struct aggr_init_expr_arg_iterator_d GTY (())
+{
+  tree t;      /* the aggr_init_expr */
+  int n;       /* argument count */
+  int i;       /* next argument index */
+} aggr_init_expr_arg_iterator;
+
+/* Initialize the abstract argument list iterator object ITER with the
+   arguments from AGGR_INIT_EXPR node EXP.  */
+static inline void
+init_aggr_init_expr_arg_iterator (tree exp,
+                                      aggr_init_expr_arg_iterator *iter)
+{
+  iter->t = exp;
+  iter->n = aggr_init_expr_nargs (exp);
+  iter->i = 0;
+}
+
+/* Return the next argument from abstract argument list iterator object ITER,
+   and advance its state.  Return NULL_TREE if there are no more arguments.  */
+static inline tree
+next_aggr_init_expr_arg (aggr_init_expr_arg_iterator *iter)
+{
+  tree result;
+  if (iter->i >= iter->n)
+    return NULL_TREE;
+  result = AGGR_INIT_EXPR_ARG (iter->t, iter->i);
+  iter->i++;
+  return result;
+}
+
+/* Initialize the abstract argument list iterator object ITER, then advance
+   past and return the first argument.  Useful in for expressions, e.g.
+     for (arg = first_aggr_init_expr_arg (exp, &iter); arg;
+          arg = next_aggr_init_expr_arg (&iter))   */
+static inline tree
+first_aggr_init_expr_arg (tree exp, aggr_init_expr_arg_iterator *iter)
+{
+  init_aggr_init_expr_arg_iterator (exp, iter);
+  return next_aggr_init_expr_arg (iter);
+}
+
+/* Test whether there are more arguments in abstract argument list iterator
+   ITER, without changing its state.  */
+static inline bool
+more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
+{
+  return (iter->i < iter->n);
+}
+
+/* Iterate through each argument ARG of AGGR_INIT_EXPR CALL, using variable
+   ITER (of type aggr_init_expr_arg_iterator) to hold the iteration state.  */
+#define FOR_EACH_AGGR_INIT_EXPR_ARG(arg, iter, call)                   \
+  for ((arg) = first_aggr_init_expr_arg ((call), &(iter)); (arg);      \
+       (arg) = next_aggr_init_expr_arg (&(iter)))
+
 /* The TYPE_MAIN_DECL for a class template type is a TYPE_DECL, not a
    TEMPLATE_DECL.  This macro determines whether or not a given class
    type is really a template type, as opposed to an instantiation or
@@ -2322,6 +2585,10 @@ extern void decl_shadowed_for_var_insert (tree, tree);
 #define TYPENAME_IS_CLASS_P(NODE) \
   (TREE_LANG_FLAG_1 (TYPENAME_TYPE_CHECK (NODE)))
 
+/* True if a TYPENAME_TYPE is in the process of being resolved.  */
+#define TYPENAME_IS_RESOLVING_P(NODE) \
+  (TREE_LANG_FLAG_2 (TYPENAME_TYPE_CHECK (NODE)))
+
 /* Nonzero in INTEGER_CST means that this int is negative by dint of
    using a twos-complement negated operand.  */
 #define TREE_NEGATED_INT(NODE) TREE_LANG_FLAG_0 (INTEGER_CST_CHECK (NODE))
@@ -2404,14 +2671,21 @@ extern void decl_shadowed_for_var_insert (tree, tree);
 /* [basic.fundamental]
 
    Integral and floating types are collectively called arithmetic
-   types.  Keep these checks in ascending code order.  */
+   types.  
+
+   As a GNU extension, we also accept complex types.
+
+   Keep these checks in ascending code order.  */
 #define ARITHMETIC_TYPE_P(TYPE) \
-  (CP_INTEGRAL_TYPE_P (TYPE) || TREE_CODE (TYPE) == REAL_TYPE)
+  (CP_INTEGRAL_TYPE_P (TYPE) \
+   || TREE_CODE (TYPE) == REAL_TYPE \
+   || TREE_CODE (TYPE) == COMPLEX_TYPE)
 
 /* [basic.types]
 
    Arithmetic types, enumeration types, pointer types, and
    pointer-to-member types, are collectively called scalar types.
+   
    Keep these checks in ascending code order.  */
 #define SCALAR_TYPE_P(TYPE)                    \
   (TYPE_PTRMEM_P (TYPE)                                \
@@ -2476,8 +2750,13 @@ extern void decl_shadowed_for_var_insert (tree, tree);
 
 /* Nonzero if there is a user-defined X::op=(x&) for this class.  */
 #define TYPE_HAS_COMPLEX_ASSIGN_REF(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->has_complex_assign_ref)
+
+/* Nonzero if there is a user-defined X::X(x&) for this class.  */
 #define TYPE_HAS_COMPLEX_INIT_REF(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->has_complex_init_ref)
 
+/* Nonzero if there is a user-defined default constructor for this class.  */
+#define TYPE_HAS_COMPLEX_DFLT(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->has_complex_dflt)
+
 /* Nonzero if TYPE has a trivial destructor.  From [class.dtor]:
 
      A destructor is trivial if it is an implicitly declared
@@ -2499,6 +2778,10 @@ extern void decl_shadowed_for_var_insert (tree, tree);
 #define TYPE_HAS_NONTRIVIAL_DESTRUCTOR(NODE) \
   (TYPE_LANG_FLAG_4 (NODE))
 
+/* Nonzero for class type means that the default constructor is trivial.  */
+#define TYPE_HAS_TRIVIAL_DFLT(NODE) \
+  (TYPE_HAS_DEFAULT_CONSTRUCTOR (NODE) && ! TYPE_HAS_COMPLEX_DFLT (NODE))
+
 /* Nonzero for class type means that copy initialization of this type can use
    a bitwise copy.  */
 #define TYPE_HAS_TRIVIAL_INIT_REF(NODE) \
@@ -2521,7 +2804,7 @@ extern void decl_shadowed_for_var_insert (tree, tree);
      [basic.types]
 
      An object type is a (possibly cv-qualified) type that is not a
-     function type, not a reference type, and not a void type.  
+     function type, not a reference type, and not a void type.
 
    Keep these checks in ascending order, for speed.  */
 #define TYPE_OBJ_P(NODE)                       \
@@ -2540,6 +2823,10 @@ extern void decl_shadowed_for_var_insert (tree, tree);
 #define TYPE_REF_OBJ_P(NODE)                                   \
   (TREE_CODE (NODE) == REFERENCE_TYPE && TYPE_OBJ_P (TREE_TYPE (NODE)))
 
+/* True if reference type NODE is an rvalue reference */
+#define TYPE_REF_IS_RVALUE(NODE) \
+  TREE_LANG_FLAG_0 (REFERENCE_TYPE_CHECK (NODE))
+
 /* Returns true if NODE is a pointer to an object, or a pointer to
    void.  Keep these checks in ascending tree code order.  */
 #define TYPE_PTROBV_P(NODE)                                    \
@@ -2629,6 +2916,15 @@ extern void decl_shadowed_for_var_insert (tree, tree);
 /* The expression in question for a TYPEOF_TYPE.  */
 #define TYPEOF_TYPE_EXPR(NODE) (TYPEOF_TYPE_CHECK (NODE))->type.values
 
+/* The expression in question for a DECLTYPE_TYPE.  */
+#define DECLTYPE_TYPE_EXPR(NODE) (DECLTYPE_TYPE_CHECK (NODE))->type.values
+
+/* Whether the DECLTYPE_TYPE_EXPR of NODE was originally parsed as an
+   id-expression or a member-access expression. When false, it was
+   parsed as a full expression.  */
+#define DECLTYPE_TYPE_ID_EXPR_OR_MEMBER_ACCESS_P(NODE) \
+  (DECLTYPE_TYPE_CHECK (NODE))->type.string_flag
+
 /* Nonzero for VAR_DECL and FUNCTION_DECL node means that `extern' was
    specified in its declaration.  This can also be set for an
    erroneously declared PARM_DECL.  */
@@ -2835,17 +3131,44 @@ extern void decl_shadowed_for_var_insert (tree, tree);
 /* Returns nonzero if NODE is a primary template.  */
 #define PRIMARY_TEMPLATE_P(NODE) (DECL_PRIMARY_TEMPLATE (NODE) == (NODE))
 
-/* Indicates whether or not (and how) a template was expanded for this
-   FUNCTION_DECL or VAR_DECL.
-     0=normal declaration, e.g. int min (int, int);
-     1=implicit template instantiation
-     2=explicit template specialization, e.g. int min<int> (int, int);
-     3=explicit template instantiation, e.g. template int min<int> (int, int);
+/* Nonzero iff NODE is a specialization of a template.  The value
+   indicates the type of specializations:
+
+     1=implicit instantiation
+
+     2=partial or explicit specialization, e.g.:
+
+        template <> int min<int> (int, int),
+
+     3=explicit instantiation, e.g.:
+  
+        template int min<int> (int, int);
+
+   Note that NODE will be marked as a specialization even if the
+   template it is instantiating is not a primary template.  For
+   example, given:
+
+     template <typename T> struct O { 
+       void f();
+       struct I {}; 
+     };
+    
+   both O<int>::f and O<int>::I will be marked as instantiations.
 
    If DECL_USE_TEMPLATE is nonzero, then DECL_TEMPLATE_INFO will also
    be non-NULL.  */
 #define DECL_USE_TEMPLATE(NODE) (DECL_LANG_SPECIFIC (NODE)->decl_flags.use_template)
 
+/* Like DECL_USE_TEMPLATE, but for class types.  */
+#define CLASSTYPE_USE_TEMPLATE(NODE) \
+  (LANG_TYPE_CLASS_CHECK (NODE)->use_template)
+
+/* True if NODE is a specialization of a primary template.  */
+#define CLASSTYPE_SPECIALIZATION_OF_PRIMARY_TEMPLATE_P(NODE)   \
+  (CLASS_TYPE_P (NODE)                                         \
+   && CLASSTYPE_USE_TEMPLATE (NODE)                            \
+   && PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (arg)))  
+
 #define DECL_TEMPLATE_INSTANTIATION(NODE) (DECL_USE_TEMPLATE (NODE) & 1)
 #define CLASSTYPE_TEMPLATE_INSTANTIATION(NODE) \
   (CLASSTYPE_USE_TEMPLATE (NODE) & 1)
@@ -2901,7 +3224,11 @@ extern void decl_shadowed_for_var_insert (tree, tree);
 
 /* DECL_EXTERNAL must be set on a decl until the decl is actually emitted,
    so that assemble_external will work properly.  So we have this flag to
-   tell us whether the decl is really not external.  */
+   tell us whether the decl is really not external.
+
+   This flag does not indicate whether or not the decl is defined in the
+   current translation unit; it indicates whether or not we should emit the
+   decl at the end of compilation if it is defined and needed.  */
 #define DECL_NOT_REALLY_EXTERN(NODE) \
   (DECL_LANG_SPECIFIC (NODE)->decl_flags.not_really_extern)
 
@@ -2980,24 +3307,20 @@ extern void decl_shadowed_for_var_insert (tree, tree);
   (TREE_LANG_FLAG_0 (SCOPE_REF_CHECK (NODE)))
 
 /* True for an OMP_ATOMIC that has dependent parameters.  These are stored
-   as bare LHS/RHS, and not as ADDR/RHS, as in the generic statement.  */
+   as an expr in operand 1, and integer_zero_node in operand 0.  */
 #define OMP_ATOMIC_DEPENDENT_P(NODE) \
-  (TREE_LANG_FLAG_0 (OMP_ATOMIC_CHECK (NODE)))
-
-/* Used to store the operation code when OMP_ATOMIC_DEPENDENT_P is set.  */
-#define OMP_ATOMIC_CODE(NODE) \
-  (OMP_ATOMIC_CHECK (NODE)->exp.complexity)
+  (TREE_CODE (TREE_OPERAND (OMP_ATOMIC_CHECK (NODE), 0)) == INTEGER_CST)
 
 /* Used while gimplifying continue statements bound to OMP_FOR nodes.  */
 #define OMP_FOR_GIMPLIFYING_P(NODE) \
   (TREE_LANG_FLAG_0 (OMP_FOR_CHECK (NODE)))
 
-/* A language-specific token attached to the OpenMP data clauses to 
+/* A language-specific token attached to the OpenMP data clauses to
    hold code (or code fragments) related to ctors, dtors, and op=.
    See semantics.c for details.  */
 #define CP_OMP_CLAUSE_INFO(NODE) \
   TREE_TYPE (OMP_CLAUSE_RANGE_CHECK (NODE, OMP_CLAUSE_PRIVATE, \
-                                    OMP_CLAUSE_COPYPRIVATE))
+                                    OMP_CLAUSE_COPYPRIVATE))
 
 /* These macros provide convenient access to the various _STMT nodes
    created when parsing template declarations.  */
@@ -3057,6 +3380,11 @@ extern void decl_shadowed_for_var_insert (tree, tree);
    expression statement.  */
 #define EXPR_STMT_EXPR(NODE)   TREE_OPERAND (EXPR_STMT_CHECK (NODE), 0)
 
+/* True if this TARGET_EXPR was created by build_cplus_new, and so we can
+   discard it if it isn't useful.  */
+#define TARGET_EXPR_IMPLICIT_P(NODE) \
+  TREE_LANG_FLAG_0 (TARGET_EXPR_CHECK (NODE))
+
 /* An enumeration of the kind of tags that C++ accepts.  */
 enum tag_types {
   none_type = 0, /* Not a tag type.  */
@@ -3223,15 +3551,6 @@ typedef enum unification_kind_t {
   DEDUCE_EXACT
 } unification_kind_t;
 
-/* Macros for operating on a template instantiation level node.  */
-
-#define TINST_DECL(NODE) \
-  (((tinst_level_t) TINST_LEVEL_CHECK (NODE))->decl)
-#define TINST_LOCATION(NODE) \
-  (((tinst_level_t) TINST_LEVEL_CHECK (NODE))->locus)
-#define TINST_IN_SYSTEM_HEADER_P(NODE) \
-  (((tinst_level_t) TINST_LEVEL_CHECK (NODE))->in_system_header_p)
-
 /* in class.c */
 
 extern int current_class_depth;
@@ -3339,53 +3658,52 @@ extern int at_eof;
    TREE_PURPOSE slot.  */
 extern GTY(()) tree static_aggregates;
 
-/* Functions called along with real static constructors and destructors.  */
-
-extern GTY(()) tree static_ctors;
-extern GTY(()) tree static_dtors;
-
 enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, OP_FLAG, TYPENAME_FLAG };
 
-/* These are uses as bits in flags passed to build_new_method_call
-   to control its error reporting behavior.
-
-   LOOKUP_PROTECT means flag access violations.
-   LOOKUP_COMPLAIN mean complain if no suitable member function
-     matching the arguments is found.
-   LOOKUP_NORMAL is just a combination of these two.
-   LOOKUP_NONVIRTUAL means make a direct call to the member function found
-   LOOKUP_ONLYCONVERTING means that non-conversion constructors are not tried.
-   DIRECT_BIND means that if a temporary is created, it should be created so
-     that it lives as long as the current variable bindings; otherwise it
-     only lives until the end of the complete-expression.  It also forces
-     direct-initialization in cases where other parts of the compiler have
-     already generated a temporary, such as reference initialization and the
-     catch parameter.
-   LOOKUP_NO_CONVERSION means that user-defined conversions are not
-     permitted.  Built-in conversions are permitted.
-   LOOKUP_DESTRUCTOR means explicit call to destructor.
-   LOOKUP_NO_TEMP_BIND means temporaries will not be bound to references.
-
-   These are used in global lookup to support elaborated types and
-   qualifiers.
-
-   LOOKUP_PREFER_TYPES means not to accept objects, and possibly namespaces.
-   LOOKUP_PREFER_NAMESPACES means not to accept objects, and possibly types.
-   LOOKUP_PREFER_BOTH means class-or-namespace-name.  */
-
+/* These are uses as bits in flags passed to various functions to
+   control their behavior.  Despite the LOOKUP_ prefix, many of these
+   do not control name lookup.  ??? Functions using these flags should
+   probably be modified to accept explicit boolean flags for the
+   behaviors relevant to them.  */
+/* Check for access violations.  */
 #define LOOKUP_PROTECT (1 << 0)
+/* Complain if no suitable member function matching the arguments is
+   found.  */
 #define LOOKUP_COMPLAIN (1 << 1)
 #define LOOKUP_NORMAL (LOOKUP_PROTECT | LOOKUP_COMPLAIN)
+/* Even if the function found by lookup is a virtual function, it
+   should be called directly.  */
 #define LOOKUP_NONVIRTUAL (1 << 2)
+/* Non-converting (i.e., "explicit") constructors are not tried.  */
 #define LOOKUP_ONLYCONVERTING (1 << 3)
+/* If a temporary is created, it should be created so that it lives
+   as long as the current variable bindings; otherwise it only lives
+   until the end of the complete-expression.  It also forces
+   direct-initialization in cases where other parts of the compiler
+   have already generated a temporary, such as reference
+   initialization and the catch parameter.  */
 #define DIRECT_BIND (1 << 4)
+/* User-defined conversions are not permitted.  (Built-in conversions
+   are permitted.)  */
 #define LOOKUP_NO_CONVERSION (1 << 5)
+/* The user has explicitly called a destructor.  (Therefore, we do
+   not need to check that the object is non-NULL before calling the
+   destructor.)  */
 #define LOOKUP_DESTRUCTOR (1 << 6)
+/* Do not permit references to bind to temporaries.  */
 #define LOOKUP_NO_TEMP_BIND (1 << 7)
+/* Do not accept objects, and possibly namespaces.  */
 #define LOOKUP_PREFER_TYPES (1 << 8)
+/* Do not accept objects, and possibly types.   */
 #define LOOKUP_PREFER_NAMESPACES (1 << 9)
+/* Accept types or namespaces.  */
 #define LOOKUP_PREFER_BOTH (LOOKUP_PREFER_TYPES | LOOKUP_PREFER_NAMESPACES)
-#define LOOKUP_CONSTRUCTOR_CALLABLE (1 << 10)
+/* Return friend declarations and un-declared builtin functions.
+   (Normally, these entities are registered in the symbol table, but
+   not found by lookup.)  */
+#define LOOKUP_HIDDEN (LOOKUP_PREFER_NAMESPACES << 1)
+/* Prefer that the lvalue be treated as an rvalue.  */
+#define LOOKUP_PREFER_RVALUE (LOOKUP_HIDDEN << 1)
 
 #define LOOKUP_NAMESPACES_ONLY(F)  \
   (((F) & LOOKUP_PREFER_NAMESPACES) && !((F) & LOOKUP_PREFER_TYPES))
@@ -3423,7 +3741,8 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, OP_FLAG, TYPENAME_FLAG };
 #define WANT_ENUM      4 /* enumerated types */
 #define WANT_POINTER   8 /* pointer types */
 #define WANT_NULL      16 /* null pointer constant */
-#define WANT_ARITH     (WANT_INT | WANT_FLOAT)
+#define WANT_VECTOR    32 /* vector types */
+#define WANT_ARITH     (WANT_INT | WANT_FLOAT | WANT_VECTOR)
 
 /* Used with comptypes, and related functions, to guide type
    comparison.  */
@@ -3437,6 +3756,10 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, OP_FLAG, TYPENAME_FLAG };
 #define COMPARE_REDECLARATION 4 /* The comparison is being done when
                                   another declaration of an existing
                                   entity is seen.  */
+#define COMPARE_STRUCTURAL    8 /* The comparison is intended to be
+                                  structural. The actual comparison
+                                  will be identical to
+                                  COMPARE_STRICT.  */
 
 /* Used with push_overloaded_decl.  */
 #define PUSH_GLOBAL         0  /* Push the DECL into namespace scope,
@@ -3467,6 +3790,8 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, OP_FLAG, TYPENAME_FLAG };
 #define TEMPLATE_PARM_DESCENDANTS(NODE) (TREE_CHAIN (NODE))
 #define TEMPLATE_PARM_ORIG_LEVEL(NODE) (TEMPLATE_PARM_INDEX_CAST (NODE)->orig_level)
 #define TEMPLATE_PARM_DECL(NODE) (TEMPLATE_PARM_INDEX_CAST (NODE)->decl)
+#define TEMPLATE_PARM_PARAMETER_PACK(NODE) \
+  (TREE_LANG_FLAG_0 (TEMPLATE_PARM_INDEX_CHECK (NODE)))
 
 /* These macros are for accessing the fields of TEMPLATE_TYPE_PARM,
    TEMPLATE_TEMPLATE_PARM and BOUND_TEMPLATE_TEMPLATE_PARM nodes.  */
@@ -3481,6 +3806,8 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, OP_FLAG, TYPENAME_FLAG };
   (TEMPLATE_PARM_ORIG_LEVEL (TEMPLATE_TYPE_PARM_INDEX (NODE)))
 #define TEMPLATE_TYPE_DECL(NODE) \
   (TEMPLATE_PARM_DECL (TEMPLATE_TYPE_PARM_INDEX (NODE)))
+#define TEMPLATE_TYPE_PARAMETER_PACK(NODE) \
+  (TEMPLATE_PARM_PARAMETER_PACK (TEMPLATE_TYPE_PARM_INDEX (NODE)))
 
 /* These constants can used as bit flags in the process of tree formatting.
 
@@ -3497,7 +3824,9 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, OP_FLAG, TYPENAME_FLAG };
        template-declaration.
    TFF_TEMPLATE_NAME: show only template-name.
    TFF_EXPR_IN_PARENS: parenthesize expressions.
-   TFF_NO_FUNCTION_ARGUMENTS: don't show function arguments.  */
+   TFF_NO_FUNCTION_ARGUMENTS: don't show function arguments.
+   TFF_UNQUALIFIED_NAME: do not print the qualifying scope of the
+       top-level entity.  */
 
 #define TFF_PLAIN_IDENTIFIER                   (0)
 #define TFF_SCOPE                              (1)
@@ -3511,6 +3840,7 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, OP_FLAG, TYPENAME_FLAG };
 #define TFF_TEMPLATE_NAME                      (1 << 8)
 #define TFF_EXPR_IN_PARENS                     (1 << 9)
 #define TFF_NO_FUNCTION_ARGUMENTS              (1 << 10)
+#define TFF_UNQUALIFIED_NAME                   (1 << 11)
 
 /* Returns the TEMPLATE_DECL associated to a TEMPLATE_TEMPLATE_PARM
    node.  */
@@ -3610,8 +3940,9 @@ typedef struct cp_decl_specifier_seq {
      decl-specifier-seq.  */
   BOOL_BITFIELD multiple_types_p : 1;
   /* True iff multiple storage classes were (erroneously) specified
-     for this decl-specifier-seq.  */
-  BOOL_BITFIELD multiple_storage_classes_p : 1;
+     for this decl-specifier-seq or a combination of a storage class
+     with a typedef specifier.  */
+  BOOL_BITFIELD conflicting_specifiers_p : 1;
   /* True iff at least one decl-specifier was found.  */
   BOOL_BITFIELD any_specifiers_p : 1;
   /* True iff "int" was explicitly provided.  */
@@ -3656,7 +3987,10 @@ struct cp_parameter_declarator {
 /* A declarator.  */
 struct cp_declarator {
   /* The kind of declarator.  */
-  cp_declarator_kind kind;
+  ENUM_BITFIELD (cp_declarator_kind) kind : 4;
+  /* Whether we parsed an ellipsis (`...') just before the declarator,
+     to indicate this is a parameter pack.  */
+  BOOL_BITFIELD parameter_pack_p : 1;
   /* Attributes that apply to this declarator.  */
   tree attributes;
   /* For all but cdk_id and cdk_error, the contained declarator.  For
@@ -3690,16 +4024,42 @@ struct cp_declarator {
       /* The bounds to the array.  */
       tree bounds;
     } array;
-    /* For cdk_pointer, cdk_reference, and cdk_ptrmem.  */
+    /* For cdk_pointer and cdk_ptrmem.  */
     struct {
       /* The cv-qualifiers for the pointer.  */
       cp_cv_quals qualifiers;
       /* For cdk_ptrmem, the class type containing the member.  */
       tree class_type;
     } pointer;
+    /* For cdk_reference */
+    struct {
+      /* The cv-qualifiers for the reference.  These qualifiers are
+         only used to diagnose ill-formed code.  */
+      cp_cv_quals qualifiers;
+      /* Whether this is an rvalue reference */
+      bool rvalue_ref;
+    } reference;
   } u;
 };
 
+/* A level of template instantiation.  */
+struct tinst_level GTY(())
+{
+  /* The immediately deeper level in the chain.  */
+  struct tinst_level *next;
+
+  /* The original node.  Can be either a DECL (for a function or static
+     data member) or a TYPE (for a class), depending on what we were
+     asked to instantiate.  */
+  tree decl;
+
+  /* The location where the template is instantiated.  */
+  location_t locus;
+
+  /* True if the location is in a system header.  */
+  bool in_system_header_p;
+};
+
 /* A parameter list indicating for a function with no parameters,
    e.g  "int f(void)".  */
 extern cp_parameter_declarator *no_parameters;
@@ -3710,9 +4070,10 @@ extern bool check_dtor_name                      (tree, tree);
 extern tree build_vfield_ref                   (tree, tree);
 extern tree build_conditional_expr             (tree, tree, tree);
 extern tree build_addr_func                    (tree);
-extern tree build_call                         (tree, tree);
+extern tree build_call_a                       (tree, int, tree*);
+extern tree build_call_n                       (tree, int, ...);
 extern bool null_ptr_cst_p                     (tree);
-extern bool sufficient_parms_p                 (tree);
+extern bool sufficient_parms_p                 (const_tree);
 extern tree type_decays_to                     (tree);
 extern tree build_user_type_conversion         (tree, tree, int);
 extern tree build_new_function_call            (tree, tree, bool);
@@ -3726,7 +4087,7 @@ extern tree build_op_delete_call          (enum tree_code, tree, tree, bool, tree, tree)
 extern bool can_convert                                (tree, tree);
 extern bool can_convert_arg                    (tree, tree, tree, int);
 extern bool can_convert_arg_bad                        (tree, tree, tree);
-extern bool enforce_access                     (tree, tree);
+extern bool enforce_access                     (tree, tree, tree);
 extern tree convert_default_arg                        (tree, tree, tree, int);
 extern tree convert_arg_to_ellipsis            (tree);
 extern tree build_x_va_arg                     (tree, tree);
@@ -3740,7 +4101,7 @@ extern tree strip_top_quals                       (tree);
 extern tree perform_implicit_conversion                (tree, tree);
 extern tree perform_direct_initialization_if_possible (tree, tree, bool);
 extern tree in_charge_arg_for_name             (tree);
-extern tree build_cxx_call                     (tree, tree);
+extern tree build_cxx_call                     (tree, int, tree *);
 #ifdef ENABLE_CHECKING
 extern void validate_conversion_obstack                (void);
 #endif /* ENABLE_CHECKING */
@@ -3778,9 +4139,10 @@ extern void cxx_print_decl                       (FILE *, tree, int);
 extern void cxx_print_type                     (FILE *, tree, int);
 extern void cxx_print_identifier               (FILE *, tree, int);
 extern void cxx_print_error_function   (struct diagnostic_context *,
-                                                const char *);
+                                                const char *,
+                                                struct diagnostic_info *);
 extern void build_self_reference               (void);
-extern int same_signature_p                    (tree, tree);
+extern int same_signature_p                    (const_tree, const_tree);
 extern void maybe_add_class_template_decl_list (tree, tree, int);
 extern void unreverse_member_declarations      (tree);
 extern void invalidate_class_lookup_cache      (void);
@@ -3793,8 +4155,8 @@ extern tree cp_fold_obj_type_ref          (tree, tree);
 extern void set_linkage_according_to_type      (tree, tree);
 extern void determine_key_method               (tree);
 extern void check_for_override                 (tree, tree);
-extern void push_class_stack                    (void);
-extern void pop_class_stack                     (void);
+extern void push_class_stack                   (void);
+extern void pop_class_stack                    (void);
 
 /* in cvt.c */
 extern tree convert_to_reference               (tree, tree, int, int, tree);
@@ -3802,6 +4164,7 @@ extern tree convert_from_reference                (tree);
 extern tree force_rvalue                       (tree);
 extern tree ocp_convert                                (tree, tree, int, int);
 extern tree cp_convert                         (tree, tree);
+extern tree cp_convert_and_check                (tree, tree);
 extern tree convert_to_void    (tree, const char */*implicit context*/);
 extern tree convert_force                      (tree, tree, int);
 extern tree build_expr_type_conversion         (int, tree, bool);
@@ -3855,15 +4218,16 @@ extern int cp_complete_array_type               (tree *, tree, bool);
 extern tree build_ptrmemfunc_type              (tree);
 extern tree build_ptrmem_type                  (tree, tree);
 /* the grokdeclarator prototype is in decl.h */
-extern tree build_this_parm                     (tree, cp_cv_quals);
-extern int copy_fn_p                           (tree);
+extern tree build_this_parm                    (tree, cp_cv_quals);
+extern int copy_fn_p                           (const_tree);
+extern bool move_fn_p                           (const_tree);
 extern tree get_scope_of_declarator            (const cp_declarator *);
 extern void grok_special_member_properties     (tree);
-extern int grok_ctor_properties                        (tree, tree);
-extern void grok_op_properties                 (tree, bool);
+extern int grok_ctor_properties                        (const_tree, const_tree);
+extern bool grok_op_properties                 (tree, bool);
 extern tree xref_tag                           (enum tag_types, tree, tag_scope, bool);
 extern tree xref_tag_from_type                 (tree, tree, tag_scope);
-extern void xref_basetypes                     (tree, tree);
+extern bool xref_basetypes                     (tree, tree);
 extern tree start_enum                         (tree);
 extern void finish_enum                                (tree);
 extern void build_enumerator                   (tree, tree, tree);
@@ -3891,16 +4255,11 @@ extern tree create_implicit_typedef             (tree, tree);
 extern tree maybe_push_decl                    (tree);
 extern tree force_target_expr                  (tree, tree);
 extern tree build_target_expr_with_type                (tree, tree);
-extern int local_variable_p                    (tree);
-extern int nonstatic_local_decl_p              (tree);
+extern int local_variable_p                    (const_tree);
 extern tree register_dtor_fn                   (tree);
 extern tmpl_spec_kind current_tmpl_spec_kind   (int);
 extern tree cp_fname_init                      (const char *, tree *);
-extern tree builtin_function                   (const char *name, tree type,
-                                                int code,
-                                                enum built_in_class cl,
-                                                const char *libname,
-                                                tree attrs);
+extern tree cxx_builtin_function               (tree decl);
 extern tree check_elaborated_type_specifier    (enum tag_types, tree, bool);
 extern void warn_extern_redeclared_static      (tree, tree);
 extern const char *cxx_comdat_group            (tree);
@@ -3909,11 +4268,9 @@ extern void initialize_artificial_var            (tree, tree);
 extern tree check_var_type                     (tree, tree);
 extern tree reshape_init (tree, tree);
 
-extern bool have_extern_spec;
-
 /* in decl2.c */
 extern bool check_java_method                  (tree);
-extern tree build_memfn_type                    (tree, tree, cp_cv_quals);
+extern tree build_memfn_type                   (tree, tree, cp_cv_quals);
 extern void maybe_retrofit_in_chrg             (tree);
 extern void maybe_make_one_only                        (tree);
 extern void grokclassfn                                (tree, tree,
@@ -3928,11 +4285,13 @@ extern tree grokbitfield (const cp_declarator *, cp_decl_specifier_seq *,
                          tree);
 extern void cplus_decl_attributes              (tree *, tree, int);
 extern void finish_anon_union                  (tree);
-extern void cp_finish_file                     (void);
+extern void cp_write_global_declarations       (void);
 extern tree coerce_new_type                    (tree);
 extern tree coerce_delete_type                 (tree);
 extern void comdat_linkage                     (tree);
 extern void determine_visibility               (tree);
+extern void constrain_class_visibility         (tree);
+extern void update_member_visibility           (tree);
 extern void import_export_decl                 (tree);
 extern tree build_cleanup                      (tree);
 extern tree build_offset_ref_call_from_tree    (tree, tree);
@@ -3943,11 +4302,11 @@ extern tree cp_build_parm_decl                  (tree, tree);
 extern tree get_guard                          (tree);
 extern tree get_guard_cond                     (tree);
 extern tree set_guard                          (tree);
-extern tree cxx_callgraph_analyze_expr         (tree *, int *, tree);
+extern tree cxx_callgraph_analyze_expr         (tree *, int *);
 extern void mark_needed                                (tree);
 extern bool decl_needed_p                      (tree);
 extern void note_vague_linkage_fn              (tree);
-extern tree build_artificial_parm               (tree, tree);
+extern tree build_artificial_parm              (tree, tree);
 
 /* in error.c */
 extern void init_error                         (void);
@@ -3958,6 +4317,7 @@ extern const char *lang_decl_name         (tree, int);
 extern const char *language_to_string          (enum languages);
 extern const char *class_key_or_enum_as_string (tree);
 extern void print_instantiation_context                (void);
+extern void maybe_warn_variadic_templates       (void);
 
 /* in except.c */
 extern void init_exception_processing          (void);
@@ -3965,15 +4325,12 @@ 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 int nothrow_libfn_p                     (tree);
+extern int nothrow_libfn_p                     (const_tree);
 extern void check_handlers                     (tree);
 extern void choose_personality_routine         (enum languages);
 extern tree eh_type_info                       (tree);
 
 /* in expr.c */
-extern rtx cxx_expand_expr                     (tree, rtx,
-                                                enum machine_mode,
-                                                int, rtx *);
 extern tree cplus_expand_constant              (tree);
 
 /* friend.c */
@@ -3992,6 +4349,7 @@ extern tree build_zero_init                       (tree, tree, bool);
 extern tree build_offset_ref                   (tree, tree, bool);
 extern tree build_new                          (tree, tree, tree, tree, int);
 extern tree build_vec_init                     (tree, tree, tree, bool, int);
+extern tree build_default_init                  (tree, tree);
 extern tree build_delete                       (tree, tree,
                                                 special_function_kind,
                                                 int, int);
@@ -4019,6 +4377,7 @@ extern void yyerror                               (const char *);
 extern void yyhook                             (int);
 extern bool cxx_init                           (void);
 extern void cxx_finish                         (void);
+extern bool in_main_input_context              (void);
 
 /* in method.c */
 extern void init_method                                (void);
@@ -4028,8 +4387,12 @@ extern void use_thunk                            (tree, bool);
 extern void synthesize_method                  (tree);
 extern tree lazily_declare_fn                  (special_function_kind,
                                                 tree);
-extern tree skip_artificial_parms_for          (tree, tree);
+extern tree skip_artificial_parms_for          (const_tree, tree);
+extern int num_artificial_parms_for            (const_tree);
 extern tree make_alias_for                     (tree, tree);
+extern tree locate_copy                                (tree, void *);
+extern tree locate_ctor                                (tree, void *);
+extern tree locate_dtor                                (tree, void *);
 
 /* In optimize.c */
 extern bool maybe_clone_body                   (tree);
@@ -4041,18 +4404,19 @@ extern void maybe_begin_member_template_processing (tree);
 extern void maybe_end_member_template_processing (void);
 extern tree finish_member_template_decl                (tree);
 extern void begin_template_parm_list           (void);
-extern void begin_specialization               (void);
+extern bool begin_specialization               (void);
 extern void reset_specialization               (void);
 extern void end_specialization                 (void);
 extern void begin_explicit_instantiation       (void);
 extern void end_explicit_instantiation         (void);
 extern tree check_explicit_specialization      (tree, tree, int, int);
-extern tree process_template_parm              (tree, tree, bool);
+extern tree process_template_parm              (tree, tree, bool, bool);
 extern tree end_template_parm_list             (tree);
 extern void end_template_decl                  (void);
+extern bool check_default_tmpl_args             (tree, tree, int, int, int);
 extern tree push_template_decl                 (tree);
 extern tree push_template_decl_real            (tree, bool);
-extern void redeclare_class_template           (tree, tree);
+extern bool redeclare_class_template           (tree, tree);
 extern tree lookup_template_class              (tree, tree, tree, tree,
                                                 int, tsubst_flags_t);
 extern tree lookup_template_function           (tree, tree);
@@ -4067,43 +4431,51 @@ extern int more_specialized_fn                  (tree, tree, int);
 extern void do_decl_instantiation              (tree, tree);
 extern void do_type_instantiation              (tree, tree, tsubst_flags_t);
 extern tree instantiate_decl                   (tree, int, bool);
-extern int comp_template_parms                 (tree, tree);
+extern int comp_template_parms                 (const_tree, const_tree);
+extern bool uses_parameter_packs                (tree);
+extern bool template_parameter_pack_p           (const_tree);
+extern tree make_pack_expansion                 (tree);
+extern bool check_for_bare_parameter_packs      (tree*);
+extern tree get_template_info                  (tree);
 extern int template_class_depth                        (tree);
 extern int is_specialization_of                        (tree, tree);
 extern bool is_specialization_of_friend                (tree, tree);
 extern int comp_template_args                  (tree, tree);
-extern void maybe_process_partial_specialization (tree);
+extern tree maybe_process_partial_specialization (tree);
 extern tree most_specialized_instantiation     (tree);
 extern void print_candidates                   (tree);
 extern void instantiate_pending_templates      (int);
 extern tree tsubst_default_argument            (tree, tree, tree);
 extern tree tsubst_copy_and_build              (tree, tree, tsubst_flags_t,
-                                                tree, bool);
+                                                tree, bool, bool);
 extern tree most_general_template              (tree);
 extern tree get_mostly_instantiated_function_type (tree);
 extern int problematic_instantiation_changed   (void);
 extern void record_last_problematic_instantiation (void);
-extern tree current_instantiation              (void);
+extern struct tinst_level *current_instantiation(void);
 extern tree maybe_get_template_decl_from_type_decl (tree);
 extern int processing_template_parmlist;
 extern bool dependent_type_p                   (tree);
-extern bool any_dependent_template_arguments_p  (tree);
+extern bool any_dependent_template_arguments_p  (const_tree);
 extern bool dependent_template_p               (tree);
 extern bool dependent_template_id_p            (tree, tree);
 extern bool type_dependent_expression_p                (tree);
-extern bool any_type_dependent_arguments_p      (tree);
+extern bool any_type_dependent_arguments_p      (const_tree);
 extern bool value_dependent_expression_p       (tree);
+extern bool any_value_dependent_elements_p      (const_tree);
 extern tree resolve_typename_type              (tree, bool);
 extern tree template_for_substitution          (tree);
 extern tree build_non_dependent_expr           (tree);
 extern tree build_non_dependent_args           (tree);
 extern bool reregister_specialization          (tree, tree, tree);
 extern tree fold_non_dependent_expr            (tree);
+extern bool explicit_class_specialization_p     (tree);
+extern struct tinst_level *outermost_tinst_level(void);
 
 /* in repo.c */
 extern void init_repo                          (void);
 extern int repo_emit_p                         (tree);
-extern bool repo_export_class_p                        (tree);
+extern bool repo_export_class_p                        (const_tree);
 extern void finish_repo                                (void);
 
 /* in rtti.c */
@@ -4114,6 +4486,7 @@ extern void init_rtti_processing          (void);
 extern tree build_typeid                       (tree);
 extern tree get_tinfo_decl                     (tree);
 extern tree get_typeid                         (tree);
+extern tree build_headof                       (tree);
 extern tree build_dynamic_cast                 (tree, tree);
 extern void emit_support_tinfos                        (void);
 extern bool emit_tinfo_decl                    (tree);
@@ -4158,16 +4531,31 @@ extern tree copied_binfo                        (tree, tree);
 extern tree original_binfo                     (tree, tree);
 extern int shared_member_p                     (tree);
 
+
+/* The representation of a deferred access check.  */
+
+typedef struct deferred_access_check GTY(())
+{
+  /* The base class in which the declaration is referenced. */
+  tree binfo;
+  /* The declaration whose access must be checked.  */
+  tree decl;
+  /* The declaration that should be used in the error message.  */
+  tree diag_decl;
+} deferred_access_check;
+DEF_VEC_O(deferred_access_check);
+DEF_VEC_ALLOC_O(deferred_access_check,gc);
+
 /* in semantics.c */
 extern void push_deferring_access_checks       (deferring_kind);
 extern void resume_deferring_access_checks     (void);
 extern void stop_deferring_access_checks       (void);
 extern void pop_deferring_access_checks                (void);
-extern tree get_deferred_access_checks         (void);
+extern VEC (deferred_access_check,gc)* get_deferred_access_checks              (void);
 extern void pop_to_parent_deferring_access_checks (void);
-extern void perform_access_checks               (tree);
+extern void perform_access_checks              (VEC (deferred_access_check,gc)*);
 extern void perform_deferred_access_checks     (void);
-extern void perform_or_defer_access_check      (tree, tree);
+extern void perform_or_defer_access_check      (tree, tree, tree);
 extern int stmts_are_full_exprs_p              (void);
 extern void init_cp_semantics                  (void);
 extern tree do_poplevel                                (tree);
@@ -4228,6 +4616,7 @@ extern tree finish_non_static_data_member       (tree, tree, tree);
 extern tree begin_stmt_expr                    (void);
 extern tree finish_stmt_expr_expr              (tree, tree);
 extern tree finish_stmt_expr                   (tree, bool);
+extern tree stmt_expr_value_expr               (tree);
 extern tree perform_koenig_lookup              (tree, tree);
 extern tree finish_call_expr                   (tree, tree, bool, bool);
 extern tree finish_increment_expr              (tree, enum tree_code);
@@ -4239,22 +4628,23 @@ extern tree finish_fname                        (tree);
 extern void finish_translation_unit            (void);
 extern tree finish_template_type_parm          (tree, tree);
 extern tree finish_template_template_parm       (tree, tree);
-extern tree begin_class_definition             (tree);
+extern tree begin_class_definition             (tree, tree);
 extern void finish_template_decl               (tree);
 extern tree finish_template_type               (tree, tree, int);
 extern tree finish_base_specifier              (tree, tree, bool);
 extern void finish_member_declaration          (tree);
 extern void qualified_name_lookup_error                (tree, tree, tree);
-extern void check_template_keyword              (tree);
+extern void check_template_keyword             (tree);
 extern tree finish_id_expression               (tree, tree, tree,
                                                 cp_id_kind *,
                                                 bool, bool, bool *,
                                                 bool, bool, bool, bool,
                                                 const char **);
 extern tree finish_typeof                      (tree);
+extern tree finish_offsetof                    (tree);
 extern void finish_decl_cleanup                        (tree, tree);
 extern void finish_eh_cleanup                  (tree);
-extern void expand_body                                (tree);
+extern void emit_associated_thunks             (tree);
 extern void finish_mem_initializers            (tree);
 extern tree check_template_template_default_arg (tree);
 extern void expand_or_defer_fn                 (tree);
@@ -4280,34 +4670,42 @@ extern tree cxx_omp_clause_default_ctor         (tree, tree);
 extern tree cxx_omp_clause_copy_ctor           (tree, tree, tree);
 extern tree cxx_omp_clause_assign_op           (tree, tree, tree);
 extern tree cxx_omp_clause_dtor                        (tree, tree);
-extern bool cxx_omp_privatize_by_reference     (tree);
+extern bool cxx_omp_privatize_by_reference     (const_tree);
+extern tree baselink_for_fns                    (tree);
+extern void finish_static_assert                (tree, tree, location_t,
+                                                 bool);
+extern tree finish_decltype_type                (tree, bool);
+extern tree finish_trait_expr                  (enum cp_trait_kind, tree, tree);
 
 /* in tree.c */
 extern void lang_check_failed                  (const char *, int,
                                                 const char *) ATTRIBUTE_NORETURN;
 extern tree stabilize_expr                     (tree, tree *);
 extern void stabilize_call                     (tree, tree *);
+extern void stabilize_aggr_init                        (tree, tree *);
 extern bool stabilize_init                     (tree, tree *);
 extern tree add_stmt_to_compound               (tree, tree);
 extern tree cxx_maybe_build_cleanup            (tree);
 extern void init_tree                          (void);
-extern int pod_type_p                          (tree);
-extern int zero_init_p                         (tree);
+extern int pod_type_p                          (const_tree);
+extern bool class_tmpl_impl_spec_p             (const_tree);
+extern int zero_init_p                         (const_tree);
 extern tree canonical_type_variant             (tree);
 extern tree copy_binfo                         (tree, tree, tree,
                                                 tree *, int);
-extern int member_p                            (tree);
-extern cp_lvalue_kind real_lvalue_p            (tree);
-extern bool builtin_valid_in_constant_expr_p    (tree);
+extern int member_p                            (const_tree);
+extern cp_lvalue_kind real_lvalue_p            (const_tree);
+extern bool builtin_valid_in_constant_expr_p    (const_tree);
 extern tree build_min                          (enum tree_code, tree, ...);
 extern tree build_min_nt                       (enum tree_code, ...);
 extern tree build_min_non_dep                  (enum tree_code, tree, ...);
+extern tree build_min_non_dep_call_list                (tree, tree, tree);
 extern tree build_cplus_new                    (tree, tree);
 extern tree get_target_expr                    (tree);
 extern tree build_cplus_array_type             (tree, tree);
 extern tree hash_tree_cons                     (tree, tree, tree);
 extern tree hash_tree_chain                    (tree, tree);
-extern tree build_qualified_name                (tree, tree, tree, bool);
+extern tree build_qualified_name               (tree, tree, tree, bool);
 extern int is_overloaded_fn                    (tree);
 extern tree get_first_fn                       (tree);
 extern tree ovl_cons                           (tree, tree);
@@ -4320,55 +4718,61 @@ extern tree array_type_nelts_top                (tree);
 extern tree break_out_target_exprs             (tree);
 extern tree get_type_decl                      (tree);
 extern tree decl_namespace_context             (tree);
+extern bool decl_anon_ns_mem_p                 (const_tree);
 extern tree lvalue_type                                (tree);
 extern tree error_type                         (tree);
-extern int varargs_function_p                  (tree);
-extern int really_overloaded_fn                        (tree);
+extern int varargs_function_p                  (const_tree);
+extern bool really_overloaded_fn               (tree);
 extern bool cp_tree_equal                      (tree, tree);
 extern tree no_linkage_check                   (tree, bool);
 extern void debug_binfo                                (tree);
 extern tree build_dummy_object                 (tree);
 extern tree maybe_dummy_object                 (tree, tree *);
-extern int is_dummy_object                     (tree);
+extern int is_dummy_object                     (const_tree);
 extern const struct attribute_spec cxx_attribute_table[];
 extern tree make_ptrmem_cst                    (tree, tree);
 extern tree cp_build_type_attribute_variant     (tree, tree);
+extern tree cp_build_reference_type            (tree, bool);
 extern tree cp_build_qualified_type_real       (tree, int, tsubst_flags_t);
 #define cp_build_qualified_type(TYPE, QUALS) \
   cp_build_qualified_type_real ((TYPE), (QUALS), tf_warning_or_error)
-extern special_function_kind special_function_p (tree);
+extern special_function_kind special_function_p (const_tree);
 extern int count_trees                         (tree);
 extern int char_type_p                         (tree);
 extern void verify_stmt_tree                   (tree);
 extern linkage_kind decl_linkage               (tree);
 extern tree cp_walk_subtrees (tree*, int*, walk_tree_fn,
                              void*, struct pointer_set_t*);
-extern int cp_cannot_inline_tree_fn            (tree*);
-extern tree cp_add_pending_fn_decls            (void*,tree);
-extern int cp_auto_var_in_fn_p                 (tree,tree);
+#define cp_walk_tree(a,b,c,d) \
+       walk_tree_1 (a, b, c, d, cp_walk_subtrees)
+#define cp_walk_tree_without_duplicates(a,b,c) \
+       walk_tree_without_duplicates_1 (a, b, c, cp_walk_subtrees)
 extern tree fold_if_not_in_template            (tree);
-extern tree rvalue                              (tree);
+extern tree rvalue                             (tree);
 extern tree convert_bitfield_to_declared_type   (tree);
-extern tree cp_save_expr                        (tree);
-   
+extern tree cp_save_expr                       (tree);
+extern bool cast_valid_in_integral_constant_expression_p (tree);
+extern bool cxx_type_hash_eq                   (const_tree, const_tree);
+
 /* in typeck.c */
-extern int string_conv_p                       (tree, tree, int);
+extern int string_conv_p                       (const_tree, const_tree, int);
 extern tree cp_truthvalue_conversion           (tree);
 extern tree condition_conversion               (tree);
 extern tree require_complete_type              (tree);
 extern tree complete_type                      (tree);
 extern tree complete_type_or_else              (tree, tree);
-extern int type_unknown_p                      (tree);
-extern bool comp_except_specs                  (tree, tree, bool);
+extern int type_unknown_p                      (const_tree);
+extern bool comp_except_specs                  (const_tree, const_tree, bool);
 extern bool comptypes                          (tree, tree, int);
-extern bool compparms                          (tree, tree);
-extern int comp_cv_qualification               (tree, tree);
+extern bool compparms                          (const_tree, const_tree);
+extern int comp_cv_qualification               (const_tree, const_tree);
 extern int comp_cv_qual_signature              (tree, tree);
 extern tree cxx_sizeof_or_alignof_expr         (tree, enum tree_code);
 extern tree cxx_sizeof_or_alignof_type         (tree, enum tree_code, bool);
 #define cxx_sizeof_nowarn(T) cxx_sizeof_or_alignof_type (T, SIZEOF_EXPR, false)
 extern tree inline_conversion                  (tree);
-extern tree is_bitfield_expr_with_lowered_type  (tree); 
+extern tree is_bitfield_expr_with_lowered_type  (const_tree);
+extern tree unlowered_expr_type                 (const_tree);
 extern tree decay_conversion                   (tree);
 extern tree build_class_member_access_expr      (tree, tree, tree, bool);
 extern tree finish_class_member_access_expr     (tree, tree, bool);
@@ -4376,8 +4780,9 @@ extern tree build_x_indirect_ref          (tree, const char *);
 extern tree build_indirect_ref                 (tree, const char *);
 extern tree build_array_ref                    (tree, tree);
 extern tree get_member_function_from_ptrfunc   (tree *, tree);
-extern tree build_x_binary_op                  (enum tree_code, tree, tree,
-                                                bool *);
+extern tree build_x_binary_op                  (enum tree_code, tree,
+                                                enum tree_code, tree,
+                                                enum tree_code, bool *);
 extern tree build_x_unary_op                   (enum tree_code, tree);
 extern tree unary_complex_lvalue               (enum tree_code, tree);
 extern tree build_x_conditional_expr           (tree, tree, tree);
@@ -4393,12 +4798,13 @@ extern tree build_modify_expr                   (tree, enum tree_code, tree);
 extern tree convert_for_initialization         (tree, tree, tree, int,
                                                 const char *, tree, int);
 extern int comp_ptr_ttypes                     (tree, tree);
-extern bool comp_ptr_ttypes_const               (tree, tree);
-extern int ptr_reasonably_similar              (tree, tree);
+extern bool comp_ptr_ttypes_const              (tree, tree);
+extern int ptr_reasonably_similar              (const_tree, const_tree);
 extern tree build_ptrmemfunc                   (tree, tree, int, bool);
-extern int cp_type_quals                       (tree);
-extern bool cp_has_mutable_p                   (tree);
-extern bool at_least_as_qualified_p            (tree, tree);
+extern int cp_type_quals                       (const_tree);
+extern bool cp_type_readonly                   (const_tree);
+extern bool cp_has_mutable_p                   (const_tree);
+extern bool at_least_as_qualified_p            (const_tree, const_tree);
 extern void cp_apply_type_quals_to_decl                (int, tree);
 extern tree build_ptrmemfunc1                  (tree, tree, tree);
 extern void expand_ptrmemfunc_cst              (tree, tree *, tree *);
@@ -4415,22 +4821,22 @@ extern tree build_address                       (tree);
 extern tree build_nop                          (tree, tree);
 extern tree non_reference                      (tree);
 extern tree lookup_anon_field                  (tree, tree);
-extern bool invalid_nonstatic_memfn_p          (tree);
+extern bool invalid_nonstatic_memfn_p          (const_tree);
 extern tree convert_member_func_to_ptr         (tree, tree);
 extern tree convert_ptrmem                     (tree, tree, bool, bool);
-extern int lvalue_or_else                      (tree, enum lvalue_use);
-extern int lvalue_p                            (tree);
+extern int lvalue_or_else                      (const_tree, enum lvalue_use);
+extern int lvalue_p                            (const_tree);
 
 /* in typeck2.c */
 extern void require_complete_eh_spec_types     (tree, tree);
-extern void cxx_incomplete_type_diagnostic     (tree, tree, int);
+extern void cxx_incomplete_type_diagnostic     (const_tree, const_tree, int);
 #undef cxx_incomplete_type_error
-extern void cxx_incomplete_type_error          (tree, tree);
+extern void cxx_incomplete_type_error          (const_tree, const_tree);
 #define cxx_incomplete_type_error(V,T) \
   (cxx_incomplete_type_diagnostic ((V), (T), 0))
 extern tree error_not_base_type                        (tree, tree);
 extern tree binfo_or_else                      (tree, tree);
-extern void readonly_error                     (tree, const char *, int);
+extern void readonly_error                     (tree, const char *);
 extern void complete_type_check_abstract       (tree);
 extern int abstract_virtuals_error             (tree, tree);
 
@@ -4462,14 +4868,15 @@ extern bool cp_dump_tree                        (void *, tree);
 
 /* In cp/cp-objcp-common.c.  */
 
-extern HOST_WIDE_INT cxx_get_alias_set         (tree);
-extern bool cxx_warn_unused_global_decl                (tree);
-extern tree cp_expr_size                       (tree);
+extern alias_set_type cxx_get_alias_set                (tree);
+extern bool cxx_warn_unused_global_decl                (const_tree);
+extern tree cp_expr_size                       (const_tree);
 extern size_t cp_tree_size                     (enum tree_code);
 extern bool cp_var_mod_type_p                  (tree, tree);
 extern void cxx_initialize_diagnostics         (struct diagnostic_context *);
 extern int cxx_types_compatible_p              (tree, tree);
 extern void init_shadowed_var_for_decl         (void);
+extern tree cxx_staticp                         (tree);
 
 /* in cp-gimplify.c */
 extern int cp_gimplify_expr                    (tree *, tree *, tree *);
@@ -4477,7 +4884,7 @@ extern void cp_genericize                 (tree);
 
 /* -- end of C++ */
 
-/* In order for the format checking to accept the C++ frontend
+/* In order for the format checking to accept the C++ front end
    diagnostic framework extensions, you must include this file before
    toplev.h, not after.  We override the definition of GCC_DIAG_STYLE
    in c-common.h.  */