Commit d4684c00 by Jason Merrill Committed by Jason Merrill

re PR c++/42219 (ICE with "const void" as parameter type)

	PR c++/42219
	* typeck.c (error_type_p): New.
	(ptr_reasonably_similar): Use it.
	* cp-tree.h: Declare it.

From-SVN: r155177
parent ae2cac71
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
......
......@@ -5336,6 +5336,7 @@ extern tree convert_for_initialization (tree, tree, tree, int,
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);
......
......@@ -7471,6 +7471,44 @@ comp_ptr_ttypes (tree to, tree from)
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. */
......@@ -7480,9 +7518,10 @@ ptr_reasonably_similar (const_tree to, const_tree from)
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;
......@@ -7502,7 +7541,7 @@ ptr_reasonably_similar (const_tree to, const_tree from)
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
......
2009-12-11 Jason Merrill <jason@redhat.com>
PR c++/42219
* g++.dg/conversion/err-recover1.C: New.
2009-12-11 Janus Weil <janus@gcc.gnu.org>
PR fortran/42335
......
// PR c++/42219
void foo(const void); // { dg-error "incomplete|const" }
void bar()
{
void (*pf)() = foo; // { dg-error "cannot convert" }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment