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/cp | |
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/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/cp/class.c | 24 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 6 |
3 files changed, 18 insertions, 21 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); } |