From 26f86471531d569c550a3e16fbd88a0cae6f18dd Mon Sep 17 00:00:00 2001
From: Mark Mitchell <mark@codesourcery.com>
Date: Thu, 13 Mar 2003 19:57:12 +0000
Subject: [PATCH] call.c (initialize_reference): Remove bogus assertion.

	* call.c (initialize_reference): Remove bogus assertion.
	* decl.c (build_ptrmemfunc_type): Revert change of 2003-03-09.

	* g++.dg/init/ref5.C: New test.
	* g++.dg/parse/ptrmem1.C: Likewise.

From-SVN: r64316
---
 gcc/cp/ChangeLog                     |  5 ++++
 gcc/cp/call.c                        |  3 +--
 gcc/cp/decl.c                        | 38 ----------------------------
 gcc/testsuite/ChangeLog              |  5 ++++
 gcc/testsuite/g++.dg/init/ref5.C     | 12 +++++++++
 gcc/testsuite/g++.dg/parse/ptrmem1.C | 10 ++++++++
 6 files changed, 33 insertions(+), 40 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/init/ref5.C
 create mode 100644 gcc/testsuite/g++.dg/parse/ptrmem1.C

diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 71d753625b8f..da84998cb2ae 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2003-03-13  Mark Mitchell  <mark@codesourcery.com>
+
+	* call.c (initialize_reference): Remove bogus assertion.
+	* decl.c (build_ptrmemfunc_type): Revert change of 2003-03-09.
+
 2003-03-12  Andrew Lewycky  <andrew@mxc.ca>
 
 	PR c++/7050
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index c8baf749588c..d6496ad6a900 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -6088,9 +6088,8 @@ initialize_reference (tree type, tree expr, tree decl)
       conv = TREE_OPERAND (conv, 0);
       /* If the next conversion is a BASE_CONV, skip that too -- but
 	 remember that the conversion was required.  */
-      if (TREE_CODE (conv) == BASE_CONV)
+      if (TREE_CODE (conv) == BASE_CONV && !NEED_TEMPORARY_P (conv))
 	{
-	  my_friendly_assert (!NEED_TEMPORARY_P (conv), 20030307);
 	  base_conv_type = TREE_TYPE (conv);
 	  conv = TREE_OPERAND (conv, 0);
 	}
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index eeae35ad0df2..1763c41aaf50 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -9297,49 +9297,11 @@ build_ptrmemfunc_type (tree type)
 {
   tree field, fields;
   tree t;
-  tree method_type;
-  tree arg_type;
   tree unqualified_variant = NULL_TREE;
 
   if (type == error_mark_node)
     return type;
 
-  /* If the METHOD_TYPE has any default parameters, make a copy that
-     does not have the default parameters.  The pointer-to-member type
-     never has default parameters.  */
-  method_type = TREE_TYPE (type);
-  for (arg_type = TYPE_ARG_TYPES (method_type);
-       arg_type;
-       arg_type = TREE_CHAIN (arg_type))
-    if (TREE_PURPOSE (arg_type))
-      {
-	/* At least one parameter has a default argument.  */
-	tree arg_types = NULL_TREE;
-	tree *arg_type_p = &arg_types;
-
-	/* Copy the parameter types.  The "this" parameter will be
-	   added by build_cplus_method_type.  */
-	for (arg_type = TREE_CHAIN (TYPE_ARG_TYPES (method_type));
-	     arg_type;
-	     arg_type = TREE_CHAIN (arg_type))
-	  {
-	    if (arg_type == void_list_node)
-	      *arg_type_p = void_list_node;
-	    else
-	      *arg_type_p = build_tree_list (NULL_TREE,
-					     TREE_VALUE (arg_type));
-	    arg_type_p = &TREE_CHAIN (*arg_type_p);
-	  }
-	/* Build the new METHOD_TYPE.  */
-	method_type = build_cplus_method_type (TYPE_METHOD_BASETYPE (method_type), 
-					       TREE_TYPE (method_type), 
-					       arg_types);
-	/* Build the new POINTER_TYPE.  */
-	type = cp_build_qualified_type (build_pointer_type (method_type),
-					cp_type_quals (type));
-	break;
-      }
-
   /* If a canonical type already exists for this type, use it.  We use
      this method instead of type_hash_canon, because it only does a
      simple equality check on the list of field members.  */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6492c098c0c1..3407e5ccb5a1 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2003-03-13  Mark Mitchell  <mark@codesourcery.com>
+
+	* g++.dg/init/ref5.C: New test.
+	* g++.dg/parse/ptrmem1.C: Likewise.
+
 2003-03-12  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
 
 	* gcc.dg/special/ecos.exp (gcsec-1.c): Find linker used by gcc.
diff --git a/gcc/testsuite/g++.dg/init/ref5.C b/gcc/testsuite/g++.dg/init/ref5.C
new file mode 100644
index 000000000000..ad1c30c36f86
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/ref5.C
@@ -0,0 +1,12 @@
+struct A { };
+struct B : public A { };
+struct X {
+        operator B();
+};
+X x;
+
+int main()
+{
+  const A& r = x;
+  return 0;
+}
diff --git a/gcc/testsuite/g++.dg/parse/ptrmem1.C b/gcc/testsuite/g++.dg/parse/ptrmem1.C
new file mode 100644
index 000000000000..b1174c7d97b3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/ptrmem1.C
@@ -0,0 +1,10 @@
+struct A {
+  void f(int = 0) const;
+};
+
+typedef void (A::*PF)(int) const;
+
+void f()
+{
+  PF pf = &A::f;
+}
-- 
GitLab