]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/21853 (constness of pointer to data member ignored)
authorMark Mitchell <mark@codesourcery.com>
Fri, 3 Jun 2005 23:24:54 +0000 (23:24 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Fri, 3 Jun 2005 23:24:54 +0000 (23:24 +0000)
PR c++/21853
* typeck.c (casts_away_constness_r): Do not drop cv-qualifiers on
the pointed-to type for a pointer-to-member.

PR c++/21853
* g++.dg/expr/static_cast6.C: New test.

From-SVN: r100564

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog

index 74f3b1b80f43af7e3a1ccc6c7d5dd35dad7f805c..bd8c19605487dbc91634260e8f6510b77323fa4d 100644 (file)
@@ -1,3 +1,9 @@
+2005-06-03  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/21853
+       * typeck.c (casts_away_constness_r): Do not drop cv-qualifiers on
+       the pointed-to type for a pointer-to-member.
+
 2005-06-03  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/21336
index 0c9c6c4630b1feb2a0e3963e5c862dc629877e49..7f6e8b869ef07d936925d9f0cfd687b57c01425b 100644 (file)
@@ -6314,11 +6314,6 @@ casts_away_constness_r (tree *t1, tree *t2)
      and pointers to members (conv.qual), the "member" aspect of a
      pointer to member level is ignored when determining if a const
      cv-qualifier has been cast away.  */
-  if (TYPE_PTRMEM_P (*t1))
-    *t1 = build_pointer_type (TYPE_PTRMEM_POINTED_TO_TYPE (*t1));
-  if (TYPE_PTRMEM_P (*t2))
-    *t2 = build_pointer_type (TYPE_PTRMEM_POINTED_TO_TYPE (*t2));
-
   /* [expr.const.cast]
 
      For  two  pointer types:
@@ -6336,9 +6331,8 @@ casts_away_constness_r (tree *t1, tree *t2)
      to
 
             Tcv2,(M-K+1) * cv2,(M-K+2) * ... cv2,M *.  */
-
-  if (TREE_CODE (*t1) != POINTER_TYPE
-      || TREE_CODE (*t2) != POINTER_TYPE)
+  if ((!TYPE_PTR_P (*t1) && !TYPE_PTRMEM_P (*t1))
+      || (!TYPE_PTR_P (*t2) && !TYPE_PTRMEM_P (*t2)))
     {
       *t1 = cp_build_qualified_type (void_type_node,
                                     cp_type_quals (*t1));
@@ -6349,8 +6343,16 @@ casts_away_constness_r (tree *t1, tree *t2)
   
   quals1 = cp_type_quals (*t1);
   quals2 = cp_type_quals (*t2);
-  *t1 = TREE_TYPE (*t1);
-  *t2 = TREE_TYPE (*t2);
+
+  if (TYPE_PTRMEM_P (*t1))
+    *t1 = TYPE_PTRMEM_POINTED_TO_TYPE (*t1);
+  else
+    *t1 = TREE_TYPE (*t1);
+  if (TYPE_PTRMEM_P (*t2))
+    *t2 = TYPE_PTRMEM_POINTED_TO_TYPE (*t2);
+  else
+    *t2 = TREE_TYPE (*t2);
+
   casts_away_constness_r (t1, t2);
   *t1 = build_pointer_type (*t1);
   *t2 = build_pointer_type (*t2);
index 3b74f891fe8dd3f3301c0dfae67a97090dc18dc9..ac6e72a4925bbcdfefaf033466e953e58b92c6c5 100644 (file)
@@ -1,3 +1,8 @@
+2005-06-03  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/21853
+       * g++.dg/expr/static_cast6.C: New test.
+
 2005-06-03  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/21336