return false;
}
+/* Return true if T2 is derived form T1. */
+
+bool
+odr_equivalent_or_derived_p (tree t1, tree t2)
+{
+ if (in_lto_p)
+ {
+ if (odr_types_equivalent_p (t1, t2))
+ return true;
+ }
+ else
+ {
+ if (TYPE_MAIN_VARIANT (t1) == TYPE_MAIN_VARIANT (t2))
+ return true;
+ }
+ if (!TYPE_BINFO (t2))
+ return false;
+ for (unsigned int i = 0; i < BINFO_N_BASE_BINFOS (TYPE_BINFO (t2)); i++)
+ if (odr_equivalent_or_derived_p
+ (t1, BINFO_TYPE (BINFO_BASE_BINFO (TYPE_BINFO (t2), i))))
+ return true;
+ return false;
+}
+
/* Compare T1 and T2, report ODR violations if WARN is true and set
WARNED to true if anything is reported. Return true if types match.
If true is returned, the types are also compatible in the sense of
void warn_types_mismatch (tree t1, tree t2, location_t loc1 = UNKNOWN_LOCATION,
location_t loc2 = UNKNOWN_LOCATION);
bool odr_or_derived_type_p (const_tree t);
+bool odr_equivalent_or_derived_p (tree t1, tree t2);
bool odr_types_equivalent_p (tree type1, tree type2);
bool odr_type_violation_reported_p (tree type);
tree prevailing_odr_type (tree type);
#include "attribs.h"
#include "asan.h"
#include "gimplify.h"
+#include "print-tree.h"
+#include "ipa-utils.h"
/* In some instances a tree and a gimple need to be stored in a same table,
i.e. in hash tables. This is a structure to do this. */
return true;
}
+bool
+same_or_derived_type (tree t1, tree t2)
+{
+ t1 = TYPE_MAIN_VARIANT (t1);
+ t2 = TYPE_MAIN_VARIANT (t2);
+ if (t1 == t2)
+ return true;
+ while ((TREE_CODE (t1) == POINTER_TYPE || TREE_CODE (t1) == REFERENCE_TYPE)
+ && TREE_CODE (t1) == TREE_CODE (t2))
+ {
+ t1 = TYPE_MAIN_VARIANT (TREE_TYPE (t1));
+ t2 = TYPE_MAIN_VARIANT (TREE_TYPE (t2));
+ }
+ if (t1 == t2)
+ return true;
+ if (!AGGREGATE_TYPE_P (t1) || !AGGREGATE_TYPE_P (t2))
+ return false;
+ return odr_equivalent_or_derived_p (t1, t2);
+}
// Check if a landing pad can handle any of the given exception types
bool match_lp(eh_landing_pad lp, vec<tree> *exception_types) {
while (catch_handler) {
tree type_list = catch_handler->type_list;
+ if(type_list == NULL) {
+ return true;
+ }
+
for (tree t = type_list; t; t = TREE_CHAIN(t)) {
tree type = TREE_VALUE(t);
for (unsigned i = 0; i < exception_types->length(); ++i) {
// match found or a catch-all handler (NULL)
- if (type == (*exception_types)[i] || !type) {
+ if (!type || same_or_derived_type ((*exception_types)[i], type)) {
return true;
}
}