diff mbox

[C++] PR 47695

Message ID 4EB69CAC.6070900@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Nov. 6, 2011, 2:41 p.m. UTC
Hi,

duplicate diagnostics for (a pretty common error, I would guess):

void f() = delete;
void g() { f(); }

47695.C: In function ‘void g()’:
47695.C:2:12: error: use of deleted function ‘void f()’
47695.C:1:6: error: declared here
47695.C:2:14: error: use of deleted function ‘void f()’
47695.C:1:6: error: declared here

I'm fixing it by returning a bool from mark_used and checking it in 
finish_id_expression. Works fine, passes the testsuite. Or shall we do 
something more sophisticated?!?

Thanks,
Paolo.

PS: sorry if you are receiving this message two or even three times, 
today I'm experiencing serious problems with my connection and I have no 
idea whether is going through

///////////////////
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.
diff mbox

Patch

Index: semantics.c
===================================================================
--- semantics.c	(revision 181027)
+++ semantics.c	(working copy)
@@ -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
Index: decl2.c
===================================================================
--- decl2.c	(revision 181027)
+++ decl2.c	(working copy)
@@ -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"
Index: cp-tree.h
===================================================================
--- cp-tree.h	(revision 181027)
+++ cp-tree.h	(working copy)
@@ -5049,7 +5049,7 @@  extern tree build_offset_ref_call_from_tree	(tree,
 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);