OSDN Git Service

Restore canonical type comparison for dependent type(def)s
[pf3gnuchains/gcc-fork.git] / gcc / cp / cp-tree.h
index 469dcec..b46959b 100644 (file)
@@ -1,6 +1,6 @@
 /* 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, 2007, 2008, 2009
+   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
    Contributed by Michael Tiemann (tiemann@cygnus.com)
 
@@ -26,31 +26,25 @@ along with GCC; see the file COPYING3.  If not see
 #include "ggc.h"
 #include "function.h"
 #include "hashtab.h"
-#include "splay-tree.h"
 #include "vec.h"
-#include "varray.h"
-#include "c-common.h"
-#include "name-lookup.h"
 
 /* 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
+   diagnostic-core.h, not after.  We override the definition of GCC_DIAG_STYLE
    in c-common.h.  */
 #undef GCC_DIAG_STYLE
 #define GCC_DIAG_STYLE __gcc_cxxdiag__
-#if GCC_VERSION >= 4001
-#define ATTRIBUTE_GCC_CXXDIAG(m, n) __attribute__ ((__format__ (GCC_DIAG_STYLE, m, n))) ATTRIBUTE_NONNULL(m)
-#else
-#define ATTRIBUTE_GCC_CXXDIAG(m, n) ATTRIBUTE_NONNULL(m)
-#endif
-#ifdef GCC_TOPLEV_H
+#if defined(GCC_DIAGNOSTIC_CORE_H) || defined (GCC_C_COMMON_H)
 #error \
 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.
+framework extensions, you must include this file before diagnostic-core.h and \
+c-common.h, not after.
 #endif
-#include "toplev.h"
+#include "c-family/c-common.h"
 #include "diagnostic.h"
 
+#include "name-lookup.h"
+
 /* Usage of TREE_LANG_FLAG_?:
    0: IDENTIFIER_MARKED (IDENTIFIER_NODEs)
       NEW_EXPR_USE_GLOBAL (in NEW_EXPR).
@@ -74,7 +68,6 @@ framework extensions, you must include this file before toplev.h, not after.
       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)
       CONSTRUCTOR_IS_DIRECT_INIT (in CONSTRUCTOR)
       LAMBDA_EXPR_CAPTURES_THIS_P (in LAMBDA_EXPR)
@@ -121,7 +114,6 @@ framework extensions, you must include this file before toplev.h, not after.
    3: TYPE_FOR_JAVA.
    4: TYPE_HAS_NONTRIVIAL_DESTRUCTOR
    5: CLASS_TYPE_P (in RECORD_TYPE and UNION_TYPE)
-      SCOPED_ENUM_P (in ENUMERAL_TYPE)
    6: TYPE_DEPENDENT_P_VALID
 
    Usage of DECL_LANG_FLAG_?:
@@ -176,6 +168,9 @@ framework extensions, you must include this file before toplev.h, not after.
 
      The BV_FN is the declaration for the virtual function itself.
 
+     If BV_LOST_PRIMARY is set, it means that this entry is for a lost
+     primary virtual base and can be left null in the vtable.
+
    BINFO_VTABLE
      This is an expression with POINTER_TYPE that gives the value
      to which the vptr should be initialized.  Use get_vtbl_decl_for_binfo
@@ -241,15 +236,13 @@ struct GTY(()) template_parm_index_s {
   int index;
   int level;
   int orig_level;
+  int num_siblings;
   tree decl;
 };
 typedef struct template_parm_index_s template_parm_index;
 
 struct GTY(()) ptrmem_cst {
   struct tree_common common;
-  /* This isn't used, but the middle-end expects all constants to have
-     this field.  */
-  rtx rtl;
   tree member;
 };
 typedef struct ptrmem_cst * ptrmem_cst_t;
@@ -297,11 +290,6 @@ typedef struct ptrmem_cst * ptrmem_cst_t;
 #define same_type_p(TYPE1, TYPE2) \
   comptypes ((TYPE1), (TYPE2), COMPARE_STRICT)
 
-/* Returns nonzero iff TYPE1 and TYPE2 are the same type, ignoring
-   top-level qualifiers.  */
-#define same_type_ignoring_top_level_qualifiers_p(TYPE1, TYPE2) \
-  same_type_p (TYPE_MAIN_VARIANT (TYPE1), TYPE_MAIN_VARIANT (TYPE2))
-
 /* Nonzero if we are presently building a statement tree, rather
    than expanding each statement as we encounter it.  */
 #define building_stmt_tree()  (cur_stmt_list != NULL_TREE)
@@ -400,7 +388,9 @@ typedef enum cpp0x_warn_str
   /* scoped enums */
   CPP0X_SCOPED_ENUMS,
   /* defaulted and deleted functions */
-  CPP0X_DEFAULTED_DELETED
+  CPP0X_DEFAULTED_DELETED,
+  /* inline namespaces */
+  CPP0X_INLINE_NAMESPACES
 } cpp0x_warn_str;
   
 /* The various kinds of operation used by composite_pointer_type. */
@@ -428,6 +418,34 @@ typedef enum readonly_error_kind
   REK_DECREMENT
 } readonly_error_kind;
 
+/* Possible cases of expression list used by build_x_compound_expr_from_list. */
+typedef enum expr_list_kind {
+  ELK_INIT,            /* initializer */
+  ELK_MEM_INIT,                /* member initializer */
+  ELK_FUNC_CAST                /* functional cast */
+} expr_list_kind; 
+
+/* Possible cases of implicit bad rhs conversions. */
+typedef enum impl_conv_rhs {
+  ICR_DEFAULT_ARGUMENT, /* default argument */
+  ICR_CONVERTING,       /* converting */
+  ICR_INIT,             /* initialization */
+  ICR_ARGPASS,          /* argument passing */
+  ICR_RETURN,           /* return */
+  ICR_ASSIGN            /* assignment */
+} impl_conv_rhs;
+
+/* Possible cases of implicit or explicit bad conversions to void. */
+typedef enum impl_conv_void {
+  ICV_CAST,            /* (explicit) conversion to void */
+  ICV_SECOND_OF_COND,  /* second operand of conditional expression */
+  ICV_THIRD_OF_COND,   /* third operand of conditional expression */
+  ICV_RIGHT_OF_COMMA,  /* right operand of comma operator */
+  ICV_LEFT_OF_COMMA,   /* left operand of comma operator */
+  ICV_STATEMENT,       /* statement */
+  ICV_THIRD_IN_FOR     /* for increment expression */
+} impl_conv_void;
+
 /* Macros for access to language-specific slots in an identifier.  */
 
 #define IDENTIFIER_NAMESPACE_BINDINGS(NODE)    \
@@ -550,6 +568,7 @@ typedef enum cp_trait_kind
   CPTK_IS_POLYMORPHIC,
   CPTK_IS_STD_LAYOUT,
   CPTK_IS_TRIVIAL,
+  CPTK_IS_LITERAL_TYPE,
   CPTK_IS_UNION
 } cp_trait_kind;
 
@@ -768,6 +787,8 @@ enum cp_tree_index
     CPTI_LANG_NAME_JAVA,
 
     CPTI_EMPTY_EXCEPT_SPEC,
+    CPTI_NOEXCEPT_TRUE_SPEC,
+    CPTI_NOEXCEPT_FALSE_SPEC,
     CPTI_JCLASS,
     CPTI_TERMINATE,
     CPTI_CALL_UNEXPECTED,
@@ -778,6 +799,9 @@ enum cp_tree_index
 
     CPTI_KEYED_CLASSES,
 
+    CPTI_NULLPTR,
+    CPTI_NULLPTR_TYPE,
+
     CPTI_MAX
 };
 
@@ -812,6 +836,8 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
 #define abort_fndecl                   cp_global_trees[CPTI_ABORT_FNDECL]
 #define global_delete_fndecl           cp_global_trees[CPTI_GLOBAL_DELETE_FNDECL]
 #define current_aggr                   cp_global_trees[CPTI_AGGR_TAG]
