public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch c++] (__attribute__((deprecated)), part a) Fix PR17729
@ 2010-04-17 12:47 IainS
  2010-06-08 23:12 ` Jason Merrill
  0 siblings, 1 reply; 7+ messages in thread
From: IainS @ 2010-04-17 12:47 UTC (permalink / raw)
  To: GCC Patches; +Cc: Joseph S. Myers

[-- Attachment #1: Type: text/plain, Size: 676 bytes --]

Split-up of http://gcc.gnu.org/ml/gcc-patches/2010-04/msg01037.html
Part a.

I guess the testcase is somewhat moot because of  http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30612
... but I included for completeness.

regtested on i686-apple-darwin9

OK for trunk? (and since this dates back to 4.3 .. I guess at least  
4.5 ? )
Iain.

gcc/cp/Changelog:

	PR c++/17729
	* typeck.c(build_class_member_access_expr): Don't check for  
deprecation here.
	* call.c(build_call_a): Ditto.
	(build_over_call): Ditto.
	(convert_like_real): Check for deprecation here instead.
	(build_new_method_call): Ditto.

gcc/testsuite/Changelog:

	PR c++/17729
	* g++.dg/warm/deprecated-7.C: New.



[-- Attachment #2: 158459-cp-dup-errs-diff.txt --]
[-- Type: text/plain, Size: 3664 bytes --]

Index: gcc/cp/typeck.c
===================================================================
--- gcc/cp/typeck.c	(revision 158459)
+++ gcc/cp/typeck.c	(working copy)
@@ -2149,9 +2149,7 @@ build_class_member_access_expr (tree object, tree
     {
       member_scope = DECL_CLASS_CONTEXT (member);
       mark_used (member);
-      if (TREE_DEPRECATED (member))
-	warn_deprecated_use (member, NULL_TREE);
-    }
+   }
   else
     member_scope = BINFO_TYPE (BASELINK_ACCESS_BINFO (member));
   /* If MEMBER is from an anonymous aggregate, MEMBER_SCOPE will
Index: gcc/cp/call.c
===================================================================
--- gcc/cp/call.c	(revision 158459)
+++ gcc/cp/call.c	(working copy)
@@ -344,8 +344,6 @@ build_call_a (tree function, int n, tree *argarray
   if (decl && TREE_THIS_VOLATILE (decl) && cfun && cp_function_chain)
     current_function_returns_abnormally = 1;
 
-  if (decl && TREE_DEPRECATED (decl))
-    warn_deprecated_use (decl, NULL_TREE);
   require_complete_eh_spec_types (fntype, decl);
 
   if (decl && DECL_CONSTRUCTOR_P (decl))
@@ -4904,6 +4902,10 @@ convert_like_real (conversion *convs, tree expr, t
 	for (i = 0; i < cand->num_convs; ++i)
 	  cand->convs[i]->user_conv_p = true;
 
+	/* Warn on deprecation of the candidate conversion func. */
+	if (TREE_DEPRECATED (convfn))
+	  warn_deprecated_use (convfn, NULL_TREE);
+
 	expr = build_over_call (cand, LOOKUP_NORMAL, complain);
 
 	/* If this is a constructor or a function returning an aggr type,
@@ -5864,11 +5866,6 @@ build_over_call (struct z_candidate *cand, int fla
 				ba_any, NULL);
       gcc_assert (binfo && binfo != error_mark_node);
 
-      /* Warn about deprecated virtual functions now, since we're about
-	 to throw away the decl.  */
-      if (TREE_DEPRECATED (fn))
-	warn_deprecated_use (fn, NULL_TREE);
-
       argarray[0] = build_base_path (PLUS_EXPR, argarray[0], binfo, 1);
       if (TREE_SIDE_EFFECTS (argarray[0]))
 	argarray[0] = save_expr (argarray[0]);
@@ -6458,6 +6455,11 @@ build_new_method_call (tree instance, tree fns, VE
 	      /* Now we know what function is being called.  */
 	      if (fn_p)
 		*fn_p = fn;
+
+	      /* Check for deprecation of the function to the called. */
+	      if (TREE_DEPRECATED (fn))
+		warn_deprecated_use (fn, NULL_TREE);
+	      
 	      /* Build the actual CALL_EXPR.  */
 	      call = build_over_call (cand, flags, complain);
 	      /* In an expression of the form `a->f()' where `f' turns
Index: gcc/testsuite/g++.dg/warn/deprecated-7.C
===================================================================
--- gcc/testsuite/g++.dg/warn/deprecated-7.C	(revision 0)
+++ gcc/testsuite/g++.dg/warn/deprecated-7.C	(revision 0)
@@ -0,0 +1,34 @@
+// PR c++/17729 Multiple warnings for single errors.
+// { dg-do compile }
+
+void func(void) __attribute__((deprecated));
+
+void f(void) {
+  func(); // { dg-warning "'void func\\(\\)' is deprecated" "func()" }	
+// { dg-warning "'void func\\(\\)' is deprecated" "func()" { ! target *-*-* } 7 }	
+}
+
+struct s1 {
+  int notdep ;
+  int depfield __attribute__((deprecated));
+  union {
+    int notdep;
+    int deprec __attribute__((deprecated));
+  } u1 ;
+  union {
+    int notdep1;
+    int notdep2;
+  } u2 __attribute__((deprecated)) ;
+ 
+} ;
+
+int main(void) { 
+ struct s1 a;
+ int b;
+ b  = a.notdep;
+ b += a.depfield; // { dg-warning "'s1::depfield' is deprecated .declared at" "depfield" }
+ b += a.u1.notdep;
+ b += a.u1.deprec; // { dg-warning "'s1::<anonymous union>::deprec' is deprecated .declared at" "s1::u1.deprec" }
+ b += a.u2.notdep1 ;// { dg-warning "'s1::u2' is deprecated .declared at" "s1::u2" }
+ return 0;
+}

[-- Attachment #3: Type: text/plain, Size: 1 bytes --]



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-07-21 13:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-17 12:47 [Patch c++] (__attribute__((deprecated)), part a) Fix PR17729 IainS
2010-06-08 23:12 ` Jason Merrill
2010-06-09  0:26   ` IainS
2010-06-09  3:29     ` Jason Merrill
2010-07-19 17:11       ` IainS
2010-07-19 17:59         ` Jason Merrill
2010-07-21 13:43           ` IainS

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).