OSDN Git Service

Fix candidate for PR c++/43206
[pf3gnuchains/gcc-fork.git] / gcc / cp / typeck.c
index a291a9c..cff3211 100644 (file)
@@ -1129,11 +1129,15 @@ get_template_parms_of_dependent_type (tree t)
   else if (typedef_variant_p (t)
           && !NAMESPACE_SCOPE_P (TYPE_NAME (t)))
     tinfo = get_template_info (DECL_CONTEXT (TYPE_NAME (t)));
-  /* If T is a TYPENAME_TYPE which context is a template type
-     parameter, get the template parameters from that context.  */
-  else if (TYPE_CONTEXT (t)
-          && TREE_CODE (TYPE_CONTEXT (t)) == TEMPLATE_TYPE_PARM)
-   return TEMPLATE_TYPE_PARM_SIBLING_PARMS (TYPE_CONTEXT (t));
+  else if (TREE_CODE (t) == TEMPLATE_TYPE_PARM
+          && DECL_CONTEXT (TYPE_NAME (t)) == NULL_TREE)
+    /* We have not yet created the DECL_TEMPLATE this
+       template type parm belongs to. It probably means
+       that we are in the middle of parsing the template parameters
+       of a template, and T is one of the parameters we have parsed.
+       Let's return the list of template parms we have parsed so far.  */
+    return get_template_parms_at_level (current_template_parms,
+                                       TEMPLATE_TYPE_LEVEL (t));
   else if (TYPE_CONTEXT (t)
           && !NAMESPACE_SCOPE_P (t))
     tinfo = get_template_info (TYPE_CONTEXT (t));
@@ -7851,50 +7855,12 @@ comp_ptr_ttypes_const (tree to, tree from)
 int
 cp_type_quals (const_tree type)
 {
-  int quals;
   /* This CONST_CAST is okay because strip_array_types returns its
      argument unmodified and we assign it to a const_tree.  */
-  type = strip_array_types (CONST_CAST_TREE (type));
-  if (type == error_mark_node
-      /* Quals on a FUNCTION_TYPE are memfn quals.  */
-      || TREE_CODE (type) == FUNCTION_TYPE)
+  type = strip_array_types (CONST_CAST_TREE(type));
+  if (type == error_mark_node)
     return TYPE_UNQUALIFIED;
-  quals = TYPE_QUALS (type);
-  /* METHOD and REFERENCE_TYPEs should never have quals.  */
-  gcc_assert ((TREE_CODE (type) != METHOD_TYPE
-              && TREE_CODE (type) != REFERENCE_TYPE)
-             || ((quals & (TYPE_QUAL_CONST|TYPE_QUAL_VOLATILE))
-                 == TYPE_UNQUALIFIED));
-  return quals;
-}
-
-/* Returns the function-cv-quals for TYPE, which must be a FUNCTION_TYPE or
-   METHOD_TYPE.  */
-
-int
-type_memfn_quals (const_tree type)
-{
-  if (TREE_CODE (type) == FUNCTION_TYPE)
-    return TYPE_QUALS (type);
-  else if (TREE_CODE (type) == METHOD_TYPE)
-    return cp_type_quals (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (type))));
-  else
-    gcc_unreachable ();
-}
-
-/* Returns the FUNCTION_TYPE TYPE with its function-cv-quals changed to
-   MEMFN_QUALS.  */
-
-tree
-apply_memfn_quals (tree type, cp_cv_quals memfn_quals)
-{
-  /* Could handle METHOD_TYPE here if necessary.  */
-  gcc_assert (TREE_CODE (type) == FUNCTION_TYPE);
-  if (TYPE_QUALS (type) == memfn_quals)
-    return type;
-  /* This should really have a different TYPE_MAIN_VARIANT, but that gets
-     complex.  */
-  return build_qualified_type (type, memfn_quals);
+  return TYPE_QUALS (type);
 }
 
 /* Returns nonzero if the TYPE is const from a C++ perspective: look inside
@@ -7905,7 +7871,8 @@ cp_type_readonly (const_tree type)
 {
   /* This CONST_CAST is okay because strip_array_types returns its
      argument unmodified and we assign it to a const_tree.  */
-  return (cp_type_quals (type) & TYPE_QUAL_CONST) != 0;
+  type = strip_array_types (CONST_CAST_TREE(type));
+  return TYPE_READONLY (type);
 }
 
 /* Returns nonzero if TYPE is const or volatile.  */