aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2006-03-29 21:55:34 +0000
committerRoger Sayle <sayle@gcc.gnu.org>2006-03-29 21:55:34 +0000
commit0a931ce5d4c3764db08c5eff8400725525b10c0a (patch)
tree18115d4fa6067f3978ea8494f5cb4225fd5f12cb
parent9b71c701c6eb4e62c08ddeae78103259282b9179 (diff)
downloadgcc-0a931ce5d4c3764db08c5eff8400725525b10c0a.zip
gcc-0a931ce5d4c3764db08c5eff8400725525b10c0a.tar.gz
gcc-0a931ce5d4c3764db08c5eff8400725525b10c0a.tar.bz2
convert.c (convert_to_pointer): Preserve the TREE_OVERFLOW and TREE_CONSTANT_OVERFLOW bits of the argument.
* convert.c (convert_to_pointer): Preserve the TREE_OVERFLOW and TREE_CONSTANT_OVERFLOW bits of the argument. Return quickly if the argument is already of the correct type. Call fold_build1 instead of build1. Tidy up blank lines. From-SVN: r112511
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/convert.c15
2 files changed, 19 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8a29a79..b028b30 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2006-03-29 Roger Sayle <roger@eyesopen.com>
+
+ * convert.c (convert_to_pointer): Preserve the TREE_OVERFLOW
+ and TREE_CONSTANT_OVERFLOW bits of the argument. Return
+ quickly if the argument is already of the correct type.
+ Call fold_build1 instead of build1. Tidy up blank lines.
+
2006-03-29 David Edelsohn <edelsohn@gnu.org>
* genemit.c (main): Add tm-constrs.h to included headers.
diff --git a/gcc/convert.c b/gcc/convert.c
index ba5f6fd..9797704 100644
--- a/gcc/convert.c
+++ b/gcc/convert.c
@@ -33,22 +33,31 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
#include "toplev.h"
#include "langhooks.h"
#include "real.h"
-/* Convert EXPR to some pointer or reference type TYPE.
+/* Convert EXPR to some pointer or reference type TYPE.
EXPR must be pointer, reference, integer, enumeral, or literal zero;
in other cases error is called. */
tree
convert_to_pointer (tree type, tree expr)
{
+ if (TREE_TYPE (expr) == type)
+ return expr;
+
if (integer_zerop (expr))
- return build_int_cst (type, 0);
+ {
+ tree t = build_int_cst (type, 0);
+ if (TREE_OVERFLOW (expr) || TREE_CONSTANT_OVERFLOW (expr))
+ t = force_fit_type (t, 0, TREE_OVERFLOW (expr),
+ TREE_CONSTANT_OVERFLOW (expr));
+ return t;
+ }
switch (TREE_CODE (TREE_TYPE (expr)))
{
case POINTER_TYPE:
case REFERENCE_TYPE:
- return build1 (NOP_EXPR, type, expr);
+ return fold_build1 (NOP_EXPR, type, expr);
case INTEGER_TYPE:
case ENUMERAL_TYPE: