diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2009-05-05 13:00:03 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2009-05-05 13:00:03 +0000 |
commit | 95e207682899fcbf2bcfc43dd2926a6e866e884a (patch) | |
tree | 4ea69e4744077e7a5591e81e2452d87a81f52039 /gcc | |
parent | 66ba9b0b152bf853249f594655c0791189b10fc6 (diff) | |
download | gcc-95e207682899fcbf2bcfc43dd2926a6e866e884a.zip gcc-95e207682899fcbf2bcfc43dd2926a6e866e884a.tar.gz gcc-95e207682899fcbf2bcfc43dd2926a6e866e884a.tar.bz2 |
typeck.c (cp_build_compound_expr): Require RHS to have a known type.
cp/
* typeck.c (cp_build_compound_expr): Require RHS to have a known
type.
* class.c (resolve_address_of_overloaded_function): Use
OVL_CURRENT for error message.
(instantiate_type): Forbid COMPOUND_EXPRs and remove code dealing
with them. Do not copy the node.
testsuite/
* g++.old-deja/g++.other/overload11.C: Adjust expected errors.
* g++.dg/template/overload9.C: Likewise.
* g++.dg/ext/ms-1.C: New.
From-SVN: r147125
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/cp/class.c | 24 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/ms-1.C | 17 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/overload9.C | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.other/overload11.C | 9 |
7 files changed, 47 insertions, 28 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 808f0b0..56e413f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2009-05-05 Nathan Sidwell <nathan@codesourcery.com> + + * typeck.c (cp_build_compound_expr): Require RHS to have a known + type. + * class.c (resolve_address_of_overloaded_function): Use + OVL_CURRENT for error message. + (instantiate_type): Forbid COMPOUND_EXPRs and remove code dealing + with them. Do not copy the node. + 2009-05-05 Jakub Jelinek <jakub@redhat.com> PR c++/40013 diff --git a/gcc/cp/class.c b/gcc/cp/class.c index a20b8c4..6ad9415 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -6147,7 +6147,7 @@ resolve_address_of_overloaded_function (tree target_type, if (flags & tf_error) { error ("no matches converting function %qD to type %q#T", - DECL_NAME (OVL_FUNCTION (overload)), + DECL_NAME (OVL_CURRENT (overload)), target_type); /* print_candidates expects a chain with the functions in @@ -6310,13 +6310,8 @@ instantiate_type (tree lhstype, tree rhs, tsubst_flags_t flags) dependent on overload resolution. */ gcc_assert (TREE_CODE (rhs) == ADDR_EXPR || TREE_CODE (rhs) == COMPONENT_REF - || TREE_CODE (rhs) == COMPOUND_EXPR - || really_overloaded_fn (rhs)); - - /* We don't overwrite rhs if it is an overloaded function. - Copying it would destroy the tree link. */ - if (TREE_CODE (rhs) != OVERLOAD) - rhs = copy_node (rhs); + || really_overloaded_fn (rhs) + || (flag_ms_extensions && TREE_CODE (rhs) == FUNCTION_DECL)); /* This should really only be used when attempting to distinguish what sort of a pointer to function we have. For now, any @@ -6368,19 +6363,6 @@ instantiate_type (tree lhstype, tree rhs, tsubst_flags_t flags) /*explicit_targs=*/NULL_TREE, access_path); - case COMPOUND_EXPR: - TREE_OPERAND (rhs, 0) - = instantiate_type (lhstype, TREE_OPERAND (rhs, 0), flags); - if (TREE_OPERAND (rhs, 0) == error_mark_node) - return error_mark_node; - TREE_OPERAND (rhs, 1) - = instantiate_type (lhstype, TREE_OPERAND (rhs, 1), flags); - if (TREE_OPERAND (rhs, 1) == error_mark_node) - return error_mark_node; - - TREE_TYPE (rhs) = lhstype; - return rhs; - case ADDR_EXPR: { if (PTRMEM_OK_P (rhs)) diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 5486c54..e34d942 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -5034,6 +5034,12 @@ cp_build_compound_expr (tree lhs, tree rhs, tsubst_flags_t complain) return rhs; } + if (type_unknown_p (rhs)) + { + error ("no context to resolve type of %qE", rhs); + return error_mark_node; + } + return build2 (COMPOUND_EXPR, TREE_TYPE (rhs), lhs, rhs); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bf5888a..f6ef3ef 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2009-05-05 Nathan Sidwell <nathan@codesourcery.com> + + * g++.old-deja/g++.other/overload11.C: Adjust expected errors. + * g++.dg/template/overload9.C: Likewise. + * g++.dg/ext/ms-1.C: New. + 2009-05-05 Jakub Jelinek <jakub@redhat.com> PR c++/40013 diff --git a/gcc/testsuite/g++.dg/ext/ms-1.C b/gcc/testsuite/g++.dg/ext/ms-1.C new file mode 100644 index 0000000..dcd1d04 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/ms-1.C @@ -0,0 +1,17 @@ + +// MS allows more things to be pointers to member functions +// { dg-options "-fms-extensions" } + +struct X +{ + void Foo (X *); + void Bar (); +}; + +void Quux (void (X::*) ()); + +void X::Foo (X *ptr) // { dg-message "candidates" } +{ + Quux (Foo); // { dg-error "no matches" } + Quux (Bar); +} diff --git a/gcc/testsuite/g++.dg/template/overload9.C b/gcc/testsuite/g++.dg/template/overload9.C index cef8ebe..8aeab9e 100644 --- a/gcc/testsuite/g++.dg/template/overload9.C +++ b/gcc/testsuite/g++.dg/template/overload9.C @@ -7,12 +7,12 @@ template <typename T> A<T>& operator<<(A<T>&, const B<T>&); template <typename T> struct A { - A<T>& operator<<(A<T>& (*)(A<T>&)); // { dg-message "candidate" } + A<T>& operator<<(A<T>& (*)(A<T>&)); }; template <typename T> A<T>& foo(A<T>&); extern A<char> c; int main () { - c << (1, foo); // { dg-error "no match" } + c << (1, foo); // { dg-error "no context" } } diff --git a/gcc/testsuite/g++.old-deja/g++.other/overload11.C b/gcc/testsuite/g++.old-deja/g++.other/overload11.C index 3b0cab7..e8c88fd 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/overload11.C +++ b/gcc/testsuite/g++.old-deja/g++.other/overload11.C @@ -54,11 +54,10 @@ int main (int argc, char **argv) ptr = (ovl); // ok ptr = (&ovl); // ok - // 13.4 indicates these are ok. - ptr = (0, ovl); // ok { dg-bogus "" "" { xfail *-*-* } } - ptr = (0, &ovl); // ok { dg-bogus "" "" { xfail *-*-* } } - ptr = (argc ? ovl : ovl); // ok { dg-bogus "" "" { xfail *-*-* } } - ptr = (argc ? &ovl : &ovl);// ok { dg-bogus "" "" { xfail *-*-* } } + ptr = (0, ovl); // ok { dg-error "no context" } + ptr = (0, &ovl); // ok { dg-error "no context" } + ptr = (argc ? ovl : ovl); // ok { dg-error "no context" } + ptr = (argc ? &ovl : &ovl);// ok { dg-error "no context" } vptr = (ovl); // { dg-error "" } no matching candidates vptr = (&ovl); // { dg-error "" } no matching candidates |