home *** CD-ROM | disk | FTP | other *** search
/ Programming Win32 Under the API / ProgrammingWin32UnderTheApiPatVillani.iso / patches / gcc-2_95_2-x86-win32-patches.zi / gcc-2.95.2-patches / broken-down / gcc-2.95.2-c++-tidy.diff < prev    next >
Encoding:
Text File  |  1999-11-08  |  7.7 KB  |  236 lines

  1. 1999-05-19  Jason Merrill  <jason@yorick.cygnus.com>
  2.  
  3.     * call.c (find_scoped_type, resolve_scope_to_name): Lose.
  4.     * class.c (finish_struct_1): Use CLASS_TYPE_P.
  5.     * ptree.c (print_lang_type): Likewise.
  6.     * typeck.c (build_modify_expr, c_expand_asm_operands): Use
  7.     IS_AGGR_TYPE_CODE.
  8.     * typeck2.c (digest_init): Likewise.
  9.  
  10. Index: gcc-2.95.2/gcc/cp/call.c
  11. ===================================================================
  12. RCS file: /homes/khan/src/CVSROOT/gcc-2.95.2/gcc/cp/call.c,v
  13. retrieving revision 1.1.1.1
  14. diff -u -3 -p -r1.1.1.1 call.c
  15. --- gcc-2.95.2/gcc/cp/call.c    1999/11/05 01:09:45    1.1.1.1
  16. +++ gcc-2.95.2/gcc/cp/call.c    1999/11/05 06:08:58
  17. @@ -42,7 +42,6 @@ extern tree ctor_label, dtor_label;
  18.  static tree build_new_method_call PROTO((tree, tree, tree, tree, int));
  19.  
  20.  static tree build_field_call PROTO((tree, tree, tree, tree));
  21. -static tree find_scoped_type PROTO((tree, tree, tree));
  22.  static struct z_candidate * tourney PROTO((struct z_candidate *));
  23.  static int joust PROTO((struct z_candidate *, struct z_candidate *, int));
  24.  static int compare_ics PROTO((tree, tree));
  25. @@ -162,130 +161,6 @@ build_field_call (basetype_path, instanc
  26.      }
  27.  
  28.    return NULL_TREE;
  29. -}
  30. -
  31. -static tree
  32. -find_scoped_type (type, inner_name, inner_types)
  33. -     tree type, inner_name, inner_types;
  34. -{
  35. -  tree tags = CLASSTYPE_TAGS (type);
  36. -
  37. -  while (tags)
  38. -    {
  39. -      /* The TREE_PURPOSE of an enum tag (which becomes a member of the
  40. -     enclosing class) is set to the name for the enum type.  So, if
  41. -     inner_name is `bar', and we strike `baz' for `enum bar { baz }',
  42. -     then this test will be true.  */
  43. -      if (TREE_PURPOSE (tags) == inner_name)
  44. -    {
  45. -      if (inner_types == NULL_TREE)
  46. -        return TYPE_MAIN_DECL (TREE_VALUE (tags));
  47. -      return resolve_scope_to_name (TREE_VALUE (tags), inner_types);
  48. -    }
  49. -      tags = TREE_CHAIN (tags);
  50. -    }
  51. -
  52. -  /* Look for a TYPE_DECL.  */
  53. -  for (tags = TYPE_FIELDS (type); tags; tags = TREE_CHAIN (tags))
  54. -    if (TREE_CODE (tags) == TYPE_DECL && DECL_NAME (tags) == inner_name)
  55. -      {
  56. -    /* Code by raeburn.  */
  57. -    if (inner_types == NULL_TREE)
  58. -      return tags;
  59. -    return resolve_scope_to_name (TREE_TYPE (tags), inner_types);
  60. -      }
  61. -
  62. -  return NULL_TREE;
  63. -}
  64. -
  65. -/* Resolve an expression NAME1::NAME2::...::NAMEn to
  66. -   the name that names the above nested type.  INNER_TYPES
  67. -   is a chain of nested type names (held together by SCOPE_REFs);
  68. -   OUTER_TYPE is the type we know to enclose INNER_TYPES.
  69. -   Returns NULL_TREE if there is an error.  */
  70. -
  71. -tree
  72. -resolve_scope_to_name (outer_type, inner_stuff)
  73. -     tree outer_type, inner_stuff;
  74. -{
  75. -  register tree tmp;
  76. -  tree inner_name, inner_type;
  77. -
  78. -  if (outer_type == NULL_TREE && current_class_type != NULL_TREE)
  79. -    {
  80. -      /* We first try to look for a nesting in our current class context,
  81. -         then try any enclosing classes.  */
  82. -      tree type = current_class_type;
  83. -      
  84. -      while (type && (TREE_CODE (type) == RECORD_TYPE
  85. -              || TREE_CODE (type) == UNION_TYPE))
  86. -        {
  87. -          tree rval = resolve_scope_to_name (type, inner_stuff);
  88. -
  89. -      if (rval != NULL_TREE)
  90. -        return rval;
  91. -      type = DECL_CONTEXT (TYPE_MAIN_DECL (type));
  92. -    }
  93. -    }
  94. -
  95. -  if (TREE_CODE (inner_stuff) == SCOPE_REF)
  96. -    {
  97. -      inner_name = TREE_OPERAND (inner_stuff, 0);
  98. -      inner_type = TREE_OPERAND (inner_stuff, 1);
  99. -    }
  100. -  else
  101. -    {
  102. -      inner_name = inner_stuff;
  103. -      inner_type = NULL_TREE;
  104. -    }
  105. -
  106. -  if (outer_type == NULL_TREE)
  107. -    {
  108. -      tree x;
  109. -      /* If we have something that's already a type by itself,
  110. -     use that.  */
  111. -      if (IDENTIFIER_HAS_TYPE_VALUE (inner_name))
  112. -    {
  113. -      if (inner_type)
  114. -        return resolve_scope_to_name (IDENTIFIER_TYPE_VALUE (inner_name),
  115. -                      inner_type);
  116. -      return inner_name;
  117. -    }
  118. -      
  119. -      x = lookup_name (inner_name, 0);
  120. -
  121. -      if (x && TREE_CODE (x) == NAMESPACE_DECL)
  122. -    {
  123. -      x = lookup_namespace_name (x, inner_type);
  124. -      return x;
  125. -    }
  126. -      return NULL_TREE;
  127. -    }
  128. -
  129. -  if (! IS_AGGR_TYPE (outer_type))
  130. -    return NULL_TREE;
  131. -
  132. -  /* Look for member classes or enums.  */
  133. -  tmp = find_scoped_type (outer_type, inner_name, inner_type);
  134. -
  135. -  /* If it's not a type in this class, then go down into the
  136. -     base classes and search there.  */
  137. -  if (! tmp && TYPE_BINFO (outer_type))
  138. -    {
  139. -      tree binfos = TYPE_BINFO_BASETYPES (outer_type);
  140. -      int i, n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
  141. -
  142. -      for (i = 0; i < n_baselinks; i++)
  143. -    {
  144. -      tree base_binfo = TREE_VEC_ELT (binfos, i);
  145. -      tmp = resolve_scope_to_name (BINFO_TYPE (base_binfo), inner_stuff);
  146. -      if (tmp)
  147. -        return tmp;
  148. -    }
  149. -      tmp = NULL_TREE;
  150. -    }
  151. -
  152. -  return tmp;
  153.  }
  154.  
  155.  /* Returns nonzero iff the destructor name specified in NAME
  156. Index: gcc-2.95.2/gcc/cp/class.c
  157. ===================================================================
  158. RCS file: /homes/khan/src/CVSROOT/gcc-2.95.2/gcc/cp/class.c,v
  159. retrieving revision 1.1.1.1
  160. diff -u -3 -p -r1.1.1.1 class.c
  161. --- gcc-2.95.2/gcc/cp/class.c    1999/11/05 01:09:45    1.1.1.1
  162. +++ gcc-2.95.2/gcc/cp/class.c    1999/11/05 06:08:58
  163. @@ -3522,8 +3522,7 @@ finish_struct_1 (t, warn_anon)
  164.        while (TREE_CODE (type) == ARRAY_TYPE)
  165.          type = TREE_TYPE (type);
  166.  
  167. -      if (TYPE_LANG_SPECIFIC (type) && ! ANON_UNION_P (x)
  168. -          && ! TYPE_PTRMEMFUNC_P (type))
  169. +          if (CLASS_TYPE_P (type))
  170.          {
  171.            /* Never let anything with uninheritable virtuals
  172.           make it through without complaint.  */
  173. Index: gcc-2.95.2/gcc/cp/ptree.c
  174. ===================================================================
  175. RCS file: /homes/khan/src/CVSROOT/gcc-2.95.2/gcc/cp/ptree.c,v
  176. retrieving revision 1.1.1.1
  177. diff -u -3 -p -r1.1.1.1 ptree.c
  178. --- gcc-2.95.2/gcc/cp/ptree.c    1999/11/05 01:09:46    1.1.1.1
  179. +++ gcc-2.95.2/gcc/cp/ptree.c    1999/11/05 06:08:58
  180. @@ -79,11 +79,7 @@ print_lang_type (file, node, indent)
  181.        return;
  182.      }
  183.  
  184. -  if (! (TREE_CODE (node) == RECORD_TYPE
  185. -     || TREE_CODE (node) == UNION_TYPE))
  186. -    return;
  187. -
  188. -  if (!TYPE_LANG_SPECIFIC (node))
  189. +  if (! CLASS_TYPE_P (node))
  190.      return;
  191.  
  192.    indent_to (file, indent + 3);
  193. Index: gcc-2.95.2/gcc/cp/typeck.c
  194. ===================================================================
  195. RCS file: /homes/khan/src/CVSROOT/gcc-2.95.2/gcc/cp/typeck.c,v
  196. retrieving revision 1.1.1.1
  197. diff -u -3 -p -r1.1.1.1 typeck.c
  198. --- gcc-2.95.2/gcc/cp/typeck.c    1999/11/05 01:09:46    1.1.1.1
  199. +++ gcc-2.95.2/gcc/cp/typeck.c    1999/11/05 06:08:58
  200. @@ -6122,8 +6122,7 @@ build_modify_expr (lhs, modifycode, rhs)
  201.        /* Functions are not modifiable, even though they are
  202.           lvalues.  */
  203.        || TREE_CODE (TREE_TYPE (lhs)) == FUNCTION_TYPE
  204. -      || ((TREE_CODE (lhstype) == RECORD_TYPE
  205. -           || TREE_CODE (lhstype) == UNION_TYPE)
  206. +          || (IS_AGGR_TYPE_CODE (TREE_CODE (lhstype))
  207.            && C_TYPE_FIELDS_READONLY (lhstype))
  208.        || (TREE_CODE (lhstype) == REFERENCE_TYPE
  209.            && CP_TYPE_CONST_P (TREE_TYPE (lhstype)))))
  210. @@ -7305,8 +7304,7 @@ c_expand_asm_operands (string, outputs, 
  211.      {
  212.        tree type = TREE_TYPE (o[i]);
  213.        if (CP_TYPE_CONST_P (type)
  214. -          || ((TREE_CODE (type) == RECORD_TYPE
  215. -           || TREE_CODE (type) == UNION_TYPE)
  216. +              || (IS_AGGR_TYPE_CODE (TREE_CODE (type))
  217.            && C_TYPE_FIELDS_READONLY (type)))
  218.          readonly_error (o[i], "modification by `asm'", 1);
  219.      }
  220. Index: gcc-2.95.2/gcc/cp/typeck2.c
  221. ===================================================================
  222. RCS file: /homes/khan/src/CVSROOT/gcc-2.95.2/gcc/cp/typeck2.c,v
  223. retrieving revision 1.1.1.1
  224. diff -u -3 -p -r1.1.1.1 typeck2.c
  225. --- gcc-2.95.2/gcc/cp/typeck2.c    1999/11/05 01:09:46    1.1.1.1
  226. +++ gcc-2.95.2/gcc/cp/typeck2.c    1999/11/05 06:08:58
  227. @@ -836,7 +836,7 @@ digest_init (type, init, tail)
  228.        return error_mark_node;
  229.      }
  230.  
  231. -  if (code == ARRAY_TYPE || code == RECORD_TYPE || code == UNION_TYPE)
  232. +  if (code == ARRAY_TYPE || IS_AGGR_TYPE_CODE (code))
  233.      {
  234.        if (raw_constructor && TYPE_NON_AGGREGATE_CLASS (type))
  235.      {
  236.