+#define nullptr_node                   cp_global_trees[CPTI_NULLPTR]
+#define nullptr_type_node              cp_global_trees[CPTI_NULLPTR_TYPE]
 
 /* We cache these tree nodes so as to call get_identifier less
    frequently.  */
@@ -852,6 +878,8 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
 
 /* Exception specifier used for throw().  */
 #define empty_except_spec              cp_global_trees[CPTI_EMPTY_EXCEPT_SPEC]
+#define noexcept_true_spec             cp_global_trees[CPTI_NOEXCEPT_TRUE_SPEC]
+#define noexcept_false_spec            cp_global_trees[CPTI_NOEXCEPT_FALSE_SPEC]
 
 /* If non-NULL, a POINTER_TYPE equivalent to (java::lang::Class*).  */
 #define jclass_node                    cp_global_trees[CPTI_JCLASS]
@@ -897,7 +925,7 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
 struct GTY(()) saved_scope {
   VEC(cxx_saved_binding,gc) *old_bindings;
   tree old_namespace;
-  tree decl_ns_list;
+  VEC(tree,gc) *decl_ns_list;
   tree class_name;
   tree class_type;
   tree access_specifier;
@@ -1029,7 +1057,8 @@ struct GTY(()) language_function {
   (cfun && cp_function_chain                                   \
    ? cp_function_chain->x_current_class_ptr : NULL_TREE)
 #define current_class_ref \
-  (cfun ? cp_function_chain->x_current_class_ref : NULL_TREE)
+  ((cfun && cp_function_chain)                                  \
+   ? cp_function_chain->x_current_class_ref : NULL_TREE)
 
 /* The EH_SPEC_BLOCK for the exception-specifiers for the current
    function, if any.  */
@@ -1223,11 +1252,11 @@ struct GTY(()) lang_type_header {
   BOOL_BITFIELD is_lang_type_class : 1;
 
   BOOL_BITFIELD has_type_conversion : 1;
-  BOOL_BITFIELD has_init_ref : 1;
+  BOOL_BITFIELD has_copy_ctor : 1;
   BOOL_BITFIELD has_default_ctor : 1;
   BOOL_BITFIELD const_needs_init : 1;
   BOOL_BITFIELD ref_needs_init : 1;
-  BOOL_BITFIELD has_const_assign_ref : 1;
+  BOOL_BITFIELD has_const_copy_assign : 1;
 
   BOOL_BITFIELD spare : 1;
 };
@@ -1255,7 +1284,7 @@ struct GTY(()) lang_type_class {
   unsigned non_pod_class : 1;
   unsigned nearly_empty_p : 1;
   unsigned user_align : 1;
-  unsigned has_assign_ref : 1;
+  unsigned has_copy_assign : 1;
   unsigned has_new : 1;
   unsigned has_array_new : 1;
 
@@ -1281,19 +1310,24 @@ struct GTY(()) lang_type_class {
   unsigned was_anonymous : 1;
   unsigned lazy_default_ctor : 1;
   unsigned lazy_copy_ctor : 1;
-  unsigned lazy_assignment_op : 1;
+  unsigned lazy_copy_assign : 1;
   unsigned lazy_destructor : 1;
 
-  unsigned has_const_init_ref : 1;
-  unsigned has_complex_init_ref : 1;
-  unsigned has_complex_assign_ref : 1;
+  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;
-  unsigned lazy_move_ctor : 1;
   unsigned is_literal : 1;
 
+  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;
+
   /* When adding a flag here, consider whether or not it ought to
      apply to a template instance if it applies to the template.  If
      so, make sure to copy it in instantiate_class_template!  */
@@ -1301,7 +1335,7 @@ struct GTY(()) lang_type_class {
   /* 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 : 7;
+  unsigned dummy : 3;
 
   tree primary_base;
   VEC(tree_pair_s,gc) *vcall_indices;
@@ -1334,7 +1368,7 @@ struct GTY(()) lang_type_ptrmem {
   tree record;
 };
 
-struct GTY(()) lang_type {
+struct GTY((variable_size)) lang_type {
   union lang_type_u
   {
     struct lang_type_header GTY((skip (""))) h;
@@ -1396,8 +1430,13 @@ struct GTY(()) lang_type {
 
 /* Nonzero means that NODE (a class type) has an assignment operator
    -- but that it has not yet been declared.  */
-#define CLASSTYPE_LAZY_ASSIGNMENT_OP(NODE) \
-  (LANG_TYPE_CLASS_CHECK (NODE)->lazy_assignment_op)
+#define CLASSTYPE_LAZY_COPY_ASSIGN(NODE) \
+  (LANG_TYPE_CLASS_CHECK (NODE)->lazy_copy_assign)
+
+/* Nonzero means that NODE (a class type) has an assignment operator
+   -- but that it has not yet been declared.  */
+#define CLASSTYPE_LAZY_MOVE_ASSIGN(NODE) \
+  (LANG_TYPE_CLASS_CHECK (NODE)->lazy_move_assign)
 
 /* Nonzero means that NODE (a class type) has a destructor -- but that
    it has not yet been declared.  */
@@ -1405,22 +1444,28 @@ struct GTY(()) lang_type {
   (LANG_TYPE_CLASS_CHECK (NODE)->lazy_destructor)
 
 /* Nonzero means that this _CLASSTYPE node overloads operator=(X&).  */
-#define TYPE_HAS_ASSIGN_REF(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->has_assign_ref)
+#define TYPE_HAS_COPY_ASSIGN(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->has_copy_assign)
 
 /* True iff the class type NODE has an "operator =" whose parameter
    has a parameter of type "const X&".  */
-#define TYPE_HAS_CONST_ASSIGN_REF(NODE) \
-  (LANG_TYPE_CLASS_CHECK (NODE)->h.has_const_assign_ref)
+#define TYPE_HAS_CONST_COPY_ASSIGN(NODE) \
+  (LANG_TYPE_CLASS_CHECK (NODE)->h.has_const_copy_assign)
 
 /* Nonzero means that this _CLASSTYPE node has an X(X&) constructor.  */
-#define TYPE_HAS_INIT_REF(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->h.has_init_ref)
-#define TYPE_HAS_CONST_INIT_REF(NODE) \
-  (LANG_TYPE_CLASS_CHECK (NODE)->has_const_init_ref)
+#define TYPE_HAS_COPY_CTOR(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->h.has_copy_ctor)
+#define TYPE_HAS_CONST_COPY_CTOR(NODE) \
+  (LANG_TYPE_CLASS_CHECK (NODE)->has_const_copy_ctor)
 
 /* Nonzero if this class has an X(initializer_list<T>) constructor.  */
 #define TYPE_HAS_LIST_CTOR(NODE) \
   (LANG_TYPE_CLASS_CHECK (NODE)->has_list_ctor)
 
+/* Nonzero if this class has a constexpr constructor other than a copy/move
+   constructor.  Note that a class can have constexpr constructors for
+   static initialization even if it isn't a literal class.  */
+#define TYPE_HAS_CONSTEXPR_CTOR(NODE) \
+  (LANG_TYPE_CLASS_CHECK (NODE)->has_constexpr_ctor)
+
 /* Nonzero if this class defines an overloaded operator new.  (An
    operator new [] doesn't count.)  */
 #define TYPE_HAS_NEW_OPERATOR(NODE) \
@@ -1434,6 +1479,11 @@ struct GTY(()) lang_type {
    starting the definition of this type has been seen.  */
 #define TYPE_BEING_DEFINED(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->being_defined)
 
+/* Nonzero means that this type is either complete or being defined, so we
+   can do lookup in it.  */
+#define COMPLETE_OR_OPEN_TYPE_P(NODE) \
+  (COMPLETE_TYPE_P (NODE) || (CLASS_TYPE_P (NODE) && TYPE_BEING_DEFINED (NODE)))
+
 /* Mark bits for repeated base checks.  */
 #define TYPE_MARKED_P(NODE) TREE_LANG_FLAG_6 (TYPE_CHECK (NODE))
 
@@ -1727,17 +1777,24 @@ struct GTY(()) lang_type {
 /* The function to call.  */
 #define BV_FN(NODE) (TREE_VALUE (NODE))
 
+/* Whether or not this entry is for a lost primary virtual base.  */
+#define BV_LOST_PRIMARY(NODE) (TREE_LANG_FLAG_0 (NODE))
 \f
 /* For FUNCTION_TYPE or METHOD_TYPE, a list of the exceptions that
    this type can raise.  Each TREE_VALUE is a _TYPE.  The TREE_VALUE
    will be NULL_TREE to indicate a throw specification of `()', or
-   no exceptions allowed.  */
+   no exceptions allowed.  For a noexcept specification, TREE_VALUE
+   is NULL_TREE and TREE_PURPOSE is the constant-expression. */
 #define TYPE_RAISES_EXCEPTIONS(NODE) TYPE_LANG_SLOT_1 (NODE)
 
-/* For FUNCTION_TYPE or METHOD_TYPE, return 1 iff it is declared `throw()'.  */
-#define TYPE_NOTHROW_P(NODE) \
-  (TYPE_RAISES_EXCEPTIONS (NODE) \
-   && TREE_VALUE (TYPE_RAISES_EXCEPTIONS (NODE)) == NULL_TREE)
+/* For FUNCTION_TYPE or METHOD_TYPE, return 1 iff it is declared `throw()'
+   or noexcept(true).  */
+#define TYPE_NOTHROW_P(NODE) nothrow_spec_p (TYPE_RAISES_EXCEPTIONS (NODE))
+
+/* For FUNCTION_TYPE or METHOD_TYPE, true if NODE is noexcept.  This is the
+   case for things declared noexcept(true) and, with -fnothrow-opt, for
+   throw() functions.  */
+#define TYPE_NOEXCEPT_P(NODE) type_noexcept_p (NODE)
 
 /* The binding level associated with the namespace.  */
 #define NAMESPACE_LEVEL(NODE) \
@@ -1758,7 +1815,7 @@ struct GTY(()) lang_decl_base {
   unsigned threadprivate_or_deleted_p : 1; /* var or fn */
   unsigned anticipated_p : 1;             /* fn or type */
   unsigned friend_attr : 1;               /* fn or type */
-  unsigned template_conv_p : 1;                   /* template only? */
+  unsigned template_conv_p : 1;                   /* var or template */
   unsigned odr_used : 1;                  /* var or fn */
   unsigned u2sel : 1;
   /* 1 spare bit */
@@ -1875,7 +1932,7 @@ struct GTY(()) lang_decl_parm {
    union rather than a struct containing a union as its only field, but
    tree.h declares it as a struct.  */
 
-struct GTY(()) lang_decl {
+struct GTY((variable_size)) lang_decl {
   union GTY((desc ("%h.base.selector"))) lang_decl_u {
     struct lang_decl_base GTY ((default)) base;
     struct lang_decl_min GTY((tag ("0"))) min;
@@ -2041,9 +2098,9 @@ struct GTY(()) lang_decl {
   if (TREE_CODE (FN) == FUNCTION_DECL                  \
       && (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (FN)      \
          || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (FN)))   \
-     for (CLONE = TREE_CHAIN (FN);                     \
+     for (CLONE = DECL_CHAIN (FN);                     \
          CLONE && DECL_CLONED_FUNCTION_P (CLONE);      \
-         CLONE = TREE_CHAIN (CLONE))
+         CLONE = DECL_CHAIN (CLONE))
 
 /* Nonzero if NODE has DECL_DISCRIMINATOR and not DECL_ACCESS.  */
 #define DECL_DISCRIMINATOR_P(NODE)     \
@@ -2088,6 +2145,15 @@ struct GTY(()) lang_decl {
 #define DECL_TEMPLATE_CONV_FN_P(NODE) \
   (DECL_LANG_SPECIFIC (TEMPLATE_DECL_CHECK (NODE))->u.base.template_conv_p)
 
+/* Nonzero if NODE, a static data member, was declared in its class as an
+   array of unknown bound.  */
+#define VAR_HAD_UNKNOWN_BOUND(NODE)                    \
+  (DECL_LANG_SPECIFIC (VAR_DECL_CHECK (NODE))          \
+   ? DECL_LANG_SPECIFIC (NODE)->u.base.template_conv_p \
+   : false)
+#define SET_VAR_HAD_UNKNOWN_BOUND(NODE) \
+  (DECL_LANG_SPECIFIC (VAR_DECL_CHECK (NODE))->u.base.template_conv_p = true)
+
 /* Set the overloaded operator code for NODE to CODE.  */
 #define SET_OVERLOADED_OPERATOR_CODE(NODE, CODE) \
   (LANG_DECL_FN_CHECK (NODE)->operator_code = (CODE))
@@ -2142,23 +2208,6 @@ struct GTY(()) lang_decl {
 #define DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P(NODE) \
   (TREE_LANG_FLAG_2 (VAR_DECL_CHECK (NODE)))
 
-/* Nonzero for a VAR_DECL that can be used in an integral constant
-   expression.
-
-      [expr.const]
-
-      An integral constant-expression can only involve ... const
-      variables of static or enumeration types initialized with
-      constant expressions ...
-
-   The standard does not require that the expression be non-volatile.
-   G++ implements the proposed correction in DR 457.  */
-#define DECL_INTEGRAL_CONSTANT_VAR_P(NODE)             \
-  (TREE_CODE (NODE) == VAR_DECL                                \
-   && CP_TYPE_CONST_NON_VOLATILE_P (TREE_TYPE (NODE))  \
-   && INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (NODE))        \
-   && DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (NODE))
-
 /* Nonzero if the DECL was initialized in the class definition itself,
    rather than outside the class.  This is used for both static member
    VAR_DECLS, and FUNCTION_DECLS that are defined in the class.  */
@@ -2277,7 +2326,7 @@ struct GTY(()) lang_decl {
 
 /* True if DECL is declared 'constexpr'.  */
 #define DECL_DECLARED_CONSTEXPR_P(DECL) \
-  DECL_LANG_FLAG_8 (VAR_OR_FUNCTION_DECL_CHECK (DECL))
+  DECL_LANG_FLAG_8 (VAR_OR_FUNCTION_DECL_CHECK (STRIP_TEMPLATE (DECL)))
 
 /* Nonzero if this DECL is the __PRETTY_FUNCTION__ variable in a
    template function.  */
@@ -2305,12 +2354,12 @@ struct GTY(()) lang_decl {
 #define SET_DECL_FRIEND_CONTEXT(NODE, CONTEXT) \
   (LANG_DECL_FN_CHECK (NODE)->context = (CONTEXT))
 
-/* NULL_TREE in DECL_CONTEXT represents the global namespace.  */
 #define CP_DECL_CONTEXT(NODE) \
-  (DECL_CONTEXT (NODE) ? DECL_CONTEXT (NODE) : global_namespace)
+  (!DECL_FILE_SCOPE_P (NODE) ? DECL_CONTEXT (NODE) : global_namespace)
 #define CP_TYPE_CONTEXT(NODE) \
-  (TYPE_CONTEXT (NODE) ? TYPE_CONTEXT (NODE) : global_namespace)
-#define FROB_CONTEXT(NODE)   ((NODE) == global_namespace ? NULL_TREE : (NODE))
+  (!TYPE_FILE_SCOPE_P (NODE) ? TYPE_CONTEXT (NODE) : global_namespace)
+#define FROB_CONTEXT(NODE) \
+  ((NODE) == global_namespace ? DECL_CONTEXT (NODE) : (NODE))
 
 /* 1 iff NODE has namespace scope, including the global namespace.  */
 #define DECL_NAMESPACE_SCOPE_P(NODE)                           \
@@ -2320,6 +2369,10 @@ struct GTY(()) lang_decl {
 #define TYPE_NAMESPACE_SCOPE_P(NODE) \
   (TREE_CODE (CP_TYPE_CONTEXT (NODE)) == NAMESPACE_DECL)
 
+#define NAMESPACE_SCOPE_P(NODE) \
+  ((DECL_P (NODE) && DECL_NAMESPACE_SCOPE_P (NODE)) \
+   || (TYPE_P (NODE) && TYPE_NAMESPACE_SCOPE_P (NODE)))
+
 /* 1 iff NODE is a class member.  */
 #define DECL_CLASS_SCOPE_P(NODE) \
   (DECL_CONTEXT (NODE) && TYPE_P (DECL_CONTEXT (NODE)))
@@ -2493,6 +2546,23 @@ extern void decl_shadowed_for_var_insert (tree, tree);
 #define TI_TEMPLATE(NODE) TREE_TYPE (TEMPLATE_INFO_CHECK (NODE))
 #define TI_ARGS(NODE) TREE_CHAIN (TEMPLATE_INFO_CHECK (NODE))
 #define TI_PENDING_TEMPLATE_FLAG(NODE) TREE_LANG_FLAG_1 (NODE)
+/* For a given TREE_VEC containing a template argument list,
+   this property contains the number of arguments that are not
+   defaulted.  */
+#define NON_DEFAULT_TEMPLATE_ARGS_COUNT(NODE) TREE_CHAIN (TREE_VEC_CHECK (NODE))
+/* Below are the setter and getter of the NON_DEFAULT_TEMPLATE_ARGS_COUNT
+   property.  */
+#define SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT(NODE, INT_VALUE) \
+  NON_DEFAULT_TEMPLATE_ARGS_COUNT(NODE) = build_int_cst (NULL_TREE, INT_VALUE)
+#ifdef ENABLE_CHECKING
+#define GET_NON_DEFAULT_TEMPLATE_ARGS_COUNT(NODE) \
+    int_cst_value (NON_DEFAULT_TEMPLATE_ARGS_COUNT (NODE))
+#else
+#define GET_NON_DEFAULT_TEMPLATE_ARGS_COUNT(NODE) \
+  NON_DEFAULT_TEMPLATE_ARGS_COUNT (NODE) \
+  ? int_cst_value (NON_DEFAULT_TEMPLATE_ARGS_COUNT (NODE)) \
+  : TREE_VEC_LENGTH (INNERMOST_TEMPLATE_ARGS (NODE))
+#endif
 /* The list of typedefs - used in the template - that need
    access checking at template instantiation time.  */
 #define TI_TYPEDEFS_NEEDING_ACCESS_CHECKING(NODE) \
@@ -2509,7 +2579,13 @@ extern void decl_shadowed_for_var_insert (tree, tree);
 
    It is incorrect to ever form a template argument vector containing
    only one level of arguments, but which is a TREE_VEC containing as
-   its only entry the TREE_VEC for that level.  */
+   its only entry the TREE_VEC for that level.
+
+   For each TREE_VEC containing the template arguments for a single
+   level, it's possible to get or set the number of non defaulted
+   template arguments by using the accessor macros
+   GET_NON_DEFAULT_TEMPLATE_ARGS_COUNT or
+   SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT.  */
 
 /* Nonzero if the template arguments is actually a vector of vectors,
    rather than just a vector.  */
@@ -2966,10 +3042,14 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
    || TREE_CODE (TYPE) == REAL_TYPE \
    || TREE_CODE (TYPE) == COMPLEX_TYPE)
 
+/* True iff TYPE is cv decltype(nullptr).  */
+#define NULLPTR_TYPE_P(TYPE) (TREE_CODE (TYPE) == NULLPTR_TYPE)
+
 /* [basic.types]
 
-   Arithmetic types, enumeration types, pointer types, and
-   pointer-to-member types, are collectively called scalar types.
+   Arithmetic types, enumeration types, pointer types,
+   pointer-to-member types, and std::nullptr_t are collectively called
+   scalar types.
    
    Keep these checks in ascending code order.  */
 #define SCALAR_TYPE_P(TYPE)                    \
@@ -2977,7 +3057,8 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
    || TREE_CODE (TYPE) == ENUMERAL_TYPE                \
    || ARITHMETIC_TYPE_P (TYPE)                 \
    || TYPE_PTR_P (TYPE)                                \
-   || TYPE_PTRMEMFUNC_P (TYPE))
+   || TYPE_PTRMEMFUNC_P (TYPE)                  \
+   || NULLPTR_TYPE_P (TYPE))
 
 /* Determines whether this type is a C++0x scoped enumeration
    type. Scoped enumerations types are introduced via "enum class" or
@@ -3000,17 +3081,27 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
 
      - The underlying type of the enum is well-defined.  */
 #define SCOPED_ENUM_P(TYPE)                                             \
-  (TREE_CODE (TYPE) == ENUMERAL_TYPE && TYPE_LANG_FLAG_5 (TYPE))
+  (TREE_CODE (TYPE) == ENUMERAL_TYPE && ENUM_IS_SCOPED (TYPE))
 
 /* Determine whether this is an unscoped enumeration type.  */
 #define UNSCOPED_ENUM_P(TYPE)                                           \
-  (TREE_CODE (TYPE) == ENUMERAL_TYPE && !TYPE_LANG_FLAG_5 (TYPE))
+  (TREE_CODE (TYPE) == ENUMERAL_TYPE && !ENUM_IS_SCOPED (TYPE))
 
 /* Set the flag indicating whether an ENUMERAL_TYPE is a C++0x scoped
    enumeration type (1) or a normal (unscoped) enumeration type
    (0).  */
 #define SET_SCOPED_ENUM_P(TYPE, VAL)                    \
-  (TYPE_LANG_FLAG_5 (ENUMERAL_TYPE_CHECK (TYPE)) = (VAL))
+  (ENUM_IS_SCOPED (TYPE) = (VAL))
+
+#define SET_OPAQUE_ENUM_P(TYPE, VAL)                    \
+  (ENUM_IS_OPAQUE (TYPE) = (VAL))
+
+#define OPAQUE_ENUM_P(TYPE)                            \
+  (TREE_CODE (TYPE) == ENUMERAL_TYPE && ENUM_IS_OPAQUE (TYPE))
+
+/* Determines whether an ENUMERAL_TYPE has an explicit
+   underlying type.  */
+#define ENUM_FIXED_UNDERLYING_TYPE_P(NODE) (TYPE_LANG_FLAG_3 (NODE))
 
 /* Returns the underlying type of the given enumeration type. The
    underlying type is determined in different ways, depending on the
@@ -3090,13 +3181,19 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
 #define TYPE_NON_AGGREGATE_CLASS(NODE) \
   (CLASS_TYPE_P (NODE) && CLASSTYPE_NON_AGGREGATE (NODE))
 
-/* 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 non-trivial X::op=(cv X&) for this class.  */
+#define TYPE_HAS_COMPLEX_COPY_ASSIGN(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->has_complex_copy_assign)
+
+/* Nonzero if there is a non-trivial X::X(cv X&) for this class.  */
+#define TYPE_HAS_COMPLEX_COPY_CTOR(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->has_complex_copy_ctor)
+
+/* Nonzero if there is a non-trivial X::op=(X&&) for this class.  */
+#define TYPE_HAS_COMPLEX_MOVE_ASSIGN(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->has_complex_move_assign)
 
-/* 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 non-trivial X::X(X&&) for this class.  */
+#define TYPE_HAS_COMPLEX_MOVE_CTOR(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->has_complex_move_ctor)
 
-/* Nonzero if there is a user-defined default constructor for this class.  */
+/* Nonzero if there is a non-trivial 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]:
@@ -3126,13 +3223,13 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
 
 /* Nonzero for class type means that copy initialization of this type can use
    a bitwise copy.  */
-#define TYPE_HAS_TRIVIAL_INIT_REF(NODE) \
-  (TYPE_HAS_INIT_REF (NODE) && ! TYPE_HAS_COMPLEX_INIT_REF (NODE))
+#define TYPE_HAS_TRIVIAL_COPY_CTOR(NODE) \
+  (TYPE_HAS_COPY_CTOR (NODE) && ! TYPE_HAS_COMPLEX_COPY_CTOR (NODE))
 
 /* Nonzero for class type means that assignment of this type can use
    a bitwise copy.  */
-#define TYPE_HAS_TRIVIAL_ASSIGN_REF(NODE) \
-  (TYPE_HAS_ASSIGN_REF (NODE) && ! TYPE_HAS_COMPLEX_ASSIGN_REF (NODE))
+#define TYPE_HAS_TRIVIAL_COPY_ASSIGN(NODE) \
+  (TYPE_HAS_COPY_ASSIGN (NODE) && ! TYPE_HAS_COMPLEX_COPY_ASSIGN (NODE))
 
 /* Returns true if NODE is a pointer-to-data-member.  */
 #define TYPE_PTRMEM_P(NODE)                    \
@@ -3165,10 +3262,6 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
 #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)                                    \
@@ -3223,8 +3316,8 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
   do {                                                                 \
     if (TYPE_LANG_SPECIFIC (NODE) == NULL)                             \
       {                                                                        \
-       TYPE_LANG_SPECIFIC (NODE) = GGC_CNEWVAR                         \
-        (struct lang_type, sizeof (struct lang_type_ptrmem));          \
+       TYPE_LANG_SPECIFIC (NODE) = ggc_alloc_cleared_lang_type         \
+        (sizeof (struct lang_type_ptrmem));                            \
        TYPE_LANG_SPECIFIC (NODE)->u.ptrmem.h.is_lang_type_class = 0;   \
       }                                                                        \
     TYPE_LANG_SPECIFIC (NODE)->u.ptrmem.record = (VALUE);              \
@@ -3310,8 +3403,6 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
 #define ANON_UNION_TYPE_P(NODE) \
   (TREE_CODE (NODE) == UNION_TYPE && ANON_AGGR_TYPE_P (NODE))
 
-#define UNKNOWN_TYPE LANG_TYPE
-
 /* Define fields and accessors for nodes representing declared names.  */
 
 #define TYPE_WAS_ANONYMOUS(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->was_anonymous)
@@ -3711,6 +3802,12 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
 #define FOR_EXPR(NODE)         TREE_OPERAND (FOR_STMT_CHECK (NODE), 2)
 #define FOR_BODY(NODE)         TREE_OPERAND (FOR_STMT_CHECK (NODE), 3)
 
+/* RANGE_FOR_STMT accessors. These give access to the declarator,
+   expression and body of the statement, respectively.  */
+#define RANGE_FOR_DECL(NODE)   TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 0)
+#define RANGE_FOR_EXPR(NODE)   TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 1)
+#define RANGE_FOR_BODY(NODE)   TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 2)
+
 #define SWITCH_STMT_COND(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 0)
 #define SWITCH_STMT_BODY(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 1)
 #define SWITCH_STMT_TYPE(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 2)
@@ -3804,7 +3901,8 @@ typedef enum special_function_kind {
   sfk_constructor,        /* A constructor.  */
   sfk_copy_constructor,    /* A copy constructor.  */
   sfk_move_constructor,    /* A move constructor.  */
-  sfk_assignment_operator, /* An assignment operator.  */
+  sfk_copy_assignment,     /* A copy assignment operator.  */
+  sfk_move_assignment,     /* A move assignment operator.  */
   sfk_destructor,         /* A destructor.  */
   sfk_complete_destructor, /* A destructor for complete objects.  */
   sfk_base_destructor,     /* A destructor for base subobjects.  */
@@ -3837,6 +3935,13 @@ typedef enum linkage_kind {
   lk_external                  /* External linkage.  */
 } linkage_kind;
 
+typedef enum duration_kind {
+  dk_static,
+  dk_thread,
+  dk_auto,
+  dk_dynamic
+} duration_kind;
+
 /* Bitmask flags to control type substitution.  */
 enum tsubst_flags {
   tf_none = 0,                  /* nothing special */
@@ -3907,7 +4012,6 @@ typedef enum base_kind {
 
 /* For building calls to `delete'.  */
 extern GTY(()) tree integer_two_node;
-extern GTY(()) tree integer_three_node;
 
 /* The number of function bodies which we are currently processing.
    (Zero if we are at namespace scope, one inside the body of a
@@ -3921,6 +4025,7 @@ extern int function_depth;
    sizeof can be nested.  */
 
 extern int cp_unevaluated_operand;
+extern tree cp_convert_range_for (tree, tree, tree);
 
 /* in pt.c  */
 
@@ -4075,8 +4180,8 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, TYPENAME_FLAG };
    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.)  */
+/* We're performing a user-defined conversion, so more user-defined
+   conversions are not permitted (only built-in conversions).  */
 #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
@@ -4099,10 +4204,24 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, TYPENAME_FLAG };
 /* We're inside an init-list, so narrowing conversions are ill-formed.  */
 #define LOOKUP_NO_NARROWING (LOOKUP_PREFER_RVALUE << 1)
 /* Avoid user-defined conversions for the first parameter of a copy
-   constructor.  */
+   constructor (or move constructor).  */
 #define LOOKUP_NO_COPY_CTOR_CONVERSION (LOOKUP_NO_NARROWING << 1)
 /* This is the first parameter of a copy constructor.  */
 #define LOOKUP_COPY_PARM (LOOKUP_NO_COPY_CTOR_CONVERSION << 1)
+/* We only want to consider list constructors.  */
+#define LOOKUP_LIST_ONLY (LOOKUP_COPY_PARM << 1)
+/* Return after determining which function to call and checking access.
+   Used by sythesized_method_walk to determine which functions will
+   be called to initialize subobjects, in order to determine exception
+   specification and possible implicit delete.
+   This is kind of a hack, but since access control doesn't respect SFINAE
+   we can't just use tf_none to avoid access control errors, we need
+   another mechanism.  Exiting early also avoids problems with trying
+   to perform argument conversions when the class isn't complete yet.  */
+#define LOOKUP_SPECULATIVE (LOOKUP_LIST_ONLY << 1)
+/* Used in calls to store_init_value to suppress its usual call to
+   digest_init.  */
+#define LOOKUP_ALREADY_DIGESTED (LOOKUP_SPECULATIVE << 1)
 
 #define LOOKUP_NAMESPACES_ONLY(F)  \
   (((F) & LOOKUP_PREFER_NAMESPACES) && !((F) & LOOKUP_PREFER_TYPES))
@@ -4140,8 +4259,8 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, TYPENAME_FLAG };
 #define WANT_ENUM      4 /* enumerated types */
 #define WANT_POINTER   8 /* pointer types */
 #define WANT_NULL      16 /* null pointer constant */
-#define WANT_VECTOR    32 /* vector types */
-#define WANT_ARITH     (WANT_INT | WANT_FLOAT | WANT_VECTOR)
+#define WANT_VECTOR_OR_COMPLEX 32 /* vector or complex types */
+#define WANT_ARITH     (WANT_INT | WANT_FLOAT | WANT_VECTOR_OR_COMPLEX)
 
 /* Used with comptypes, and related functions, to guide type
    comparison.  */
@@ -4192,6 +4311,9 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, TYPENAME_FLAG };
        ((template_parm_index*)TEMPLATE_PARM_INDEX_CHECK (NODE))
 #define TEMPLATE_PARM_IDX(NODE) (TEMPLATE_PARM_INDEX_CAST (NODE)->index)
 #define TEMPLATE_PARM_LEVEL(NODE) (TEMPLATE_PARM_INDEX_CAST (NODE)->level)
+/* The Number of sibling parms this template parm has.  */
+#define TEMPLATE_PARM_NUM_SIBLINGS(NODE) \
+  (TEMPLATE_PARM_INDEX_CAST (NODE)->num_siblings)
 #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)
@@ -4324,14 +4446,14 @@ typedef enum cp_decl_spec {
 typedef struct cp_decl_specifier_seq {
   /* The number of times each of the keywords has been seen.  */
   unsigned specs[(int) ds_last];
+  /* The location of the primary type. Mainly used for error
+     reporting.  */
+  location_t type_location;
   /* The primary type, if any, given by the decl-specifier-seq.
      Modifiers, like "short", "const", and "unsigned" are not
      reflected here.  This field will be a TYPE, unless a typedef-name
      was used, in which case it will be a TYPE_DECL.  */
   tree type;
-  /* The location of the primary type. Mainly used for error
-     reporting.  */
-  location_t type_location;
   /* The attributes, if any, provided with the specifier sequence.  */
   tree attributes;
   /* If non-NULL, a built-in type that the user attempted to redefine
@@ -4355,6 +4477,8 @@ typedef struct cp_decl_specifier_seq {
   BOOL_BITFIELD any_type_specifiers_p : 1;
   /* True iff "int" was explicitly provided.  */
   BOOL_BITFIELD explicit_int_p : 1;
+  /* True iff "__int128" was explicitly provided.  */
+  BOOL_BITFIELD explicit_int128_p : 1;
   /* True iff "char" was explicitly provided.  */
   BOOL_BITFIELD explicit_char_p : 1;
 } cp_decl_specifier_seq;
@@ -4399,12 +4523,12 @@ struct cp_declarator {
   /* Whether we parsed an ellipsis (`...') just before the declarator,
      to indicate this is a parameter pack.  */
   BOOL_BITFIELD parameter_pack_p : 1;
+  location_t id_loc; /* Currently only set for cdk_id and cdk_function. */
   /* Attributes that apply to this declarator.  */
   tree attributes;
   /* For all but cdk_id and cdk_error, the contained declarator.  For
      cdk_id and cdk_error, guaranteed to be NULL.  */
   cp_declarator *declarator;
-  location_t id_loc; /* Currently only set for cdk_id and cdk_function. */
   union {
     /* For identifiers.  */
     struct {
@@ -4521,6 +4645,7 @@ extern tree strip_top_quals                       (tree);
 extern bool reference_related_p                        (tree, tree);
 extern tree perform_implicit_conversion                (tree, tree, tsubst_flags_t);
 extern tree perform_implicit_conversion_flags  (tree, tree, tsubst_flags_t, int);
+extern tree build_integral_nontype_arg_conv    (tree, tree, tsubst_flags_t);
 extern tree perform_direct_initialization_if_possible (tree, tree, bool,
                                                        tsubst_flags_t);
 extern tree in_charge_arg_for_name             (tree);
@@ -4535,7 +4660,8 @@ extern void validate_conversion_obstack           (void);
 extern tree build_vfield_ref                   (tree, tree);
 extern tree build_base_path                    (enum tree_code, tree,
                                                 tree, int);
-extern tree convert_to_base                    (tree, tree, bool, bool);
+extern tree convert_to_base                    (tree, tree, bool, bool,
+                                                tsubst_flags_t);
 extern tree convert_to_base_statically         (tree, tree);
 extern tree build_vtbl_ref                     (tree, tree);
 extern tree build_vfn_ref                      (tree, tree);
@@ -4545,6 +4671,7 @@ extern void resort_type_method_vec                (void *, void *,
 extern bool add_method                         (tree, tree, tree);
 extern bool currently_open_class               (tree);
 extern tree currently_open_derived_class       (tree);
+extern tree current_nonlambda_class_type       (void);
 extern tree finish_struct                      (tree, tree);
 extern void finish_struct_1                    (tree);
 extern int resolves_to_fixed_type_p            (tree, int *);
@@ -4577,12 +4704,19 @@ extern void check_for_override                  (tree, tree);
 extern void push_class_stack                   (void);
 extern void pop_class_stack                    (void);
 extern bool type_has_user_nondefault_constructor (tree);
+extern tree in_class_defaulted_default_constructor (tree);
 extern bool user_provided_p                    (tree);
 extern bool type_has_user_provided_constructor  (tree);
 extern bool type_has_user_provided_default_constructor (tree);
+extern bool synthesized_default_constructor_is_constexpr (tree);
+extern bool type_has_constexpr_default_constructor (tree);
+extern bool type_has_virtual_destructor                (tree);
+extern bool type_has_move_constructor          (tree);
+extern bool type_has_move_assign               (tree);
 extern void defaulted_late_check               (tree);
 extern bool defaultable_fn_check               (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, int);
 extern void adjust_clone_args                  (tree);
@@ -4595,8 +4729,8 @@ extern tree ocp_convert                           (tree, tree, int, int);
 extern tree cp_convert                         (tree, tree);
 extern tree cp_convert_and_check                (tree, tree);
 extern tree cp_fold_convert                    (tree, tree);
-extern tree convert_to_void    (tree, const char */*implicit context*/,
-                                 tsubst_flags_t);
+extern tree convert_to_void                    (tree, impl_conv_void,
+                                                tsubst_flags_t);
 extern tree convert_force                      (tree, tree, int);
 extern tree build_expr_type_conversion         (int, tree, bool);
 extern tree type_promotes_to                   (tree);
@@ -4613,6 +4747,7 @@ extern tree pushdecl_top_level_and_finish (tree, tree);
 extern tree check_for_out_of_scope_variable    (tree);
 extern void print_other_binding_stack          (struct cp_binding_level *);
 extern tree maybe_push_decl                    (tree);
+extern tree current_decl_namespace             (void);
 
 /* decl.c */
 extern tree poplevel                           (int, int, int);
@@ -4657,9 +4792,10 @@ 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 bool xref_basetypes                     (tree, tree);
-extern tree start_enum                         (tree, tree, bool);
+extern tree start_enum                         (tree, tree, tree, bool, bool *);
+extern void finish_enum_value_list             (tree);
 extern void finish_enum                                (tree);
-extern void build_enumerator                   (tree, tree, tree);
+extern void build_enumerator                   (tree, tree, tree, location_t);
 extern tree lookup_enumerator                  (tree, tree);
 extern void start_preparsed_function           (tree, tree, int);
 extern int start_function                      (cp_decl_specifier_seq *, const cp_declarator *, tree);
@@ -4676,7 +4812,7 @@ extern tree static_fn_type                        (tree);
 extern void revert_static_member_fn            (tree);
 extern void fixup_anonymous_aggr               (tree);
 extern int check_static_variable_definition    (tree, tree);
-extern tree compute_array_index_type           (tree, tree);
+extern tree compute_array_index_type           (tree, tree, tsubst_flags_t);
 extern tree check_default_argument             (tree, tree);
 typedef int (*walk_namespaces_fn)              (tree, void *);
 extern int walk_namespaces                     (walk_namespaces_fn,
@@ -4693,9 +4829,10 @@ 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 void initialize_artificial_var          (tree, tree);
+extern void initialize_artificial_var          (tree, VEC(constructor_elt,gc) *);
 extern tree check_var_type                     (tree, tree);
 extern tree reshape_init (tree, tree);
+extern tree next_initializable_field (tree);
 
 extern bool defer_mark_used_calls;
 extern GTY(()) VEC(tree, gc) *deferred_mark_used_calls;
@@ -4705,9 +4842,10 @@ extern tree cxx_maybe_build_cleanup              (tree);
 /* in decl2.c */
 extern bool check_java_method                  (tree);
 extern tree build_memfn_type                   (tree, tree, cp_cv_quals);
+extern tree change_return_type                 (tree, tree);
 extern void maybe_retrofit_in_chrg             (tree);
 extern void maybe_make_one_only                        (tree);
-extern bool vague_linkage_fn_p                 (tree);
+extern bool vague_linkage_p                    (tree);
 extern void grokclassfn                                (tree, tree,
                                                 enum overload_flags);
 extern tree grok_array_decl                    (tree, tree);
@@ -4730,6 +4868,8 @@ extern void constrain_class_visibility            (tree);
 extern void import_export_decl                 (tree);
 extern tree build_cleanup                      (tree);
 extern tree build_offset_ref_call_from_tree    (tree, VEC(tree,gc) **);
+extern bool decl_constant_var_p                        (tree);
+extern bool decl_maybe_constant_var_p          (tree);
 extern void check_default_args                 (tree);
 extern void mark_used                          (tree);
 extern void finish_static_data_member_decl     (tree, tree, bool, tree, int);
@@ -4758,7 +4898,7 @@ extern const char *class_key_or_enum_as_string    (tree);
 extern void print_instantiation_context                (void);
 extern void maybe_warn_variadic_templates       (void);
 extern void maybe_warn_cpp0x                   (cpp0x_warn_str str);
-extern bool pedwarn_cxx98                       (location_t, int, const char *, ...) ATTRIBUTE_GCC_CXXDIAG(3,4);
+extern bool pedwarn_cxx98                       (location_t, int, const char *, ...) ATTRIBUTE_GCC_DIAG(3,4);
 
 /* in except.c */
 extern void init_exception_processing          (void);
@@ -4768,14 +4908,25 @@ extern tree build_exc_ptr                       (void);
 extern tree build_throw                                (tree);
 extern int nothrow_libfn_p                     (const_tree);
 extern void check_handlers                     (tree);
+extern tree finish_noexcept_expr               (tree, tsubst_flags_t);
+extern void perform_deferred_noexcept_checks   (void);
+extern bool nothrow_spec_p                     (const_tree);
+extern bool type_noexcept_p                    (const_tree);
+extern bool type_throw_all_p                   (const_tree);
+extern tree build_noexcept_spec                        (tree, int);
 extern void choose_personality_routine         (enum languages);
 extern tree eh_type_info                       (tree);
 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);
 
 /* in expr.c */
 extern tree cplus_expand_constant              (tree);
+extern tree mark_rvalue_use                    (tree);
+extern tree mark_lvalue_use                    (tree);
+extern tree mark_type_use                      (tree);
+extern void mark_exp_read                      (tree);
 
 /* friend.c */
 extern int is_friend                           (tree, tree);
@@ -4791,8 +4942,8 @@ extern tree build_aggr_init                       (tree, tree, int,
 extern int is_class_type                       (tree, int);
 extern tree get_type_value                     (tree);
 extern tree build_zero_init                    (tree, tree, bool);
-extern tree build_value_init                   (tree);
-extern tree build_value_init_noctor            (tree);
+extern tree build_value_init                   (tree, tsubst_flags_t);
+extern tree build_value_init_noctor            (tree, tsubst_flags_t);
 extern tree build_offset_ref                   (tree, tree, bool);
 extern tree build_new                          (VEC(tree,gc) **, tree, tree,
                                                 VEC(tree,gc) **, int,
@@ -4809,6 +4960,7 @@ extern tree create_temporary_var          (tree);
 extern void initialize_vtbl_ptrs               (tree);
 extern tree build_java_class_ref               (tree);
 extern tree integral_constant_value            (tree);
+extern int diagnose_uninitialized_cst_or_ref_member (tree, bool, bool);
 
 /* in lex.c */
 extern void cxx_dup_lang_specific_decl         (tree);
@@ -4817,6 +4969,7 @@ extern void yyungetc                              (int, int);
 extern tree unqualified_name_lookup_error      (tree);
 extern tree unqualified_fn_lookup_error                (tree);
 extern tree build_lang_decl                    (enum tree_code, tree, tree);
+extern tree build_lang_decl_loc                        (location_t, enum tree_code, tree, tree);
 extern void retrofit_lang_decl                 (tree);
 extern tree copy_decl                          (tree);
 extern tree copy_type                          (tree);
@@ -4831,15 +4984,19 @@ extern void init_method                         (void);
 extern tree make_thunk                         (tree, bool, tree, tree);
 extern void finish_thunk                       (tree);
 extern void use_thunk                          (tree, bool);
+extern bool trivial_fn_p                       (tree);
+extern bool maybe_explain_implicit_delete      (tree);
 extern void synthesize_method                  (tree);
 extern tree lazily_declare_fn                  (special_function_kind,
                                                 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 *);
+extern tree get_copy_ctor                      (tree);
+extern tree get_copy_assign                    (tree);
+extern tree get_default_ctor                   (tree);
+extern tree get_dtor                           (tree);
+extern tree locate_ctor                                (tree);
 
 /* In optimize.c */
 extern bool maybe_clone_body                   (tree);
@@ -4865,9 +5022,10 @@ extern void append_type_to_template_for_access_check (tree, tree, tree,
 extern tree splice_late_return_type            (tree, tree);
 extern bool is_auto                            (const_tree);
 extern tree process_template_parm              (tree, location_t, tree, 
-                                                bool, bool);
+                                                bool, bool, unsigned);
 extern tree end_template_parm_list             (tree);
 extern void end_template_decl                  (void);
+extern tree maybe_update_decl_type             (tree, tree);
 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);
@@ -4936,16 +5094,21 @@ extern void make_args_non_dependent             (VEC(tree,gc) *);
 extern bool reregister_specialization          (tree, tree, tree);
 extern tree fold_non_dependent_expr            (tree);
 extern bool explicit_class_specialization_p     (tree);
+extern int push_tinst_level                     (tree);
+extern void pop_tinst_level                     (void);
 extern struct tinst_level *outermost_tinst_level(void);
 extern bool parameter_of_template_p            (tree, tree);
 extern void init_template_processing           (void);
+extern void print_template_statistics          (void);
 bool template_template_parameter_p             (const_tree);
 extern bool primary_template_instantiation_p    (const_tree);
 extern tree get_primary_template_innermost_parameters  (const_tree);
+extern tree get_template_parms_at_level (tree, int);
 extern tree get_template_innermost_arguments   (const_tree);
 extern tree get_template_argument_pack_elems   (const_tree);
 extern tree get_function_template_decl         (const_tree);
 extern tree resolve_nondeduced_context         (tree);
+extern hashval_t iterative_hash_template_arg (tree arg, hashval_t val);
 
 /* in repo.c */
 extern void init_repo                          (void);
@@ -4975,6 +5138,7 @@ extern int accessible_p                           (tree, tree, bool);
 extern tree lookup_field_1                     (tree, tree, bool);
 extern tree lookup_field                       (tree, tree, int, bool);
 extern int lookup_fnfields_1                   (tree, tree);
+extern tree lookup_fnfields_slot               (tree, tree);
 extern int class_method_index_for_fn           (tree, tree);
 extern tree lookup_fnfields                    (tree, tree, int);
 extern tree lookup_member                      (tree, tree, int, bool);
@@ -4989,7 +5153,7 @@ extern int at_function_scope_p                    (void);
 extern bool at_class_scope_p                   (void);
 extern bool at_namespace_scope_p               (void);
 extern tree context_for_name_lookup            (tree);
-extern tree lookup_conversions                 (tree);
+extern tree lookup_conversions                 (tree, bool);
 extern tree binfo_from_vbase                   (tree);
 extern tree binfo_for_vbase                    (tree, tree);
 extern tree look_for_overrides_here            (tree, tree);
@@ -5053,6 +5217,9 @@ extern void finish_for_init_stmt          (tree);
 extern void finish_for_cond                    (tree, tree);
 extern void finish_for_expr                    (tree, tree);
 extern void finish_for_stmt                    (tree);
+extern tree begin_range_for_stmt               (void);
+extern void finish_range_for_decl              (tree, tree, tree);
+extern void finish_range_for_stmt              (tree);
 extern tree finish_break_stmt                  (void);
 extern tree finish_continue_stmt               (void);
 extern tree begin_switch_stmt                  (void);
@@ -5072,7 +5239,14 @@ extern void finish_handler                       (tree);
 extern void finish_cleanup                     (tree, tree);
 extern bool literal_type_p (tree);
 extern tree validate_constexpr_fundecl (tree);
+extern tree register_constexpr_fundef (tree, tree);
 extern tree ensure_literal_type_for_constexpr_object (tree);
+extern tree cxx_constant_value (tree);
+extern tree maybe_constant_value (tree);
+extern tree maybe_constant_init (tree);
+extern bool is_sub_constant_expr (tree);
+extern bool reduced_constant_expression_p (tree);
+extern VEC(tree,heap)* cx_error_context (void);
 
 enum {
   BCS_NO_SCOPE = 1,
@@ -5093,7 +5267,7 @@ extern tree finish_stmt_expr_expr         (tree, tree);
 extern tree finish_stmt_expr                   (tree, bool);
 extern tree stmt_expr_value_expr               (tree);
 bool empty_expr_stmt_p                         (tree);
-extern tree perform_koenig_lookup              (tree, VEC(tree,gc) *);
+extern tree perform_koenig_lookup              (tree, VEC(tree,gc) *, bool);
 extern tree finish_call_expr                   (tree, VEC(tree,gc) **, bool,
                                                 bool, tsubst_flags_t);
 extern tree finish_increment_expr              (tree, enum tree_code);
@@ -5165,7 +5339,9 @@ extern tree lambda_function                       (tree);
 extern void apply_lambda_return_type            (tree, tree);
 extern tree add_capture                         (tree, tree, tree, bool, bool);
 extern tree add_default_capture                 (tree, tree, tree);
+extern void register_capture_members           (tree);
 extern tree lambda_expr_this_capture            (tree);
+extern tree nonlambda_method_basetype          (void);
 extern void maybe_add_lambda_conv_op            (tree);
 
 /* in tree.c */
@@ -5184,17 +5360,17 @@ extern bool pod_type_p                          (const_tree);
 extern bool layout_pod_type_p                  (const_tree);
 extern bool std_layout_type_p                  (const_tree);
 extern bool trivial_type_p                     (const_tree);
+extern bool trivially_copyable_p               (const_tree);
 extern bool type_has_nontrivial_default_init   (const_tree);
 extern bool type_has_nontrivial_copy_init      (const_tree);
 extern bool class_tmpl_impl_spec_p             (const_tree);
 extern int zero_init_p                         (const_tree);
 extern tree strip_typedefs                     (tree);
-extern bool typedef_variant_p                  (tree);
-extern void cp_set_underlying_type             (tree);
 extern tree copy_binfo                         (tree, tree, tree,
                                                 tree *, int);
 extern int member_p                            (const_tree);
-extern cp_lvalue_kind real_lvalue_p            (tree);
+extern cp_lvalue_kind real_lvalue_p            (const_tree);
+extern cp_lvalue_kind lvalue_kind              (const_tree);
 extern bool lvalue_or_rvalue_with_address_p    (const_tree);
 extern bool builtin_valid_in_constant_expr_p    (const_tree);
 extern tree build_min                          (enum tree_code, tree, ...);
@@ -5207,10 +5383,12 @@ extern tree get_target_expr                     (tree);
 extern tree build_cplus_array_type             (tree, tree);
 extern tree build_array_of_n_type              (tree, int);
 extern tree build_array_copy                   (tree);
+extern tree build_vec_init_expr                        (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 int is_overloaded_fn                    (tree);
+extern tree get_fns                            (tree);
 extern tree get_first_fn                       (tree);
 extern tree ovl_cons                           (tree, tree);
 extern tree build_overload                     (tree, tree);
@@ -5249,6 +5427,7 @@ extern int count_trees                            (tree);
 extern int char_type_p                         (tree);
 extern void verify_stmt_tree                   (tree);
 extern linkage_kind decl_linkage               (tree);
+extern duration_kind decl_storage_duration     (tree);
 extern tree cp_walk_subtrees (tree*, int*, walk_tree_fn,
                              void*, struct pointer_set_t*);
 #define cp_walk_tree(a,b,c,d) \
@@ -5269,7 +5448,7 @@ extern void cxx_print_xnode                       (FILE *, tree, int);
 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 *,
+extern void cxx_print_error_function           (diagnostic_context *,
                                                 const char *,
                                                 struct diagnostic_info *);
 
@@ -5279,11 +5458,15 @@ 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 require_complete_type_sfinae       (tree, tsubst_flags_t);
 extern tree complete_type                      (tree);
 extern tree complete_type_or_else              (tree, tree);
+extern tree complete_type_or_maybe_complain    (tree, tree, tsubst_flags_t);
 extern int type_unknown_p                      (const_tree);
-extern bool comp_except_specs                  (const_tree, const_tree, bool);
+enum { ce_derived, 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 compparms                          (const_tree, const_tree);
 extern int comp_cv_qualification               (const_tree, const_tree);
 extern int comp_cv_qual_signature              (tree, tree);
@@ -5302,8 +5485,12 @@ extern tree build_x_indirect_ref         (tree, ref_operator,
 extern tree cp_build_indirect_ref              (tree, ref_operator,
                                                  tsubst_flags_t);
 extern tree build_array_ref                    (location_t, tree, tree);
+extern tree cp_build_array_ref                 (location_t, tree, tree,
+                                                tsubst_flags_t);
 extern tree get_member_function_from_ptrfunc   (tree *, tree);
 extern tree cp_build_function_call              (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,gc) **,
                                                 tsubst_flags_t);
 extern tree build_x_binary_op                  (enum tree_code, tree,
@@ -5313,12 +5500,15 @@ extern tree build_x_binary_op                   (enum tree_code, tree,
 extern tree build_x_array_ref                  (tree, tree, tsubst_flags_t);
 extern tree build_x_unary_op                   (enum tree_code, tree,
                                                  tsubst_flags_t);
+extern tree cp_build_addr_expr                 (tree, tsubst_flags_t);
+extern tree cp_build_addr_expr_strict          (tree, tsubst_flags_t);
 extern tree cp_build_unary_op                   (enum tree_code, tree, int, 
                                                  tsubst_flags_t);
 extern tree unary_complex_lvalue               (enum tree_code, tree);
 extern tree build_x_conditional_expr           (tree, tree, tree, 
                                                  tsubst_flags_t);
-extern tree build_x_compound_expr_from_list    (tree, const char *);
+extern tree build_x_compound_expr_from_list    (tree, expr_list_kind,
+                                                tsubst_flags_t);
 extern tree build_x_compound_expr_from_vec     (VEC(tree,gc) *, const char *);
 extern tree build_x_compound_expr              (tree, tree, tsubst_flags_t);
 extern tree build_compound_expr                 (location_t, tree, tree);
@@ -5333,15 +5523,17 @@ extern tree build_x_modify_expr                 (tree, enum tree_code, tree,
 extern tree cp_build_modify_expr               (tree, enum tree_code, tree,
                                                 tsubst_flags_t);
 extern tree convert_for_initialization         (tree, tree, tree, int,
-                                                const char *, 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 error_type_p                       (const_tree);
 extern int ptr_reasonably_similar              (const_tree, const_tree);
-extern tree build_ptrmemfunc                   (tree, tree, int, bool);
+extern tree build_ptrmemfunc                   (tree, tree, int, bool,
+                                                tsubst_flags_t);
 extern int cp_type_quals                       (const_tree);
-extern bool cp_type_readonly                   (const_tree);
+extern int type_memfn_quals                    (const_tree);
+extern tree apply_memfn_quals                  (tree, cp_cv_quals);
 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);
@@ -5353,6 +5545,7 @@ extern tree composite_pointer_type                (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 cp_build_binary_op                  (location_t,
                                                 enum tree_code, tree, tree,
@@ -5366,7 +5559,8 @@ extern tree non_reference                 (tree);
 extern tree lookup_anon_field                  (tree, tree);
 extern bool invalid_nonstatic_memfn_p          (const_tree, tsubst_flags_t);
 extern tree convert_member_func_to_ptr         (tree, tree);
-extern tree convert_ptrmem                     (tree, tree, bool, bool);
+extern tree convert_ptrmem                     (tree, tree, bool, bool,
+                                                tsubst_flags_t);
 extern int lvalue_or_else                      (tree, enum lvalue_use,
                                                  tsubst_flags_t);
 extern void check_template_keyword             (tree);
@@ -5416,10 +5610,9 @@ extern bool cp_dump_tree                 (void *, 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 void cxx_initialize_diagnostics         (diagnostic_context *);
 extern int cxx_types_compatible_p              (tree, tree);
 extern void init_shadowed_var_for_decl         (void);