From 5ae37bdfce3f433ff51af4d614d9271abb25671f Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Tue, 31 Jan 2017 19:37:11 +0000 Subject: [PATCH] re PR c++/79290 (forming pointer to member function tries to access "__pfn") PR c++/79290 * typeck.c (build_ptrmemfunc_access_expr): Set TREE_NO_WARNING. PR c++/79290 * g++.dg/warn/pr79290.C: New. From-SVN: r245069 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/typeck.c | 5 ++++- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/warn/pr79290.C | 25 +++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/warn/pr79290.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 78a5725dc6d..2a8660796e1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2017-01-31 Nathan Sidwell + PR c++/79290 + * typeck.c (build_ptrmemfunc_access_expr): Set TREE_NO_WARNING. + PR c++/67273 PR c++/79253 * pt.c: (instantiate_decl): Push to top level when current diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 8f66d3c7933..ef4dae47133 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -2950,7 +2950,10 @@ build_ptrmemfunc_access_expr (tree ptrmem, tree member_name) member = DECL_CHAIN (member)) if (DECL_NAME (member) == member_name) break; - return build_simple_component_ref (ptrmem, member); + tree res = build_simple_component_ref (ptrmem, member); + + TREE_NO_WARNING (res) = 1; + return res; } /* Given an expression PTR for a pointer, return an expression diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 922fe645755..302843ddcdd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2017-01-31 Nathan Sidwell + PR c++/79290 + * g++.dg/warn/pr79290.C: New. + PR c++/67273 PR c++/79253 * g++.dg/cpp1y/pr67273.C: New. diff --git a/gcc/testsuite/g++.dg/warn/pr79290.C b/gcc/testsuite/g++.dg/warn/pr79290.C new file mode 100644 index 00000000000..65929e55974 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/pr79290.C @@ -0,0 +1,25 @@ +// { dg-additional-options "-Wall" } +// PR 79290, bogus warning looking inside PMF + +struct Song { + int get() const ; +}; + +typedef int (Song::*PMF_t)() const; + +struct SongTag { + PMF_t function () const; +}; + + +template +struct Printer { + bool Foo(const SongTag &st) { + return st.function () == &Song::get; + } +}; + +void Baz (Printer *p, SongTag const &st) +{ + p->Foo (st); +} -- 2.30.2