FreeBSD/contrib/gcc/cp/class.c
/* Check for things that are invalid.  There are probably plenty of other
   things we should check for also.  */
Check for things that are invalid.  There are probably plenty of other
things we should check for also.
Check for things that are invalid . There are probably plenty of other things we should check for also .
static void
finish_struct_anon (tree t)
{
  tree field;
  for (field = TYPE_FIELDS (t); field; field = TREE_CHAIN (field))
    {
      if (TREE_STATIC (field))
	continue;
      if (TREE_CODE (field) != FIELD_DECL)
	continue;
      if (DECL_NAME (field) == NULL_TREE
	  && ANON_AGGR_TYPE_P (TREE_TYPE (field)))
	{
	  tree elt = TYPE_FIELDS (TREE_TYPE (field));
	  for (; elt; elt = TREE_CHAIN (elt))
	    {
	      if (DECL_ARTIFICIAL (elt)
		  && (!DECL_IMPLICIT_TYPEDEF_P (elt)
		      || TYPE_ANONYMOUS_P (TREE_TYPE (elt))))
		continue;
	      if (TREE_CODE (elt) != FIELD_DECL)
		{
		  pedwarn ("%q+#D invalid; an anonymous union can "
			   "only have non-static data members", elt);
		  continue;
		}
	      if (TREE_PRIVATE (elt))
		pedwarn ("private member %q+#D in anonymous union", elt);
	      else if (TREE_PROTECTED (elt))
		pedwarn ("protected member %q+#D in anonymous union", elt);
	      TREE_PRIVATE (elt) = TREE_PRIVATE (field);
	      TREE_PROTECTED (elt) = TREE_PROTECTED (field);
	    }
	}
    }
}
static void finish_struct_anon ( tree t ) { tree field ; for ( field = TYPE_FIELDS ( t ) ; field ; field = TREE_CHAIN ( field ) ) { if ( TREE_STATIC ( field ) ) continue ; if ( TREE_CODE ( field ) != FIELD_DECL ) continue ; if ( DECL_NAME ( field ) == NULL_TREE && ANON_AGGR_TYPE_P ( TREE_TYPE ( field ) ) ) { tree elt = TYPE_FIELDS ( TREE_TYPE ( field ) ) ; for ( ; elt ; elt = TREE_CHAIN ( elt ) ) { if ( DECL_ARTIFICIAL ( elt ) && ( ! DECL_IMPLICIT_TYPEDEF_P ( elt ) || TYPE_ANONYMOUS_P ( TREE_TYPE ( elt ) ) ) ) continue ; if ( TREE_CODE ( elt ) != FIELD_DECL ) { pedwarn ( " " " " , elt ) ; continue ; } if ( TREE_PRIVATE ( elt ) ) pedwarn ( " " , elt ) ; else if ( TREE_PROTECTED ( elt ) ) pedwarn ( " " , elt ) ; TREE_PRIVATE ( elt ) = TREE_PRIVATE ( field ) ; TREE_PROTECTED ( elt ) = TREE_PROTECTED ( field ) ; } } } }
Check for things that are invalid.
Check for things that are invalid .
/* We're generally only interested in entities the user
		 declared, but we also find nested classes by noticing
		 the TYPE_DECL that we create implicitly.  You're
		 allowed to put one anonymous union inside another,
		 though, so we explicitly tolerate that.  We use
		 TYPE_ANONYMOUS_P rather than ANON_AGGR_TYPE_P so that
		 we also allow unnamed types used for defining fields.  */