re PR c++/79290 (forming pointer to member function tries to access "__pfn")
authorNathan Sidwell <nathan@acm.org>
Tue, 31 Jan 2017 19:37:11 +0000 (19:37 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Tue, 31 Jan 2017 19:37:11 +0000 (19:37 +0000)
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
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/pr79290.C [new file with mode: 0644]

index 78a5725dc6d0f6c84428f736b4dccc72f35b23d7..2a8660796e186ced1b937524f7514e7022bc76a1 100644 (file)
@@ -1,5 +1,8 @@
 2017-01-31  Nathan Sidwell  <nathan@acm.org>
 
+       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
index 8f66d3c7933c1475b9e2538512a96f44c61e72a3..ef4dae47133e326cf9ca8962b45d53c4ae17821b 100644 (file)
@@ -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
index 922fe645755a1b484e5f0bf612142a6e606e0e86..302843ddcdd7e5676b4025644423fb491a1ce1fe 100644 (file)
@@ -1,5 +1,8 @@
 2017-01-31  Nathan Sidwell  <nathan@acm.org>
 
+       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 (file)
index 0000000..65929e5
--- /dev/null
@@ -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<typename T>
+struct Printer {
+  bool Foo(const SongTag &st) {
+    return st.function () == &Song::get;
+  }
+};
+
+void Baz (Printer<int> *p, SongTag const &st)
+{
+  p->Foo (st);
+}