FreeBSD/contrib/gcc/cp/decl.c
/* When we call finish_struct for an anonymous union, we create
   default copy constructors and such.  But, an anonymous union
   shouldn't have such things; this function undoes the damage to the
   anonymous union type T.

   (The reason that we create the synthesized methods is that we don't
   distinguish `union { int i; }' from `typedef union { int i; } U'.
   The first is an anonymous union; the second is just an ordinary
   union type.)  */
When we call finish_struct for an anonymous union, we create
default copy constructors and such.  But, an anonymous union
shouldn't have such things; this function undoes the damage to the
anonymous union type T.

(The reason that we create the synthesized methods is that we don't
distinguish `union { int i; }' from `typedef union { int i; } U'.
The first is an anonymous union; the second is just an ordinary
union type.)
When we call finish_struct for an anonymous union we create default copy constructors and such . But an anonymous union shouldn ' t have such things ; this function undoes the damage to the anonymous union type T . ( The reason that we create the synthesized methods is that we don ' t distinguish ` union { int i ; } ' from ` typedef union { int i ; } U ' . The first is an anonymous union ; the second is just an ordinary union type . )
void
fixup_anonymous_aggr (tree t)
{
  tree *q;
  TYPE_HAS_CONSTRUCTOR (t) = 0;
  TYPE_HAS_DEFAULT_CONSTRUCTOR (t) = 0;
  TYPE_HAS_INIT_REF (t) = 0;
  TYPE_HAS_CONST_INIT_REF (t) = 0;
  TYPE_HAS_ASSIGN_REF (t) = 0;
  TYPE_HAS_CONST_ASSIGN_REF (t) = 0;
  q = &TYPE_METHODS (t);
  while (*q)
    {
      if (DECL_ARTIFICIAL (*q))
	*q = TREE_CHAIN (*q);
      else
	q = &TREE_CHAIN (*q);
    }
  if (TYPE_METHODS (t))
    error ("%Jan anonymous union cannot have function members",
	   TYPE_MAIN_DECL (t));
  if (TREE_CODE (t) != UNION_TYPE)
    {
      tree field, type;
      for (field = TYPE_FIELDS (t); field; field = TREE_CHAIN (field))
	if (TREE_CODE (field) == FIELD_DECL)
	  {
	    type = TREE_TYPE (field);
	    if (CLASS_TYPE_P (type))
	      {
		if (TYPE_NEEDS_CONSTRUCTING (type))
		  error ("member %q+#D with constructor not allowed "
			 "in anonymous aggregate", field);
		if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type))
		  error ("member %q+#D with destructor not allowed "
			 "in anonymous aggregate", field);
		if (TYPE_HAS_COMPLEX_ASSIGN_REF (type))
		  error ("member %q+#D with copy assignment operator "
			 "not allowed in anonymous aggregate", field);
	      }
	  }
    }
}
void fixup_anonymous_aggr ( tree t ) { tree * q ; TYPE_HAS_CONSTRUCTOR ( t ) = 0 ; TYPE_HAS_DEFAULT_CONSTRUCTOR ( t ) = 0 ; TYPE_HAS_INIT_REF ( t ) = 0 ; TYPE_HAS_CONST_INIT_REF ( t ) = 0 ; TYPE_HAS_ASSIGN_REF ( t ) = 0 ; TYPE_HAS_CONST_ASSIGN_REF ( t ) = 0 ; q = & TYPE_METHODS ( t ) ; while ( * q ) { if ( DECL_ARTIFICIAL ( * q ) ) * q = TREE_CHAIN ( * q ) ; else q = & TREE_CHAIN ( * q ) ; } if ( TYPE_METHODS ( t ) ) error ( " " , TYPE_MAIN_DECL ( t ) ) ; if ( TREE_CODE ( t ) != UNION_TYPE ) { tree field , type ; for ( field = TYPE_FIELDS ( t ) ; field ; field = TREE_CHAIN ( field ) ) if ( TREE_CODE ( field ) == FIELD_DECL ) { type = TREE_TYPE ( field ) ; if ( CLASS_TYPE_P ( type ) ) { if ( TYPE_NEEDS_CONSTRUCTING ( type ) ) error ( " " " " , field ) ; if ( TYPE_HAS_NONTRIVIAL_DESTRUCTOR ( type ) ) error ( " " " " , field ) ; if ( TYPE_HAS_COMPLEX_ASSIGN_REF ( type ) ) error ( " " " " , field ) ; } } } }
When we call finish_struct for an anonymous union, we create
default copy constructors and such.
When we call finish_struct for an anonymous union we create default copy constructors and such .
/* Wipe out memory of synthesized methods.  */ /* Splice the implicitly generated functions out of the TYPE_METHODS
     list.  */ /* ISO C++ 9.5.3.  Anonymous unions may not have function members.  */ /* Anonymous aggregates cannot have fields with ctors, dtors or complex
     assignment operators (because they cannot have these methods themselves).
     For anonymous unions this is already checked because they are not allowed
     in any union, otherwise we have to check it.  */