Patchwork C++ PATCH for 3 ref-qualifier issues

login
register
mail settings
Submitter Jason Merrill
Date May 13, 2013, 7:19 p.m.
Message ID <51913CB0.8090801@redhat.com>
Download mbox | patch
Permalink /patch/243499/
State New
Headers show

Comments

Jason Merrill - May 13, 2013, 7:19 p.m.
3 places that hadn't yet been updated to handle ref-qualifiers.

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

Patch

commit e4f9e32f7e7b9e508f713ac15a9edbd275d4bd85
Author: Jason Merrill <jason@redhat.com>
Date:   Mon May 13 10:45:41 2013 -0400

    	PR c++/57252
    	* decl.c (decls_match): Compare ref-qualifiers.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index d8363b2..faa2911 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -1024,6 +1024,7 @@  decls_match (tree newdecl, tree olddecl)
 	  else
 	    types_match =
 	      compparms (p1, p2)
+	      && type_memfn_rqual (f1) == type_memfn_rqual (f2)
 	      && (TYPE_ATTRIBUTES (TREE_TYPE (newdecl)) == NULL_TREE
 	          || comp_type_attributes (TREE_TYPE (newdecl),
 					   TREE_TYPE (olddecl)) != 0);
diff --git a/gcc/testsuite/g++.dg/cpp0x/ref-qual10.C b/gcc/testsuite/g++.dg/cpp0x/ref-qual10.C
new file mode 100644
index 0000000..1b6c54f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/ref-qual10.C
@@ -0,0 +1,13 @@ 
+// PR c++/57252
+// { dg-require-effective-target c++11 }
+
+struct foo {
+  void bar() & {}
+  void bar() && {}
+};
+
+int main()
+{
+  auto p = &foo::bar;		// { dg-error "" }
+  (foo{}.*p)();
+}

commit d6cad04704766c07324719463aac32c1ea428659
Author: Jason Merrill <jason@redhat.com>
Date:   Mon May 13 10:54:47 2013 -0400

    	PR c++/57253
    	* decl.c (grokdeclarator): Apply ref-qualifier
    	in the TYPENAME case.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index faa2911..3854135 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -10284,7 +10284,7 @@  grokdeclarator (const cp_declarator *declarator,
 	      type = void_type_node;
 	    }
 	}
-      else if (memfn_quals)
+      else if (memfn_quals || rqual)
 	{
 	  if (ctype == NULL_TREE
 	      && TREE_CODE (type) == METHOD_TYPE)
diff --git a/gcc/testsuite/g++.dg/cpp0x/ref-qual11.C b/gcc/testsuite/g++.dg/cpp0x/ref-qual11.C
new file mode 100644
index 0000000..15dd049
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/ref-qual11.C
@@ -0,0 +1,10 @@ 
+// PR c++/57253
+// { dg-require-effective-target c++11 }
+
+template<typename T> struct foo;
+
+template<> struct foo<void()&> {};
+template<> struct foo<void()> {};
+
+int main()
+{}

commit 1f114e1a2911396b76dfecda214e132e10b41816
Author: Jason Merrill <jason@redhat.com>
Date:   Mon May 13 11:26:25 2013 -0400

    	PR c++/57254
    	* typeck.c (merge_types): Propagate ref-qualifier
    	in METHOD_TYPE case.

diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index b8ea555..fb75847 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -851,6 +851,7 @@  merge_types (tree t1, tree t2)
 	tree raises = merge_exception_specifiers (TYPE_RAISES_EXCEPTIONS (t1),
 						  TYPE_RAISES_EXCEPTIONS (t2),
 						  NULL_TREE);
+	cp_ref_qualifier rqual = type_memfn_rqual (t1);
 	tree t3;
 
 	/* If this was a member function type, get back to the
@@ -864,6 +865,7 @@  merge_types (tree t1, tree t2)
 	t3 = build_method_type_directly (basetype, TREE_TYPE (t3),
 					 TYPE_ARG_TYPES (t3));
 	t1 = build_exception_variant (t3, raises);
+	t1 = build_ref_qualified_type (t1, rqual);
 	break;
       }
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/ref-qual12.C b/gcc/testsuite/g++.dg/cpp0x/ref-qual12.C
new file mode 100644
index 0000000..b0a16fe
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/ref-qual12.C
@@ -0,0 +1,22 @@ 
+// PR c++/57254
+// { dg-require-effective-target c++11 }
+
+struct foo {
+    template<typename T>
+    void bar(T) &;
+
+    template<typename T>
+    void bar(T) &&;
+};
+
+template<typename T>
+void foo::bar(T) & {}
+
+template<typename T>
+void foo::bar(T) && {}
+
+int main()
+{
+  foo f;
+  f.bar(0);
+}