FreeBSD/contrib/gcc/c-common.c
/* Make a variant type in the proper way for C/C++, propagating qualifiers
   down to the element type of an array.  */
Make a variant type in the proper way for C/C++, propagating qualifiers
down to the element type of an array.
Make a variant type in the proper way for C / C ++ propagating qualifiers down to the element type of an array .
tree
c_build_qualified_type (tree type, int type_quals)
{
  if (type == error_mark_node)
    return type;
  if (TREE_CODE (type) == ARRAY_TYPE)
    {
      tree t;
      tree element_type = c_build_qualified_type (TREE_TYPE (type),
						  type_quals);
      for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))
	{
	  if (TYPE_QUALS (strip_array_types (t)) == type_quals
	      && TYPE_NAME (t) == TYPE_NAME (type)
	      && TYPE_CONTEXT (t) == TYPE_CONTEXT (type)
	      && attribute_list_equal (TYPE_ATTRIBUTES (t),
				       TYPE_ATTRIBUTES (type)))
	    break;
	}
      if (!t)
	{
	  t = build_variant_type_copy (type);
	  TREE_TYPE (t) = element_type;
	}
      return t;
    }
  if ((type_quals & TYPE_QUAL_RESTRICT)
      && (!POINTER_TYPE_P (type)
	  || !C_TYPE_OBJECT_OR_INCOMPLETE_P (TREE_TYPE (type))))
    {
      error ("invalid use of %<restrict%>");
      type_quals &= ~TYPE_QUAL_RESTRICT;
    }
  return build_qualified_type (type, type_quals);
}
tree c_build_qualified_type ( tree type , int type_quals ) { if ( type == error_mark_node ) return type ; if ( TREE_CODE ( type ) == ARRAY_TYPE ) { tree t ; tree element_type = c_build_qualified_type ( TREE_TYPE ( type ) , type_quals ) ; for ( t = TYPE_MAIN_VARIANT ( type ) ; t ; t = TYPE_NEXT_VARIANT ( t ) ) { if ( TYPE_QUALS ( strip_array_types ( t ) ) == type_quals && TYPE_NAME ( t ) == TYPE_NAME ( type ) && TYPE_CONTEXT ( t ) == TYPE_CONTEXT ( type ) && attribute_list_equal ( TYPE_ATTRIBUTES ( t ) , TYPE_ATTRIBUTES ( type ) ) ) break ; } if ( ! t ) { t = build_variant_type_copy ( type ) ; TREE_TYPE ( t ) = element_type ; } return t ; } if ( ( type_quals & TYPE_QUAL_RESTRICT ) && ( ! POINTER_TYPE_P ( type ) || ! C_TYPE_OBJECT_OR_INCOMPLETE_P ( TREE_TYPE ( type ) ) ) ) { error ( " " ) ; type_quals &= ~ TYPE_QUAL_RESTRICT ; } return build_qualified_type ( type , type_quals ) ; }
Make a variant type in the proper way for C/C++, propagating qualifiers
down to the element type of an array.
Make a variant type in the proper way for C / C ++ propagating qualifiers down to the element type of an array .
/* See if we already have an identically qualified type.  */ /* A restrict-qualified pointer type must be a pointer to object or
     incomplete type.  Note that the use of POINTER_TYPE_P also allows
     REFERENCE_TYPEs, which is appropriate for C++.  */