+2009-12-11 Jason Merrill <jason@redhat.com>
+
+ PR c++/42219
+ * typeck.c (error_type_p): New.
+ (ptr_reasonably_similar): Use it.
+ * cp-tree.h: Declare it.
+
2009-12-11 Dodji Seketeli <dodji@redhat.com>
PR c++/42225
tsubst_flags_t);
extern int comp_ptr_ttypes (tree, tree);
extern bool comp_ptr_ttypes_const (tree, tree);
+extern bool error_type_p (const_tree);
extern int ptr_reasonably_similar (const_tree, const_tree);
extern tree build_ptrmemfunc (tree, tree, int, bool);
extern int cp_type_quals (const_tree);
return comp_ptr_ttypes_real (to, from, 1);
}
+/* Returns true iff FNTYPE is a non-class type that involves
+ error_mark_node. We can get FUNCTION_TYPE with buried error_mark_node
+ if a parameter type is ill-formed. */
+
+bool
+error_type_p (const_tree type)
+{
+ tree t;
+
+ switch (TREE_CODE (type))
+ {
+ case ERROR_MARK:
+ return true;
+
+ case POINTER_TYPE:
+ case REFERENCE_TYPE:
+ case OFFSET_TYPE:
+ return error_type_p (TREE_TYPE (type));
+
+ case FUNCTION_TYPE:
+ case METHOD_TYPE:
+ if (error_type_p (TREE_TYPE (type)))
+ return true;
+ for (t = TYPE_ARG_TYPES (type); t; t = TREE_CHAIN (t))
+ if (error_type_p (TREE_VALUE (t)))
+ return true;
+ return false;
+
+ case RECORD_TYPE:
+ if (TYPE_PTRMEMFUNC_P (type))
+ return error_type_p (TYPE_PTRMEMFUNC_FN_TYPE (type));
+ return false;
+
+ default:
+ return false;
+ }
+}
+
/* Returns 1 if to and from are (possibly multi-level) pointers to the same
type or inheritance-related types, regardless of cv-quals. */
for (; ; to = TREE_TYPE (to), from = TREE_TYPE (from))
{
/* Any target type is similar enough to void. */
- if (TREE_CODE (to) == VOID_TYPE
- || TREE_CODE (from) == VOID_TYPE)
- return 1;
+ if (TREE_CODE (to) == VOID_TYPE)
+ return !error_type_p (from);
+ if (TREE_CODE (from) == VOID_TYPE)
+ return !error_type_p (to);
if (TREE_CODE (to) != TREE_CODE (from))
return 0;
return 1;
if (TREE_CODE (to) == FUNCTION_TYPE)
- return 1;
+ return !error_type_p (to) && !error_type_p (from);
if (TREE_CODE (to) != POINTER_TYPE)
return comptypes