OSDN Git Service

* pt.c (print_template_statistics): New.
[pf3gnuchains/gcc-fork.git] / gcc / cp / pt.c
index 1ff1fe2..d1c33d6 100644 (file)
@@ -1,6 +1,6 @@
 /* Handle parameterized types (templates) for GNU C++.
    Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
+   2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
    Free Software Foundation, Inc.
    Written by Ken Raeburn (raeburn@cygnus.com) while at Watchmaker Computing.
    Rewritten by Jason Merrill (jason@cygnus.com).
@@ -1563,12 +1563,6 @@ iterative_hash_template_arg (tree arg, hashval_t val)
       val = iterative_hash_template_arg (TREE_TYPE (arg), val);
       return iterative_hash_template_arg (TYPE_DOMAIN (arg), val);
 
-    case LAMBDA_EXPR:
-      /* A lambda can't appear in a template arg, but don't crash on
-        erroneous input.  */
-      gcc_assert (errorcount > 0);
-      return val;
-
     default:
       switch (tclass)
        {
@@ -3837,7 +3831,7 @@ process_partial_specialization (tree decl)
   int nargs = TREE_VEC_LENGTH (inner_args);
   int ntparms;
   int  i;
-  bool did_error_intro = false;
+  int did_error_intro = 0;
   struct template_parm_data tpd;
   struct template_parm_data tpd2;
 
@@ -3899,15 +3893,12 @@ process_partial_specialization (tree decl)
        if (!did_error_intro)
          {
            error ("template parameters not used in partial specialization:");
-           did_error_intro = true;
+           did_error_intro = 1;
          }
 
        error ("        %qD", TREE_VALUE (TREE_VEC_ELT (inner_parms, i)));
       }
 
-  if (did_error_intro)
-    return error_mark_node;
-
   /* [temp.class.spec]
 
      The argument list of the specialization shall not be identical to
@@ -4933,7 +4924,6 @@ convert_nontype_argument (tree type, tree expr)
   if (error_operand_p (expr))
     return error_mark_node;
   expr_type = TREE_TYPE (expr);
-  expr = mark_rvalue_use (expr);
 
   /* HACK: Due to double coercion, we can get a
      NOP_EXPR<REFERENCE_TYPE>(ADDR_EXPR<POINTER_TYPE> (arg)) here,
@@ -7340,18 +7330,11 @@ tsubst_friend_function (tree decl, tree args)
              DECL_TEMPLATE_INFO (old_decl) = new_friend_template_info;
 
              if (TREE_CODE (old_decl) != TEMPLATE_DECL)
-               {
-                 /* We should have called reregister_specialization in
-                    duplicate_decls.  */
-                 gcc_assert (retrieve_specialization (new_template,
-                                                      new_args, 0)
-                             == old_decl);
-
-                 /* Instantiate it if the global has already been used.  */
-                 if (DECL_ODR_USED (old_decl))
-                   instantiate_decl (old_decl, /*defer_ok=*/true,
-                                     /*expl_inst_class_mem_p=*/false);
-               }
+               /* We should have called reregister_specialization in
+                  duplicate_decls.  */
+               gcc_assert (retrieve_specialization (new_template,
+                                                    new_args, 0)
+                           == old_decl);
              else
                {
                  tree t;
@@ -9506,8 +9489,6 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
              type = DECL_ORIGINAL_TYPE (t);
            else
              type = TREE_TYPE (t);
-           if (TREE_CODE (t) == VAR_DECL && VAR_HAD_UNKNOWN_BOUND (t))
-             type = strip_array_domain (type);
            type = tsubst (type, args, complain, in_decl);
          }
        if (TREE_CODE (r) == VAR_DECL)
@@ -14472,10 +14453,6 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict)
       FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (arg), i, elt)
        {
          int elt_strict = strict;
-
-         if (elt == error_mark_node)
-           return 1;
-
          if (!BRACE_ENCLOSED_INITIALIZER_P (elt))
            {
              tree type = TREE_TYPE (elt);
@@ -15949,13 +15926,12 @@ most_specialized_class (tree type, tree tmpl)
       tree parms = TREE_VALUE (t);
 
       partial_spec_args = CLASSTYPE_TI_ARGS (TREE_TYPE (t));
-
-      ++processing_template_decl;
-
       if (outer_args)
        {
          int i;
 
+         ++processing_template_decl;
+
          /* Discard the outer levels of args, and then substitute in the
             template args from the enclosing class.  */
          partial_spec_args = INNERMOST_TEMPLATE_ARGS (partial_spec_args);
@@ -15972,6 +15948,7 @@ most_specialized_class (tree type, tree tmpl)
            TREE_VEC_ELT (parms, i) =
              tsubst (TREE_VEC_ELT (parms, i), outer_args, tf_none, NULL_TREE);
 
+         --processing_template_decl;
        }
 
       partial_spec_args =
@@ -15982,8 +15959,6 @@ most_specialized_class (tree type, tree tmpl)
                                 /*require_all_args=*/true,
                                 /*use_default_args=*/true);
 
-      --processing_template_decl;
-
       if (partial_spec_args == error_mark_node)
        return error_mark_node;
 
@@ -16474,15 +16449,10 @@ regenerate_decl_from_template (tree decl, tree tmpl)
        DECL_DECLARED_INLINE_P (decl) = 1;
     }
   else if (TREE_CODE (decl) == VAR_DECL)
-    {
-      DECL_INITIAL (decl) =
-       tsubst_expr (DECL_INITIAL (code_pattern), args,
-                    tf_error, DECL_TI_TEMPLATE (decl),
-                    /*integral_constant_expression_p=*/false);
-      if (VAR_HAD_UNKNOWN_BOUND (decl))
-       TREE_TYPE (decl) = tsubst (TREE_TYPE (code_pattern), args,
-                                  tf_error, DECL_TI_TEMPLATE (decl));
-    }
+    DECL_INITIAL (decl) =
+      tsubst_expr (DECL_INITIAL (code_pattern), args,
+                  tf_error, DECL_TI_TEMPLATE (decl),
+                  /*integral_constant_expression_p=*/false);
   else
     gcc_unreachable ();
 
@@ -17753,15 +17723,6 @@ type_dependent_expression_p (tree expression)
       return false;
     }
 
-  /* A static data member of the current instantiation with incomplete
-     array type is type-dependent, as the definition and specializations
-     can have different bounds.  */
-  if (TREE_CODE (expression) == VAR_DECL
-      && DECL_CLASS_SCOPE_P (expression)
-      && dependent_type_p (DECL_CONTEXT (expression))
-      && VAR_HAD_UNKNOWN_BOUND (expression))
-    return true;
-
   if (TREE_TYPE (expression) == unknown_type_node)
     {
       if (TREE_CODE (expression) == ADDR_EXPR)