This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch for bug 7425 (and similar C++ bug)


This patch fixes bug 7425, that __attribute__((deprecated)) failed to
merge with multiple declarations; though the attribute lists merge,
the separate TREE_DEPRECATED information needed to merge as well.
Though this bug report was for C, the same problem is also present in
the C++ front end, with the same fix, so this patch fixes the issue
for both C and C++.

(The C++ front end gives a duplicate diagnostic for the use of a
deprecated function; this is already the case before the patch with a
single declaration of the function as deprecated, and I've filed bug
17729 for it.)

Bootstrapped with no regressions on i686-pc-linux-gnu.  OK to commit
(the C++ part)?

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
  http://www.srcf.ucam.org/~jsm28/gcc/#c90status - status of C90 for GCC 4.0
    jsm@polyomino.org.uk (personal mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)

2004-09-29  Joseph S. Myers  <jsm@polyomino.org.uk>

	PR c/7425
	* c-decl.c (merge_decls): Merge TREE_DEPRECATED.

cp:
2004-09-29  Joseph S. Myers  <jsm@polyomino.org.uk>

	* decl.c (duplicate_decls): Merge TREE_DEPRECATED.

testsuite:
2004-09-29  Joseph S. Myers  <jsm@polyomino.org.uk>

	PR c/7425
	* gcc.dg/deprecated-3.c, g++.dg/warn/deprecated-2.C: New tests.

diff -rupN GCC.orig/gcc/c-decl.c GCC/gcc/c-decl.c
--- GCC.orig/gcc/c-decl.c	2004-09-28 19:32:50.000000000 +0000
+++ GCC/gcc/c-decl.c	2004-09-29 14:09:03.000000000 +0000
@@ -1586,6 +1586,10 @@ merge_decls (tree newdecl, tree olddecl,
 	make_var_volatile (newdecl);
     }
 
+  /* Merge deprecatedness.  */
+  if (TREE_DEPRECATED (newdecl))
+    TREE_DEPRECATED (olddecl) = 1;
+
   /* Keep source location of definition rather than declaration.  */
   if (DECL_INITIAL (newdecl) == 0 && DECL_INITIAL (olddecl) != 0)
     DECL_SOURCE_LOCATION (newdecl) = DECL_SOURCE_LOCATION (olddecl);
diff -rupN GCC.orig/gcc/cp/decl.c GCC/gcc/cp/decl.c
--- GCC.orig/gcc/cp/decl.c	2004-09-28 08:18:51.000000000 +0000
+++ GCC/gcc/cp/decl.c	2004-09-29 14:12:16.000000000 +0000
@@ -1720,6 +1720,10 @@ duplicate_decls (tree newdecl, tree oldd
       if (TREE_THIS_VOLATILE (newdecl))
 	TREE_THIS_VOLATILE (olddecl) = 1;
 
+      /* Merge deprecatedness.  */
+      if (TREE_DEPRECATED (newdecl))
+	TREE_DEPRECATED (olddecl) = 1;
+
       /* Merge the initialization information.  */
       if (DECL_INITIAL (newdecl) == NULL_TREE
 	  && DECL_INITIAL (olddecl) != NULL_TREE)
diff -rupN GCC.orig/gcc/testsuite/g++.dg/warn/deprecated-2.C GCC/gcc/testsuite/g++.dg/warn/deprecated-2.C
--- GCC.orig/gcc/testsuite/g++.dg/warn/deprecated-2.C	1970-01-01 00:00:00.000000000 +0000
+++ GCC/gcc/testsuite/g++.dg/warn/deprecated-2.C	2004-09-29 14:11:38.000000000 +0000
@@ -0,0 +1,11 @@
+/* Test __attribute__((deprecated)).  Test merging with multiple
+   declarations.  Bug 7425 (C++ version).  */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+void func(void);
+void func(void) __attribute__((deprecated));
+
+void f(void) {
+  func(); /* { dg-warning "'func' is deprecated" } */
+}
diff -rupN GCC.orig/gcc/testsuite/gcc.dg/deprecated-3.c GCC/gcc/testsuite/gcc.dg/deprecated-3.c
--- GCC.orig/gcc/testsuite/gcc.dg/deprecated-3.c	1970-01-01 00:00:00.000000000 +0000
+++ GCC/gcc/testsuite/gcc.dg/deprecated-3.c	2004-09-29 14:05:32.000000000 +0000
@@ -0,0 +1,11 @@
+/* Test __attribute__((deprecated)).  Test merging with multiple
+   declarations.  Bug 7425.  */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+void func(void);
+void func(void) __attribute__((deprecated));
+
+void f(void) {
+  func(); /* { dg-warning "'func' is deprecated" } */
+}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]