g++ and aliasing bools

Joe Buck jbuck@synopsys.COM
Fri Jan 25 13:16:00 GMT 2002


Paolo wrote:

> Should'nt this be in pseudocode, even more safely:
> 
> {
>         if (AGGREGATE_TYPE && (HAS_BASECLASSES || HAS_VIRTUALS))
>                 return 0;
>         return c_get_alias_set();
> }

The new version would look like

/* return true iff, for purposes of layout, we have a C object.
 */

bool
cxx_simple_enough_type(type t)
{
	if (!AGGREGATE_TYPE(t))
		return true;
	if (HAS_BASECLASSES(t) || HAS_VIRTUALS(t))
		return false;
	for(each member m of t) {
		if (cxx_simple_enough_type(typeof(m)))
			return false;
	}
	return true;
}

alias_set*
cxx_get_alias_set(type t)
{
	if (!cxx_simple_enough_type(t))
		return 0;
	return c_get_alias_set();
}



More information about the Gcc mailing list