* C++ PATCH for c++/65687 (typedefs and attribute deprecated)
@ 2016-01-21 20:25 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2016-01-21 20:25 UTC (permalink / raw)
To: gcc-patches List
[-- Attachment #1: Type: text/plain, Size: 314 bytes --]
This BZ asks that the C++ front end follow the behavior of the C front
end in handling typedefs that involve deprecated types: we should warn
when defining the typedef, not when using it. This seems reasonable,
particularly since the C front end works this way.
Tested x86_64-pc-linux-gnu, applying to trunk.
[-- Attachment #2: 65687.patch --]
[-- Type: text/x-patch, Size: 1507 bytes --]
commit a2de40417b69ee1a42396ecbe8ca7e02a7541160
Author: Jason Merrill <jason@redhat.com>
Date: Thu Jan 21 14:45:05 2016 -0500
PR c++/65687
* decl.c (type_is_deprecated): Don't look into a typedef.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 020e9bd..f4604b6 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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
index 0000000..55cdf3d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/deprecated-10.C
@@ -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" }
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-01-21 20:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-21 20:25 C++ PATCH for c++/65687 (typedefs and attribute deprecated) Jason Merrill
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).