call.c (standard_conversion): Tweak handling of pointer-to-member types.
authorMark Mitchell <mark@codesourcery.com>
Sun, 27 Jul 2003 18:25:57 +0000 (18:25 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Sun, 27 Jul 2003 18:25:57 +0000 (18:25 +0000)
* call.c (standard_conversion): Tweak handling of
pointer-to-member types.
* pt.c (tsubst): Correctly qualify pointers-to-data member types.
* typeck.c (comp_ptr_ttypes_real): Check qualifiers on
pointer-to-data member types.

* g++.dg/template/ptrmem6.C: New test.

From-SVN: r69855

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/pt.c
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/ptrmem6.C [new file with mode: 0644]

index ad86f1aa5e02f7ba0fc61977917362c15b062e05..209e1adce9e8ba09fe63afbadcee20eef011cde9 100644 (file)
@@ -1,3 +1,11 @@
+2003-07-27  Mark Mitchell  <mark@codesourcery.com>
+
+       * call.c (standard_conversion): Tweak handling of
+       pointer-to-member types.
+       * pt.c (tsubst): Correctly qualify pointers-to-data member types.
+       * typeck.c (comp_ptr_ttypes_real): Check qualifiers on
+       pointer-to-data member types.
+
 2003-07-27  Nathan Sidwell  <nathan@codesourcery.com>
 
        * parser.c (cp_parser_type_parameter): Reformat.
index 58888eacf521aab579f285ba46649ef61eb11281..7e3302fa0f7d02e0097947b3a0ba6812669d621f 100644 (file)
@@ -715,8 +715,8 @@ standard_conversion (tree to, tree from, tree expr)
        }
       else
        {
-         to_pointee = to;
-         from_pointee = from;
+         to_pointee = TYPE_PTRMEM_POINTED_TO_TYPE (to);
+         from_pointee = TYPE_PTRMEM_POINTED_TO_TYPE (from);
        }
 
       if (same_type_p (from, to))
index 66703723178712220d222ece30d76bf20db60f63..efbf75abb694571a64918f188b34f41ae9571d6b 100644 (file)
@@ -6827,7 +6827,9 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
            return build_ptrmemfunc_type (build_pointer_type (method_type));
          }
        else
-         return build_ptrmem_type (r, type);
+         return cp_build_qualified_type_real (build_ptrmem_type (r, type),
+                                              TYPE_QUALS (t),
+                                              complain);
       }
     case FUNCTION_TYPE:
     case METHOD_TYPE:
index faa71975f5a4c9087c0c1dbffcf9964fe2297e88..ec6765b28b06e67067c2294ea040d6ed23cace32 100644 (file)
@@ -6013,9 +6013,9 @@ comp_ptr_ttypes_real (tree to, tree from, int constp)
        return 0;
 
       if (TREE_CODE (from) == OFFSET_TYPE
-         && same_type_p (TYPE_OFFSET_BASETYPE (from),
-                         TYPE_OFFSET_BASETYPE (to)))
-         continue;
+         && !same_type_p (TYPE_OFFSET_BASETYPE (from),
+                          TYPE_OFFSET_BASETYPE (to)))
+       return 0;
 
       /* Const and volatile mean something different for function types,
         so the usual checks are not appropriate.  */
@@ -6035,7 +6035,7 @@ comp_ptr_ttypes_real (tree to, tree from, int constp)
            constp &= TYPE_READONLY (to);
        }
 
-      if (TREE_CODE (to) != POINTER_TYPE)
+      if (TREE_CODE (to) != POINTER_TYPE && !TYPE_PTR_TO_MEMBER_P (to))
        return ((constp >= 0 || to_more_cv_qualified)
                && same_type_ignoring_top_level_qualifiers_p (to, from));
     }
index c06df55a540dca31afd8d5b83494a21575067a7a..1057be5c667d65759c11a65ecfed543128550f93 100644 (file)
@@ -1,3 +1,7 @@
+2003-07-27  Mark Mitchell  <mark@codesourcery.com>
+
+       * g++.dg/template/ptrmem6.C: New test.
+
 2003-07-26  Geoffrey Keating  <geoffk@apple.com>
 
        * gcc.c-torture/compile/zero-strct-2.c: New test.
diff --git a/gcc/testsuite/g++.dg/template/ptrmem6.C b/gcc/testsuite/g++.dg/template/ptrmem6.C
new file mode 100644 (file)
index 0000000..0d7dec2
--- /dev/null
@@ -0,0 +1,10 @@
+struct S {};
+
+void g(int S::**);
+
+template <typename T>
+void f (int T::* volatile *p) {
+  g(p); // { dg-error "" }
+}
+
+template void f(int S::* volatile *); // { dg-error "instantiated" }