diff options
author | Jason Merrill <jason@redhat.com> | 2009-12-11 16:03:55 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2009-12-11 16:03:55 -0500 |
commit | d4684c007a26cbfe71548b1173dd642b8daab1c2 (patch) | |
tree | 4cacc86de671f112c5dd9cc8f03f7cb9d99b9504 /gcc | |
parent | ae2cac711f13fb778f5065b160e5b27b56c0f129 (diff) | |
download | gcc-d4684c007a26cbfe71548b1173dd642b8daab1c2.zip gcc-d4684c007a26cbfe71548b1173dd642b8daab1c2.tar.gz gcc-d4684c007a26cbfe71548b1173dd642b8daab1c2.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 1 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 47 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/conversion/err-recover1.C | 8 |
5 files changed, 64 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 988f98f..e51641b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +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 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index d0a0435..eb7f06d 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -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); diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 791b506..782502d 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 598c1aa..92163b3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +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 diff --git a/gcc/testsuite/g++.dg/conversion/err-recover1.C b/gcc/testsuite/g++.dg/conversion/err-recover1.C new file mode 100644 index 0000000..9723789 --- /dev/null +++ b/gcc/testsuite/g++.dg/conversion/err-recover1.C @@ -0,0 +1,8 @@ +// PR c++/42219 + +void foo(const void); // { dg-error "incomplete|const" } + +void bar() +{ + void (*pf)() = foo; // { dg-error "cannot convert" } +} |