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++-anon-struct.diff < prev    next >
Encoding:
Text File  |  1999-11-08  |  18.6 KB  |  500 lines

  1. 1999-05-19  Jason Merrill  <jason@yorick.cygnus.com>
  2.  
  3.     Implement anonymous structs.
  4.     * cp-tree.h (ANON_AGGR_TYPE_P): Rename from ANON_UNION_TYPE_P.
  5.     * class.c, decl.c, decl2.c, init.c, pt.c, search.c, typeck.c: Adjust.
  6.     * class.c (finish_struct_1): Remove redundant check for anon struct.
  7.     * decl.c (fixup_anonymous_aggr): Renamed from fixup_anonymous_union.
  8.     (check_tag_decl): Check for anonymous struct here.
  9.     * decl2.c (build_anon_union_vars): Catch anon struct at file scope.
  10.     * init.c (sort_member_init, emit_base_init): Handle getting fields
  11.     as well as names in current_member_init_list.
  12.     (perform_member_init): Handle getting an anon aggr.
  13.     * method.c (do_build_assign_ref): Don't descend into anon aggrs.
  14.     (do_build_copy_constructor): Likewise.
  15.  
  16. Index: gcc-2.95.2/gcc/cp/class.c
  17. ===================================================================
  18. RCS file: /homes/khan/src/CVSROOT/gcc-2.95.2/gcc/cp/class.c,v
  19. retrieving revision 1.2
  20. diff -u -3 -p -r1.2 class.c
  21. --- gcc-2.95.2/gcc/cp/class.c    1999/11/05 06:11:44    1.2
  22. +++ gcc-2.95.2/gcc/cp/class.c    1999/11/05 06:12:00
  23. @@ -1336,7 +1336,7 @@ delete_duplicate_fields_1 (field, fields
  24.    tree prev = 0;
  25.    if (DECL_NAME (field) == 0)
  26.      {
  27. -      if (TREE_CODE (TREE_TYPE (field)) != UNION_TYPE)
  28. +      if (! ANON_AGGR_TYPE_P (TREE_TYPE (field)))
  29.      return fields;
  30.  
  31.        for (x = TYPE_FIELDS (TREE_TYPE (field)); x; x = TREE_CHAIN (x))
  32. @@ -1349,7 +1349,7 @@ delete_duplicate_fields_1 (field, fields
  33.      {
  34.        if (DECL_NAME (x) == 0)
  35.          {
  36. -          if (TREE_CODE (TREE_TYPE (x)) != UNION_TYPE)
  37. +          if (! ANON_AGGR_TYPE_P (TREE_TYPE (x)))
  38.          continue;
  39.            TYPE_FIELDS (TREE_TYPE (x))
  40.          = delete_duplicate_fields_1 (field, TYPE_FIELDS (TREE_TYPE (x)));
  41. @@ -2949,7 +2949,7 @@ finish_struct_anon (t)
  42.      continue;
  43.  
  44.        if (DECL_NAME (field) == NULL_TREE
  45. -      && TREE_CODE (TREE_TYPE (field)) == UNION_TYPE)
  46. +      && ANON_AGGR_TYPE_P (TREE_TYPE (field)))
  47.      {
  48.        tree* uelt = &TYPE_FIELDS (TREE_TYPE (field));
  49.        for (; *uelt; uelt = &TREE_CHAIN (*uelt))
  50. @@ -3130,9 +3130,6 @@ finish_struct_1 (t, warn_anon)
  51.    int empty = 1;
  52.    int has_pointers = 0;
  53.    tree inline_friends;
  54. -
  55. -  if (warn_anon && code != UNION_TYPE && ANON_AGGRNAME_P (TYPE_IDENTIFIER (t)))
  56. -    pedwarn ("anonymous class type not used to declare any objects");
  57.  
  58.    if (TYPE_SIZE (t))
  59.      {
  60. Index: gcc-2.95.2/gcc/cp/cp-tree.h
  61. ===================================================================
  62. RCS file: /homes/khan/src/CVSROOT/gcc-2.95.2/gcc/cp/cp-tree.h,v
  63. retrieving revision 1.1.1.1
  64. diff -u -3 -p -r1.1.1.1 cp-tree.h
  65. --- gcc-2.95.2/gcc/cp/cp-tree.h    1999/11/05 01:09:46    1.1.1.1
  66. +++ gcc-2.95.2/gcc/cp/cp-tree.h    1999/11/05 06:12:00
  67. @@ -700,7 +700,7 @@ struct lang_type
  68.        unsigned const_needs_init : 1;
  69.        unsigned ref_needs_init : 1;
  70.        unsigned has_const_assign_ref : 1;
  71. -      unsigned anon_union : 1;
  72. +      unsigned anon_aggr : 1;
  73.  
  74.        unsigned has_nonpublic_ctor : 2;
  75.        unsigned has_nonpublic_assign_ref : 2;
  76. @@ -1772,16 +1772,14 @@ extern int flag_new_for_scope;
  77.     Just used to communicate formatting information to dbxout.c.  */
  78.  #define DECL_OPERATOR(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.operator_attr)
  79.  
  80. -#define ANON_UNION_P(NODE) (DECL_NAME (NODE) == 0)
  81. -
  82. -/* Nonzero if TYPE is an anonymous union type.  We have to use a flag for
  83. -   this because "A union for which objects or pointers are declared is not
  84. -   an anonymous union" [class.union].  */
  85. -#define ANON_UNION_TYPE_P(NODE)                \
  86. +/* Nonzero if TYPE is an anonymous union or struct type.  We have to use a
  87. +   flag for this because "A union for which objects or pointers are
  88. +   declared is not an anonymous union" [class.union].  */
  89. +#define ANON_AGGR_TYPE_P(NODE)                \
  90.    (TYPE_LANG_SPECIFIC (NODE)                \
  91. -   && TYPE_LANG_SPECIFIC (NODE)->type_flags.anon_union)
  92. -#define SET_ANON_UNION_TYPE_P(NODE)                \
  93. -  (TYPE_LANG_SPECIFIC (NODE)->type_flags.anon_union = 1)
  94. +   && TYPE_LANG_SPECIFIC (NODE)->type_flags.anon_aggr)
  95. +#define SET_ANON_AGGR_TYPE_P(NODE)            \
  96. +  (TYPE_LANG_SPECIFIC (NODE)->type_flags.anon_aggr = 1)
  97.  
  98.  #define UNKNOWN_TYPE LANG_TYPE
  99.  
  100. @@ -2890,7 +2888,7 @@ extern int in_function_p            PROTO((void))
  101.  extern void replace_defarg            PROTO((tree, tree));
  102.  extern void print_other_binding_stack        PROTO((struct binding_level *));
  103.  extern void revert_static_member_fn             PROTO((tree*, tree*, tree*));
  104. -extern void fixup_anonymous_union               PROTO((tree));
  105. +extern void fixup_anonymous_aggr               PROTO((tree));
  106.  extern int check_static_variable_definition     PROTO((tree, tree));
  107.  extern void push_local_binding                  PROTO((tree, tree, int));
  108.  extern int push_class_binding                   PROTO((tree, tree));
  109. Index: gcc-2.95.2/gcc/cp/decl.c
  110. ===================================================================
  111. RCS file: /homes/khan/src/CVSROOT/gcc-2.95.2/gcc/cp/decl.c,v
  112. retrieving revision 1.1.1.1
  113. diff -u -3 -p -r1.1.1.1 decl.c
  114. --- gcc-2.95.2/gcc/cp/decl.c    1999/11/05 01:09:46    1.1.1.1
  115. +++ gcc-2.95.2/gcc/cp/decl.c    1999/11/05 06:12:01
  116. @@ -4343,7 +4343,7 @@ pushdecl_class_level (x)
  117.        if (TREE_CODE (x) == TYPE_DECL)
  118.      set_identifier_type_value (name, TREE_TYPE (x));
  119.      }
  120. -  else if (ANON_UNION_TYPE_P (TREE_TYPE (x)))
  121. +  else if (ANON_AGGR_TYPE_P (TREE_TYPE (x)))
  122.      {
  123.        tree f;
  124.  
  125. @@ -7017,7 +7017,7 @@ define_function (name, type, function_co
  126.     union type.)  */
  127.  
  128.  void
  129. -fixup_anonymous_union (t)
  130. +fixup_anonymous_aggr (t)
  131.       tree t;
  132.  {
  133.    tree *q;
  134. @@ -7104,12 +7104,15 @@ check_tag_decl (declspecs)
  135.    /* Check for an anonymous union.  We're careful
  136.       accessing TYPE_IDENTIFIER because some built-in types, like
  137.       pointer-to-member types, do not have TYPE_NAME.  */
  138. -  else if (t && TREE_CODE (t) == UNION_TYPE
  139. +  else if (t && IS_AGGR_TYPE_CODE (TREE_CODE (t))
  140.         && TYPE_NAME (t)
  141.         && ANON_AGGRNAME_P (TYPE_IDENTIFIER (t)))
  142.      {
  143.        /* Anonymous unions are objects, so they can have specifiers.  */;
  144. -      SET_ANON_UNION_TYPE_P (t);
  145. +      SET_ANON_AGGR_TYPE_P (t);
  146. +
  147. +      if (TREE_CODE (t) != UNION_TYPE && pedantic && ! in_system_header)
  148. +    pedwarn ("ISO C++ prohibits anonymous structs");
  149.      }
  150.  
  151.    else if (ob_modifier)
  152. @@ -7155,9 +7158,9 @@ shadow_tag (declspecs)
  153.       union { ... } ;
  154.       because there is no declarator after the union, the parser
  155.       sends that declaration here.  */
  156. -  if (t && ANON_UNION_TYPE_P (t))
  157. +  if (t && ANON_AGGR_TYPE_P (t))
  158.      {
  159. -      fixup_anonymous_union (t);
  160. +      fixup_anonymous_aggr (t);
  161.  
  162.        if (TYPE_FIELDS (t))
  163.      {
  164. @@ -10087,7 +10090,7 @@ grokdeclarator (declarator, declspecs, d
  165.    /* Static anonymous unions are dealt with here.  */
  166.    if (staticp && decl_context == TYPENAME
  167.        && TREE_CODE (declspecs) == TREE_LIST
  168. -      && ANON_UNION_TYPE_P (TREE_VALUE (declspecs)))
  169. +      && ANON_AGGR_TYPE_P (TREE_VALUE (declspecs)))
  170.      decl_context = FIELD;
  171.  
  172.    /* Give error if `const,' `volatile,' `inline,' `friend,' or `virtual'
  173. Index: gcc-2.95.2/gcc/cp/decl2.c
  174. ===================================================================
  175. RCS file: /homes/khan/src/CVSROOT/gcc-2.95.2/gcc/cp/decl2.c,v
  176. retrieving revision 1.1.1.1
  177. diff -u -3 -p -r1.1.1.1 decl2.c
  178. --- gcc-2.95.2/gcc/cp/decl2.c    1999/11/05 01:09:46    1.1.1.1
  179. +++ gcc-2.95.2/gcc/cp/decl2.c    1999/11/05 06:12:01
  180. @@ -893,10 +893,10 @@ grok_x_components (specs)
  181.  
  182.    /* The only case where we need to do anything additional here is an
  183.       anonymous union field, e.g.: `struct S { union { int i; }; };'.  */
  184. -  if (t == NULL_TREE || !ANON_UNION_TYPE_P (t))
  185. +  if (t == NULL_TREE || !ANON_AGGR_TYPE_P (t))
  186.      return;
  187.  
  188. -  fixup_anonymous_union (t);
  189. +  fixup_anonymous_aggr (t);
  190.    finish_member_declaration (build_lang_field_decl (FIELD_DECL,
  191.                              NULL_TREE,
  192.                              t)); 
  193. @@ -2158,6 +2158,11 @@ build_anon_union_vars (anon_decl, elems,
  194.    tree main_decl = NULL_TREE;
  195.    tree field;
  196.  
  197. +  /* Rather than write the code to handle the non-union case,
  198. +     just give an error.  */
  199. +  if (TREE_CODE (type) != UNION_TYPE)
  200. +    error ("anonymous struct not inside named type");
  201. +
  202.    for (field = TYPE_FIELDS (type); 
  203.         field != NULL_TREE; 
  204.         field = TREE_CHAIN (field))
  205. @@ -2179,7 +2184,7 @@ build_anon_union_vars (anon_decl, elems,
  206.      cp_pedwarn_at ("protected member `%#D' in anonymous union", field);
  207.  
  208.        if (DECL_NAME (field) == NULL_TREE
  209. -      && TREE_CODE (TREE_TYPE (field)) == UNION_TYPE)
  210. +      && ANON_AGGR_TYPE_P (TREE_TYPE (field)))
  211.      {
  212.        decl = build_anon_union_vars (field, elems, static_p, external_p);
  213.        if (!decl)
  214. @@ -2211,7 +2216,7 @@ build_anon_union_vars (anon_decl, elems,
  215.      TREE_ASM_WRITTEN (decl) = 1;
  216.        
  217.        if (DECL_NAME (field) == NULL_TREE
  218. -      && TREE_CODE (TREE_TYPE (field)) == UNION_TYPE)
  219. +      && ANON_AGGR_TYPE_P (TREE_TYPE (field)))
  220.      /* The remainder of the processing was already done in the
  221.         recursive call.  */
  222.      continue;
  223. Index: gcc-2.95.2/gcc/cp/init.c
  224. ===================================================================
  225. RCS file: /homes/khan/src/CVSROOT/gcc-2.95.2/gcc/cp/init.c,v
  226. retrieving revision 1.1.1.1
  227. diff -u -3 -p -r1.1.1.1 init.c
  228. --- gcc-2.95.2/gcc/cp/init.c    1999/11/05 01:09:46    1.1.1.1
  229. +++ gcc-2.95.2/gcc/cp/init.c    1999/11/05 06:12:01
  230. @@ -154,16 +154,25 @@ perform_member_init (member, name, init,
  231.  
  232.    expand_start_target_temps ();
  233.  
  234. -  if (TYPE_NEEDS_CONSTRUCTING (type)
  235. -      || (init && TYPE_HAS_CONSTRUCTOR (type)))
  236. +  decl = build_component_ref (current_class_ref, name, NULL_TREE, explicit);
  237. +
  238. +  /* Deal with this here, as we will get confused if we try to call the
  239. +     assignment op for an anonymous union.  This can happen in a
  240. +     synthesized copy constructor.  */
  241. +  if (ANON_AGGR_TYPE_P (type))
  242. +    {
  243. +      init = build (INIT_EXPR, type, decl, TREE_VALUE (init));
  244. +      TREE_SIDE_EFFECTS (init) = 1;
  245. +      expand_expr_stmt (init);
  246. +    }
  247. +  else if (TYPE_NEEDS_CONSTRUCTING (type)
  248. +       || (init && TYPE_HAS_CONSTRUCTOR (type)))
  249.      {
  250.        /* Since `init' is already a TREE_LIST on the current_member_init_list,
  251.       only build it into one if we aren't already a list.  */
  252.        if (init != NULL_TREE && TREE_CODE (init) != TREE_LIST)
  253.      init = build_expr_list (NULL_TREE, init);
  254.  
  255. -      decl = build_component_ref (current_class_ref, name, NULL_TREE, explicit);
  256. -
  257.        if (explicit
  258.        && TREE_CODE (type) == ARRAY_TYPE
  259.        && init != NULL_TREE
  260. @@ -186,7 +195,7 @@ perform_member_init (member, name, init,
  261.            /* default-initialization.  */
  262.            if (AGGREGATE_TYPE_P (type))
  263.          init = build (CONSTRUCTOR, type, NULL_TREE, NULL_TREE);
  264. -          else if (TREE_CODE (type) == REFERENCE_TYPE)
  265. +           else if (TREE_CODE (type) == REFERENCE_TYPE)
  266.          {
  267.            cp_error ("default-initialization of `%#D', which has reference type",
  268.                  member);
  269. @@ -216,8 +225,6 @@ perform_member_init (member, name, init,
  270.       current_member_init_list.  */
  271.        if (init || explicit)
  272.      {
  273. -      decl = build_component_ref (current_class_ref, name, NULL_TREE,
  274. -                      explicit);
  275.        expand_expr_stmt (build_modify_expr (decl, INIT_EXPR, init));
  276.      }
  277.      }
  278. @@ -275,16 +282,13 @@ sort_member_init (t)
  279.          continue;
  280.        name = TREE_PURPOSE (x);
  281.  
  282. -#if 0
  283. -      /* This happens in templates, since the IDENTIFIER is replaced
  284. -             with the COMPONENT_REF in tsubst_expr.  */
  285. -      field = (TREE_CODE (name) == COMPONENT_REF
  286. -           ? TREE_OPERAND (name, 1) : IDENTIFIER_CLASS_VALUE (name));
  287. -#else
  288. -      /* Let's find out when this happens.  */
  289. -      my_friendly_assert (TREE_CODE (name) != COMPONENT_REF, 348);
  290. -      field = IDENTIFIER_CLASS_VALUE (name);
  291. -#endif
  292. +      if (TREE_CODE (name) == IDENTIFIER_NODE)
  293. +        field = IDENTIFIER_CLASS_VALUE (name);
  294. +      else
  295. +        {
  296. +          my_friendly_assert (TREE_CODE (name) == FIELD_DECL, 348); 
  297. +          field = name;
  298. +        }
  299.  
  300.        /* If one member shadows another, get the outermost one.  */
  301.        if (TREE_CODE (field) == TREE_LIST)
  302. @@ -612,15 +616,8 @@ emit_base_init (t, immediately)
  303.        init = TREE_VALUE (mem_init_list);
  304.        from_init_list = 1;
  305.  
  306. -#if 0
  307. -      if (TREE_CODE (name) == COMPONENT_REF)
  308. -        name = DECL_NAME (TREE_OPERAND (name, 1));
  309. -#else
  310. -      /* Also see if it's ever a COMPONENT_REF here.  If it is, we
  311. -         need to do `expand_assignment (name, init, 0, 0);' and
  312. -         a continue.  */
  313. -      my_friendly_assert (TREE_CODE (name) != COMPONENT_REF, 349);
  314. -#endif
  315. +      my_friendly_assert (TREE_CODE (name) == IDENTIFIER_NODE
  316. +                  || TREE_CODE (name) == FIELD_DECL, 349);
  317.      }
  318.        else
  319.      {
  320. @@ -649,9 +646,11 @@ emit_base_init (t, immediately)
  321.      {
  322.        name = TREE_PURPOSE (mem_init_list);
  323.        init = TREE_VALUE (mem_init_list);
  324. -      /* XXX: this may need the COMPONENT_REF operand 0 check if
  325. -         it turns out we actually get them.  */
  326. -      field = IDENTIFIER_CLASS_VALUE (name);
  327. +
  328. +      if (TREE_CODE (name) == IDENTIFIER_NODE)
  329. +        field = IDENTIFIER_CLASS_VALUE (name);
  330. +      else
  331. +        field = name;
  332.  
  333.        /* If one member shadows another, get the outermost one.  */
  334.        if (TREE_CODE (field) == TREE_LIST)
  335. @@ -865,7 +864,7 @@ initializing_context (field)
  336.  
  337.    /* Anonymous union members can be initialized in the first enclosing
  338.       non-anonymous union context.  */
  339. -  while (t && ANON_UNION_TYPE_P (t))
  340. +  while (t && ANON_AGGR_TYPE_P (t))
  341.      t = TYPE_CONTEXT (t);
  342.    return t;
  343.  }
  344. Index: gcc-2.95.2/gcc/cp/method.c
  345. ===================================================================
  346. RCS file: /homes/khan/src/CVSROOT/gcc-2.95.2/gcc/cp/method.c,v
  347. retrieving revision 1.1.1.1
  348. diff -u -3 -p -r1.1.1.1 method.c
  349. --- gcc-2.95.2/gcc/cp/method.c    1999/11/05 01:09:46    1.1.1.1
  350. +++ gcc-2.95.2/gcc/cp/method.c    1999/11/05 06:12:01
  351. @@ -2267,18 +2267,10 @@ do_build_copy_constructor (fndecl)
  352.          continue;
  353.          }
  354.        else if ((t = TREE_TYPE (field)) != NULL_TREE
  355. -           && ANON_UNION_TYPE_P (t)
  356. +           && ANON_AGGR_TYPE_P (t)
  357.             && TYPE_FIELDS (t) != NULL_TREE)
  358. -        {
  359. -          do
  360. -        {
  361. -          init = build (COMPONENT_REF, t, init, field);
  362. -          field = largest_union_member (t);
  363. -        }
  364. -          while ((t = TREE_TYPE (field)) != NULL_TREE
  365. -             && ANON_UNION_TYPE_P (t)
  366. -             && TYPE_FIELDS (t) != NULL_TREE);
  367. -        }
  368. +        /* Just use the field; anonymous types can't have
  369. +           nontrivial copy ctors or assignment ops.  */;
  370.        else
  371.          continue;
  372.  
  373. @@ -2286,7 +2278,7 @@ do_build_copy_constructor (fndecl)
  374.        init = build_tree_list (NULL_TREE, init);
  375.  
  376.        current_member_init_list
  377. -        = tree_cons (DECL_NAME (field), init, current_member_init_list);
  378. +        = tree_cons (field, init, current_member_init_list);
  379.      }
  380.        current_member_init_list = nreverse (current_member_init_list);
  381.        current_base_init_list = nreverse (current_base_init_list);
  382. @@ -2375,19 +2367,10 @@ do_build_assign_ref (fndecl)
  383.          continue;
  384.          }
  385.        else if ((t = TREE_TYPE (field)) != NULL_TREE
  386. -           && ANON_UNION_TYPE_P (t)
  387. +           && ANON_AGGR_TYPE_P (t)
  388.             && TYPE_FIELDS (t) != NULL_TREE)
  389. -        {
  390. -          do
  391. -        {
  392. -          comp = build (COMPONENT_REF, t, comp, field);
  393. -          init = build (COMPONENT_REF, t, init, field);
  394. -          field = largest_union_member (t);
  395. -        }
  396. -          while ((t = TREE_TYPE (field)) != NULL_TREE
  397. -             && ANON_UNION_TYPE_P (t)
  398. -             && TYPE_FIELDS (t) != NULL_TREE);
  399. -        }
  400. +        /* Just use the field; anonymous types can't have
  401. +           nontrivial copy ctors or assignment ops.  */;
  402.        else
  403.          continue;
  404.  
  405. Index: gcc-2.95.2/gcc/cp/pt.c
  406. ===================================================================
  407. RCS file: /homes/khan/src/CVSROOT/gcc-2.95.2/gcc/cp/pt.c,v
  408. retrieving revision 1.1.1.1
  409. diff -u -3 -p -r1.1.1.1 pt.c
  410. --- gcc-2.95.2/gcc/cp/pt.c    1999/11/05 01:09:46    1.1.1.1
  411. +++ gcc-2.95.2/gcc/cp/pt.c    1999/11/05 06:12:01
  412. @@ -4886,8 +4886,8 @@ instantiate_class_template (type)
  413.    TYPE_PACKED (type) = TYPE_PACKED (pattern);
  414.    TYPE_ALIGN (type) = TYPE_ALIGN (pattern);
  415.    TYPE_FOR_JAVA (type) = TYPE_FOR_JAVA (pattern); /* For libjava's JArray<T> */
  416. -  if (ANON_UNION_TYPE_P (pattern))
  417. -    SET_ANON_UNION_TYPE_P (type);
  418. +  if (ANON_AGGR_TYPE_P (pattern))
  419. +    SET_ANON_AGGR_TYPE_P (type);
  420.  
  421.    /* We must copy the arguments to the permanent obstack since
  422.       during the tsubst'ing below they may wind up in the
  423. Index: gcc-2.95.2/gcc/cp/search.c
  424. ===================================================================
  425. RCS file: /homes/khan/src/CVSROOT/gcc-2.95.2/gcc/cp/search.c,v
  426. retrieving revision 1.1.1.1
  427. diff -u -3 -p -r1.1.1.1 search.c
  428. --- gcc-2.95.2/gcc/cp/search.c    1999/11/05 01:09:46    1.1.1.1
  429. +++ gcc-2.95.2/gcc/cp/search.c    1999/11/05 06:12:01
  430. @@ -534,7 +534,7 @@ lookup_field_1 (type, name)
  431.  #endif /* GATHER_STATISTICS */
  432.        my_friendly_assert (TREE_CODE_CLASS (TREE_CODE (field)) == 'd', 0);
  433.        if (DECL_NAME (field) == NULL_TREE
  434. -      && TREE_CODE (TREE_TYPE (field)) == UNION_TYPE)
  435. +      && ANON_AGGR_TYPE_P (TREE_TYPE (field)))
  436.      {
  437.        tree temp = lookup_field_1 (TREE_TYPE (field), name);
  438.        if (temp)
  439. @@ -610,7 +610,7 @@ context_for_name_lookup (decl)
  440.       declared.  */ 
  441.    tree context = DECL_REAL_CONTEXT (decl);
  442.  
  443. -  while (TYPE_P (context) && ANON_UNION_TYPE_P (context))
  444. +  while (TYPE_P (context) && ANON_AGGR_TYPE_P (context))
  445.      context = TYPE_CONTEXT (context);
  446.    if (!context)
  447.      context = global_namespace;
  448. @@ -2939,7 +2939,7 @@ dfs_push_decls (binfo, data)
  449.          && TREE_CODE (fields) != USING_DECL)
  450.        setup_class_bindings (DECL_NAME (fields), /*type_binding_p=*/0);
  451.      else if (TREE_CODE (fields) == FIELD_DECL
  452. -         && ANON_UNION_TYPE_P (TREE_TYPE (fields)))
  453. +         && ANON_AGGR_TYPE_P (TREE_TYPE (fields)))
  454.        dfs_push_decls (TYPE_BINFO (TREE_TYPE (fields)), data);
  455.        
  456.        method_vec = (CLASS_TYPE_P (type) 
  457. @@ -3013,7 +3013,7 @@ dfs_unuse_fields (binfo, data)
  458.  
  459.        TREE_USED (fields) = 0;
  460.        if (DECL_NAME (fields) == NULL_TREE
  461. -      && TREE_CODE (TREE_TYPE (fields)) == UNION_TYPE)
  462. +      && ANON_AGGR_TYPE_P (TREE_TYPE (fields)))
  463.      unuse_fields (TREE_TYPE (fields));
  464.      }
  465.  
  466. Index: gcc-2.95.2/gcc/cp/typeck.c
  467. ===================================================================
  468. RCS file: /homes/khan/src/CVSROOT/gcc-2.95.2/gcc/cp/typeck.c,v
  469. retrieving revision 1.2
  470. diff -u -3 -p -r1.2 typeck.c
  471. --- gcc-2.95.2/gcc/cp/typeck.c    1999/11/05 06:11:44    1.2
  472. +++ gcc-2.95.2/gcc/cp/typeck.c    1999/11/05 06:12:01
  473. @@ -2011,7 +2011,7 @@ lookup_anon_field (t, type)
  474.  
  475.        /* Otherwise, it could be nested, search harder.  */
  476.        if (DECL_NAME (field) == NULL_TREE
  477. -      && TREE_CODE (TREE_TYPE (field)) == UNION_TYPE)
  478. +      && ANON_AGGR_TYPE_P (TREE_TYPE (field)))
  479.      {
  480.        tree subfield = lookup_anon_field (TREE_TYPE (field), type);
  481.        if (subfield)
  482. @@ -2221,7 +2221,7 @@ build_component_ref (datum, component, b
  483.        tree context = DECL_FIELD_CONTEXT (field);
  484.        tree base = context;
  485.        while (!same_type_p (base, basetype) && TYPE_NAME (base)
  486. -         && ANON_UNION_TYPE_P (base))
  487. +         && ANON_AGGR_TYPE_P (base))
  488.      {
  489.        base = TYPE_CONTEXT (base);
  490.      }
  491. @@ -2251,7 +2251,7 @@ build_component_ref (datum, component, b
  492.        basetype = base;
  493.   
  494.        /* Handle things from anon unions here...  */
  495. -      if (TYPE_NAME (context) && ANON_UNION_TYPE_P (context))
  496. +      if (TYPE_NAME (context) && ANON_AGGR_TYPE_P (context))
  497.      {
  498.        tree subfield = lookup_anon_field (basetype, context);
  499.        tree subdatum = build_component_ref (datum, subfield,
  500.