From 60349f15cce1213fc4f3e36209332eb69dd24e95 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Sat, 15 Aug 2015 03:59:26 -0400 Subject: [PATCH] re PR c++/65974 (Bogus deprecated-declarations warnings for inline definitions of deprecated virtual methods) PR c++/65974 * decl2.c (mark_vtable_entries): Suppress -Wdeprecated. From-SVN: r226908 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/decl2.c | 3 +++ gcc/testsuite/g++.dg/warn/deprecated-9.C | 16 ++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 gcc/testsuite/g++.dg/warn/deprecated-9.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e8008ce0140..a5a42ff11a5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2015-08-14 Jason Merrill + + PR c++/65974 + * decl2.c (mark_vtable_entries): Suppress -Wdeprecated. + 2015-08-12 Jason Merrill PR c++/67104 diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 8e7a453ec1b..74ba380c44d 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1747,6 +1747,9 @@ mark_vtable_entries (tree decl) tree fnaddr; unsigned HOST_WIDE_INT idx; + /* It's OK for the vtable to refer to deprecated virtual functions. */ + warning_sentinel w(warn_deprecated_decl); + FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (DECL_INITIAL (decl)), idx, fnaddr) { diff --git a/gcc/testsuite/g++.dg/warn/deprecated-9.C b/gcc/testsuite/g++.dg/warn/deprecated-9.C new file mode 100644 index 00000000000..fc861ee2442 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/deprecated-9.C @@ -0,0 +1,16 @@ +// PR c++/65974 +// { dg-options "-Wdeprecated" } + +struct S { + void bar(); + + __attribute__((deprecated("use bar() instead."))) + virtual void foo(); +}; + +void S::foo() { bar(); } + +int main() +{ + return 0; +} -- 2.30.2