public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/81188, error matching decltype of member function call
@ 2017-06-29 19:43 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2017-06-29 19:43 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 297 bytes --]

Here, cp_tree_equal was assuming that the member operand of
COMPONENT_REF will be == if it is equivalent; that isn't accurate for
a reference to a member function.  So let's remove the special case
and fall back on normal expression handling.

Tested x86_64-pc-linux-gnu, applying to trunk and 7.

[-- Attachment #2: 81188.diff --]
[-- Type: text/plain, Size: 1396 bytes --]

commit a4a899baf962a73d81ae776ab3a7d80ea0a5bf8b
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Jun 29 15:15:48 2017 -0400

            PR c++/81188 - matching decltype of member function call.
    
            * tree.c (cp_tree_equal): Remove COMPONENT_REF special case.

diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 4535af6..a52a9e8 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -3589,11 +3589,6 @@ cp_tree_equal (tree t1, tree t2)
 	return false;
       return cp_tree_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t1, 1));
 
-    case COMPONENT_REF:
-      if (TREE_OPERAND (t1, 1) != TREE_OPERAND (t2, 1))
-	return false;
-      return cp_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
-
     case PARM_DECL:
       /* For comparing uses of parameters in late-specified return types
 	 with an out-of-class definition of the function, but can also come
diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype-call4.C b/gcc/testsuite/g++.dg/cpp0x/decltype-call4.C
new file mode 100644
index 0000000..d504954
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/decltype-call4.C
@@ -0,0 +1,13 @@
+// PR c++/81188
+// { dg-do compile { target c++11 } }
+
+template <class F>
+struct C {
+  F fast(long i) const;
+  auto operator[](long i) const -> decltype(this->fast(i));
+};
+
+template <class F>
+auto C<F>::operator[](long i) const -> decltype(this->fast(i)) {
+  return fast(i);
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-06-29 19:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-29 19:43 C++ PATCH for c++/81188, error matching decltype of member function call 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).