aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2002-07-05 18:10:25 -0400
committerJason Merrill <jason@gcc.gnu.org>2002-07-05 18:10:25 -0400
commit212e17fd89735946ac3640225958d50bc4392979 (patch)
treeac4b30d81da4adf9bfc374acdf196a98ed90ac90 /gcc
parent4c8aed1419361e544f919f2455308da2bc6d04f4 (diff)
downloadgcc-212e17fd89735946ac3640225958d50bc4392979.zip
gcc-212e17fd89735946ac3640225958d50bc4392979.tar.gz
gcc-212e17fd89735946ac3640225958d50bc4392979.tar.bz2
cvt.c (cp_convert_to_pointer): Call force_fit_type for null pointers.
* cvt.c (cp_convert_to_pointer): Call force_fit_type for null pointers. From-SVN: r55272
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/cvt.c2
-rw-r--r--gcc/testsuite/g++.dg/other/ptrmem3.C14
3 files changed, 19 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index ab5c144..1c4b06d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
2002-07-05 Jason Merrill <jason@redhat.com>
+ * cvt.c (cp_convert_to_pointer): Call force_fit_type for null
+ pointers.
+
PR optimization/7145
* tree.c (cp_copy_res_decl_for_inlining): Also copy DECL_INITIAL.
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c
index 0c43fc3..bd42b42 100644
--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -252,6 +252,8 @@ cp_convert_to_pointer (type, expr, force)
else
expr = build_int_2 (0, 0);
TREE_TYPE (expr) = type;
+ /* Fix up the representation of -1 if appropriate. */
+ force_fit_type (expr, 0);
return expr;
}
diff --git a/gcc/testsuite/g++.dg/other/ptrmem3.C b/gcc/testsuite/g++.dg/other/ptrmem3.C
new file mode 100644
index 0000000..ed6d875
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/ptrmem3.C
@@ -0,0 +1,14 @@
+// Bug: The double cast had an TREE_INT_CST_HIGH of 0, while the single
+// cast had -1, so the comparison failed.
+
+// { dg-do run }
+
+struct A { };
+
+typedef int A::* aip;
+typedef long A::* alp;
+
+int main()
+{
+ return ((aip)(alp)0 != (aip)0);
+}