FreeBSD/contrib/gcc/cp/typeck.c
/* Compare two exception specifier types for exactness or subsetness, if
   allowed. Returns false for mismatch, true for match (same, or
   derived and !exact).

   [except.spec] "If a class X ... objects of class X or any class publicly
   and unambiguously derived from X. Similarly, if a pointer type Y * ...
   exceptions of type Y * or that are pointers to any type publicly and
   unambiguously derived from Y. Otherwise a function only allows exceptions
   that have the same type ..."
   This does not mention cv qualifiers and is different to what throw
   [except.throw] and catch [except.catch] will do. They will ignore the
   top level cv qualifiers, and allow qualifiers in the pointer to class
   example.

   We implement the letter of the standard.  */
Compare two exception specifier types for exactness or subsetness, if
allowed. Returns false for mismatch, true for match (same, or
derived and !exact).

[except.spec] "If a class X ... objects of class X or any class publicly
and unambiguously derived from X. Similarly, if a pointer type Y *
exceptions of type Y * or that are pointers to any type publicly and
unambiguously derived from Y. Otherwise a function only allows exceptions
that have the same type ..."
This does not mention cv qualifiers and is different to what throw
[except.throw] and catch [except.catch] will do. They will ignore the
top level cv qualifiers, and allow qualifiers in the pointer to class
example.

We implement the letter of the standard.
Compare two exception specifier types for exactness or subsetness if allowed . Returns false for mismatch true for match ( same or derived and !exact ) . [ except . spec ] " If a class X ... objects of class X or any class publicly and unambiguously derived from X . Similarly if a pointer type Y * exceptions of type Y * or that are pointers to any type publicly and unambiguously derived from Y . Otherwise a function only allows exceptions that have the same type ... " This does not mention cv qualifiers and is different to what throw [ except . throw ] and catch [ except . catch ] will do . They will ignore the top level cv qualifiers and allow qualifiers in the pointer to class example . We implement the letter of the standard .
static bool
comp_except_types (tree a, tree b, bool exact)
{
  if (same_type_p (a, b))
    return true;
  else if (!exact)
    {
      if (cp_type_quals (a) || cp_type_quals (b))
	return false;
      if (TREE_CODE (a) == POINTER_TYPE
	  && TREE_CODE (b) == POINTER_TYPE)
	{
	  a = TREE_TYPE (a);
	  b = TREE_TYPE (b);
	  if (cp_type_quals (a) || cp_type_quals (b))
	    return false;
	}
      if (TREE_CODE (a) != RECORD_TYPE
	  || TREE_CODE (b) != RECORD_TYPE)
	return false;
      if (PUBLICLY_UNIQUELY_DERIVED_P (a, b))
	return true;
    }
  return false;
}
static bool comp_except_types ( tree a , tree b , bool exact ) { if ( same_type_p ( a , b ) ) return true ; else if ( ! exact ) { if ( cp_type_quals ( a ) || cp_type_quals ( b ) ) return false ; if ( TREE_CODE ( a ) == POINTER_TYPE && TREE_CODE ( b ) == POINTER_TYPE ) { a = TREE_TYPE ( a ) ; b = TREE_TYPE ( b ) ; if ( cp_type_quals ( a ) || cp_type_quals ( b ) ) return false ; } if ( TREE_CODE ( a ) != RECORD_TYPE || TREE_CODE ( b ) != RECORD_TYPE ) return false ; if ( PUBLICLY_UNIQUELY_DERIVED_P ( a , b ) ) return true ; } return false ; }
Compare two exception specifier types for exactness or subsetness, if
allowed.
Compare two exception specifier types for exactness or subsetness if allowed .