diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2011-11-06 21:05:44 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2011-11-06 21:05:44 +0000 |
commit | 9965f21f9ce932dd77935cd0375085571e8dffa0 (patch) | |
tree | 078f15895c3fe1af4a24d246903573fc9dfad9d7 | |
parent | f25481f470c2810f6af2a7fcd76e2a0804b5f738 (diff) | |
download | gcc-9965f21f9ce932dd77935cd0375085571e8dffa0.zip gcc-9965f21f9ce932dd77935cd0375085571e8dffa0.tar.gz gcc-9965f21f9ce932dd77935cd0375085571e8dffa0.tar.bz2 |
re PR c++/47695 ([C++0X] Calling a deleted function fails twice)
2011-11-06 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/47695
* decl2.c (mark_used): Early return false after error or sorry.
* cp-tree.h (mark_used): Adjust declaration.
* semantics.c (finish_id_expression): Check mark_used return value.
From-SVN: r181042
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 2 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 25 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 5 |
4 files changed, 25 insertions, 14 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 642c507..f374af6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2011-11-06 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/47695 + * decl2.c (mark_used): Early return false after error or sorry. + * cp-tree.h (mark_used): Adjust declaration. + * semantics.c (finish_id_expression): Check mark_used return value. + 2011-11-05 Jason Merrill <jason@redhat.com> * decl.c (cp_finish_decl): Mostly revert previous change. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index c941abc..fd57409 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -5049,7 +5049,7 @@ extern tree build_offset_ref_call_from_tree (tree, VEC(tree,gc) **); extern bool decl_constant_var_p (tree); extern bool decl_maybe_constant_var_p (tree); extern void check_default_args (tree); -extern void mark_used (tree); +extern bool mark_used (tree); extern void finish_static_data_member_decl (tree, tree, bool, tree, int); extern tree cp_build_parm_decl (tree, tree); extern tree get_guard (tree); diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 32b5c7e..f4499b5 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -4203,9 +4203,10 @@ possibly_inlined_p (tree decl) /* Mark DECL (either a _DECL or a BASELINK) as "used" in the program. If DECL is a specialization or implicitly declared class member, - generate the actual definition. */ + generate the actual definition. Return false if something goes + wrong, true otherwise. */ -void +bool mark_used (tree decl) { /* If DECL is a BASELINK for a single function, then treat it just @@ -4216,7 +4217,7 @@ mark_used (tree decl) { decl = BASELINK_FUNCTIONS (decl); if (really_overloaded_fn (decl)) - return; + return true; decl = OVL_CURRENT (decl); } @@ -4237,13 +4238,13 @@ mark_used (tree decl) generate it properly; see maybe_add_lambda_conv_op. */ sorry ("converting lambda which uses %<...%> to " "function pointer"); - return; + return false; } } error ("use of deleted function %qD", decl); if (!maybe_explain_implicit_delete (decl)) error_at (DECL_SOURCE_LOCATION (decl), "declared here"); - return; + return false; } /* We can only check DECL_ODR_USED on variables or functions with @@ -4252,20 +4253,20 @@ mark_used (tree decl) if ((TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != FUNCTION_DECL) || DECL_LANG_SPECIFIC (decl) == NULL || DECL_THUNK_P (decl)) - return; + return true; /* We only want to do this processing once. We don't need to keep trying to instantiate inline templates, because unit-at-a-time will make sure we get them compiled before functions that want to inline them. */ if (DECL_ODR_USED (decl)) - return; + return true; /* If within finish_function, defer the rest until that function finishes, otherwise it might recurse. */ if (defer_mark_used_calls) { VEC_safe_push (tree, gc, deferred_mark_used_calls, decl); - return; + return true; } if (TREE_CODE (decl) == FUNCTION_DECL) @@ -4294,15 +4295,15 @@ mark_used (tree decl) /* If we don't need a value, then we don't need to synthesize DECL. */ if (cp_unevaluated_operand != 0) - return; + return true; if (processing_template_decl) - return; + return true; /* Check this too in case we're within fold_non_dependent_expr. */ if (DECL_TEMPLATE_INFO (decl) && uses_template_parms (DECL_TI_ARGS (decl))) - return; + return true; DECL_ODR_USED (decl) = 1; if (DECL_CLONED_FUNCTION_P (decl)) @@ -4380,6 +4381,8 @@ mark_used (tree decl) /*expl_inst_class_mem_p=*/false); --function_depth; } + + return true; } #include "gt-cp-decl2.h" diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index cebb7df..c5ced87 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3286,8 +3286,9 @@ finish_id_expression (tree id_expression, if (TREE_CODE (first_fn) == TEMPLATE_DECL) first_fn = DECL_TEMPLATE_RESULT (first_fn); - if (!really_overloaded_fn (decl)) - mark_used (first_fn); + if (!really_overloaded_fn (decl) + && !mark_used (first_fn)) + return error_mark_node; if (!template_arg_p && TREE_CODE (first_fn) == FUNCTION_DECL |