re PR c++/65687 (Inconsistent behavior for __attribute__((__deprecated__)) between...
authorJason Merrill <jason@redhat.com>
Thu, 21 Jan 2016 20:26:21 +0000 (15:26 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 21 Jan 2016 20:26:21 +0000 (15:26 -0500)
PR c++/65687
* decl.c (type_is_deprecated): Don't look into a typedef.

From-SVN: r232703

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.dg/warn/deprecated-10.C [new file with mode: 0644]

index c592cbf4f729edb887b398cfe38fc20c59d06acb..af5c907713e7967f434b323fa4c7f51298fc2462 100644 (file)
@@ -1,5 +1,8 @@
 2016-01-21  Jason Merrill  <jason@redhat.com>
 
+       PR c++/65687
+       * decl.c (type_is_deprecated): Don't look into a typedef.
+
        PR c++/40751
        PR c++/64987
        * decl.c (copy_type_enum): Respect TYPE_USER_ALIGN.
index 020e9bd2510a4b5bd4efddd32240a89d6f33a3c2..f4604b61ee02a79c66f09e688c6a68a4d1597270 100644 (file)
@@ -11595,9 +11595,13 @@ type_is_deprecated (tree type)
   enum tree_code code;
   if (TREE_DEPRECATED (type))
     return type;
-  if (TYPE_NAME (type)
-      && TREE_DEPRECATED (TYPE_NAME (type)))
-    return type;
+  if (TYPE_NAME (type))
+    {
+      if (TREE_DEPRECATED (TYPE_NAME (type)))
+       return type;
+      else
+       return NULL_TREE;
+    }
 
   /* Do warn about using typedefs to a deprecated class.  */
   if (OVERLOAD_TYPE_P (type) && type != TYPE_MAIN_VARIANT (type))
diff --git a/gcc/testsuite/g++.dg/warn/deprecated-10.C b/gcc/testsuite/g++.dg/warn/deprecated-10.C
new file mode 100644 (file)
index 0000000..55cdf3d
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/65687
+
+typedef struct old_visible_stuff *opaquePointer;
+
+struct old_visible_stuff {
+  int things_we_no_longer;
+  int wish_to_expose;
+} __attribute__((__deprecated__("do not refer to this, the layout might change")));
+
+typedef struct old_visible_stuff *another; // { dg-warning "deprecated" }
+
+opaquePointer runtime_function (opaquePointer someObject);
+
+opaquePointer bad_runtime_call (struct old_visible_stuff *otherObject); // { dg-warning "deprecated" }