aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2005-06-03 23:22:11 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2005-06-03 23:22:11 +0000
commitdad732fa41f3ef745ee9dfcde49e6c5387dcef30 (patch)
treecbb4dbf657f7f2f79c7655d6fa4b1a75bd1b7424 /gcc
parentd0b73789d3ac99ccabc5d6d58e4f0b056f0a2a2c (diff)
downloadgcc-dad732fa41f3ef745ee9dfcde49e6c5387dcef30.zip
gcc-dad732fa41f3ef745ee9dfcde49e6c5387dcef30.tar.gz
gcc-dad732fa41f3ef745ee9dfcde49e6c5387dcef30.tar.bz2
re PR c++/21853 (constness of pointer to data member ignored)
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: r100560
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/typeck.c22
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/expr/static_cast6.C15
4 files changed, 36 insertions, 10 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 28dc483..1f8b270 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +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.
+
PR c++/21336
* cp-tree.h (grok_op_properties): Remove friendp parameter.
* decl.c (grokfndecl): Adjust call.
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 73bb514..624f145 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -6466,11 +6466,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:
@@ -6488,9 +6483,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));
@@ -6501,8 +6495,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);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3142634..fb02e49 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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 Diego Novillo <dnovillo@redhat.com>
* gcc.dg/tree-ssa/vrp14.c: New test.
diff --git a/gcc/testsuite/g++.dg/expr/static_cast6.C b/gcc/testsuite/g++.dg/expr/static_cast6.C
new file mode 100644
index 0000000..90f32f1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/expr/static_cast6.C
@@ -0,0 +1,15 @@
+// PR c++/21853
+
+struct blah {
+ int a;
+};
+
+int main( int argc, char ** argv ) {
+ int blah::* ptdma = &blah::a;
+
+ const void *ptdmv = static_cast< void * >( &ptdma );
+
+ int blah::* const ptdmb = * static_cast< int blah::* const * >( ptdmv );
+
+ return 0;
+}