From a150de295117d1e8f76a01180541eff7d0eb380c Mon Sep 17 00:00:00 2001
From: Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
Date: Thu, 1 Apr 2004 13:41:37 +0000
Subject: [PATCH] expr.c (get_inner_reference): Use DECL_UNSIGNED, not
 TREE_UNSIGNED.

	* expr.c (get_inner_reference): Use DECL_UNSIGNED, not TREE_UNSIGNED.
	* stor-layout.c (layout_decl): Likewise.
	* tree.c (get_narrower): Likewise and also use BIT_FIELD_REF_UNSIGNED.
	* fold-const.c (make_bit_field_ref): Use BIT_FIELD_REF_UNSIGNED.
	* print-tree.c (print_node): Handle various used of unsigned_flag.
	* tree.def (BIT_FIELD_REF): Update comment.
	* tree.h (TREE_UNSIGNED): Deleted.
	(DECL_UNSIGNED, BIT_FIELD_REF_UNSIGNED): New macros.

	* cp/class.c (VTT_TOP_LEVEL_P): Use unsigned_flag directly.

	* f/com.c (ffe_truthvalue_conversion, case COMPONENT_REF):
	Use DECL_UNSIGNED and integer_onep.

From-SVN: r80293
---
 gcc/ChangeLog     | 11 +++++++++++
 gcc/cp/ChangeLog  |  4 ++++
 gcc/cp/class.c    |  2 +-
 gcc/expr.c        |  4 ++--
 gcc/f/ChangeLog   |  5 +++++
 gcc/f/com.c       |  4 ++--
 gcc/fold-const.c  |  2 +-
 gcc/print-tree.c  | 11 +++++++++--
 gcc/stor-layout.c |  2 +-
 gcc/tree.c        |  8 ++++----
 gcc/tree.def      |  2 +-
 gcc/tree.h        | 15 ++++++++++-----
 12 files changed, 51 insertions(+), 19 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c35a9cf1625f..a1fffe747d44 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2004-04-01  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
+
+	* expr.c (get_inner_reference): Use DECL_UNSIGNED, not TREE_UNSIGNED.
+	* stor-layout.c (layout_decl): Likewise.
+	* tree.c (get_narrower): Likewise and also use BIT_FIELD_REF_UNSIGNED.
+	* fold-const.c (make_bit_field_ref): Use BIT_FIELD_REF_UNSIGNED.
+	* print-tree.c (print_node): Handle various used of unsigned_flag.
+	* tree.def (BIT_FIELD_REF): Update comment.
+	* tree.h (TREE_UNSIGNED): Deleted.
+	(DECL_UNSIGNED, BIT_FIELD_REF_UNSIGNED): New macros.
+
 2004-03-31  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
 
 	* builtins.c, c-aux-info.c, c-common.c, c-cppbuiltin.c, c-decl.c:
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 077fcef09854..4a6f648f3149 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,7 @@
+2004-04-01  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
+
+	* class.c (VTT_TOP_LEVEL_P): Use unsigned_flag directly.
+
 2004-03-31  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
 
 	* call.c (joust): Use TYPE_UNSIGNED, not TREE_UNSIGNED.
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index fe49e267eae5..6188f5e1cbf3 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -213,7 +213,7 @@ static tree get_vcall_index (tree, tree);
 /* Macros for dfs walking during vtt construction. See
    dfs_ctor_vtable_bases_queue_p, dfs_build_secondary_vptr_vtt_inits
    and dfs_fixup_binfo_vtbls.  */
-#define VTT_TOP_LEVEL_P(NODE) TREE_UNSIGNED (NODE)
+#define VTT_TOP_LEVEL_P(NODE) (TREE_LIST_CHECK (NODE)->common.unsigned_flag)
 #define VTT_MARKED_BINFO_P(NODE) TREE_USED (NODE)
 
 /* Variables shared between class.c and call.c.  */
diff --git a/gcc/expr.c b/gcc/expr.c
index 3365aef2e10b..f884ad977472 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -5440,12 +5440,12 @@ get_inner_reference (tree exp, HOST_WIDE_INT *pbitsize,
       if (! DECL_BIT_FIELD (TREE_OPERAND (exp, 1)))
 	mode = DECL_MODE (TREE_OPERAND (exp, 1));
 
-      *punsignedp = TREE_UNSIGNED (TREE_OPERAND (exp, 1));
+      *punsignedp = DECL_UNSIGNED (TREE_OPERAND (exp, 1));
     }
   else if (TREE_CODE (exp) == BIT_FIELD_REF)
     {
       size_tree = TREE_OPERAND (exp, 1);
-      *punsignedp = TREE_UNSIGNED (exp);
+      *punsignedp = BIT_FIELD_REF_UNSIGNED (exp);
     }
   else
     {
diff --git a/gcc/f/ChangeLog b/gcc/f/ChangeLog
index f81e5a383671..be92b2974772 100644
--- a/gcc/f/ChangeLog
+++ b/gcc/f/ChangeLog
@@ -1,3 +1,8 @@
+2004-04-01  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
+
+	* com.c (ffe_truthvalue_conversion, case COMPONENT_REF):
+	Use DECL_UNSIGNED and integer_onep.
+
 2004-03-31  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
 
 	* com.c (ffecom_arrayref_): Use TYPE_UNSIGNED, not TREE_UNSIGNED.
diff --git a/gcc/f/com.c b/gcc/f/com.c
index 178326b0ea8f..ab6fc1b35975 100644
--- a/gcc/f/com.c
+++ b/gcc/f/com.c
@@ -14754,8 +14754,8 @@ ffe_truthvalue_conversion (tree expr)
 #if 0
     case COMPONENT_REF:
       /* A one-bit unsigned bit-field is already acceptable.  */
-      if (1 == TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (expr, 1)))
-	  && TREE_UNSIGNED (TREE_OPERAND (expr, 1)))
+      if (integer_onep (DECL_SIZE (TREE_OPERAND (expr, 1)))
+	  && DECL_UNSIGNED (TREE_OPERAND (expr, 1)))
 	return expr;
       break;
 #endif
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 78fb2789d87a..51e986abf38a 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -2814,7 +2814,7 @@ make_bit_field_ref (tree inner, tree type, int bitsize, int bitpos,
   tree result = build (BIT_FIELD_REF, type, inner,
 		       size_int (bitsize), bitsize_int (bitpos));
 
-  TREE_UNSIGNED (result) = unsignedp;
+  BIT_FIELD_REF_UNSIGNED (result) = unsignedp;
 
   return result;
 }
diff --git a/gcc/print-tree.c b/gcc/print-tree.c
index 14a70218fc61..2fe09967d748 100644
--- a/gcc/print-tree.c
+++ b/gcc/print-tree.c
@@ -255,8 +255,6 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
     fputs (" addressable", file);
   if (TREE_THIS_VOLATILE (node))
     fputs (" volatile", file);
-  if (TREE_UNSIGNED (node))
-    fputs (" unsigned", file);
   if (TREE_ASM_WRITTEN (node))
     fputs (" asm_written", file);
   if (TREE_USED (node))
@@ -295,6 +293,8 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
     case 'd':
       mode = DECL_MODE (node);
 
+      if (DECL_UNSIGNED (node))
+	fputs (" unsigned", file);
       if (DECL_IGNORED_P (node))
 	fputs (" ignored", file);
       if (DECL_ABSTRACT (node))
@@ -455,6 +455,9 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
       break;
 
     case 't':
+      if (TYPE_UNSIGNED (node))
+	fputs (" unsigned", file);
+
       /* The no-force-blk flag is used for different things in
 	 different types.  */
       if ((TREE_CODE (node) == RECORD_TYPE
@@ -576,6 +579,10 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
     case '2':
     case 'r':
     case 's':
+      if (TREE_CODE (node) == BIT_FIELD_REF && BIT_FIELD_REF_UNSIGNED (node))
+	fputs (" unsigned", file);
+      else if (TREE_CODE (node) == SAVE_EXPR && SAVE_EXPR_NOPLACEHOLDER (node))
+	fputs (" noplaceholder", file);
       if (TREE_CODE (node) == BIND_EXPR)
 	{
 	  print_node (file, "vars", TREE_OPERAND (node, 0), indent + 4);
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index 340608fc1ddb..2baa36432a4d 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -364,7 +364,7 @@ layout_decl (tree decl, unsigned int known_align)
      size in bytes from the size in bits.  If we have already set the mode,
      don't set it again since we can be called twice for FIELD_DECLs.  */
 
-  TREE_UNSIGNED (decl) = TYPE_UNSIGNED (type);
+  DECL_UNSIGNED (decl) = TYPE_UNSIGNED (type);
   if (DECL_MODE (decl) == VOIDmode)
     DECL_MODE (decl) = TYPE_MODE (type);
 
diff --git a/gcc/tree.c b/gcc/tree.c
index be153225cf0e..7d5e6d5b600d 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -4415,7 +4415,7 @@ get_unwidened (tree op, tree for_type)
     {
       unsigned int innerprec
 	= tree_low_cst (DECL_SIZE (TREE_OPERAND (op, 1)), 1);
-      int unsignedp = (TREE_UNSIGNED (TREE_OPERAND (op, 1))
+      int unsignedp = (DECL_UNSIGNED (TREE_OPERAND (op, 1))
 		       || TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op, 1))));
       type = lang_hooks.types.type_for_size (innerprec, unsignedp);
 
@@ -4500,7 +4500,7 @@ get_narrower (tree op, int *unsignedp_ptr)
     {
       unsigned HOST_WIDE_INT innerprec
 	= tree_low_cst (DECL_SIZE (TREE_OPERAND (op, 1)), 1);
-      int unsignedp = (TREE_UNSIGNED (TREE_OPERAND (op, 1))
+      int unsignedp = (DECL_UNSIGNED (TREE_OPERAND (op, 1))
 		       || TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op, 1))));
       tree type = lang_hooks.types.type_for_size (innerprec, unsignedp);
 
@@ -4514,11 +4514,11 @@ get_narrower (tree op, int *unsignedp_ptr)
 
       if (innerprec < TYPE_PRECISION (TREE_TYPE (op))
 	  && ! DECL_BIT_FIELD (TREE_OPERAND (op, 1))
-	  && (first || uns == TREE_UNSIGNED (TREE_OPERAND (op, 1)))
+	  && (first || uns == DECL_UNSIGNED (TREE_OPERAND (op, 1)))
 	  && type != 0)
 	{
 	  if (first)
-	    uns = TREE_UNSIGNED (TREE_OPERAND (op, 1));
+	    uns = DECL_UNSIGNED (TREE_OPERAND (op, 1));
 	  win = build (COMPONENT_REF, type, TREE_OPERAND (op, 0),
 		       TREE_OPERAND (op, 1));
 	  TREE_SIDE_EFFECTS (win) = TREE_SIDE_EFFECTS (op);
diff --git a/gcc/tree.def b/gcc/tree.def
index afdeadcd1546..c8e5398d5752 100644
--- a/gcc/tree.def
+++ b/gcc/tree.def
@@ -365,7 +365,7 @@ DEFTREECODE (COMPONENT_REF, "component_ref", 'r', 2)
    operand 1 is a tree giving the number of bits being referenced;
    operand 2 is a tree giving the position of the first referenced bit.
    The field can be either a signed or unsigned field;
-   TREE_UNSIGNED says which.  */
+   BIT_FIELD_REF_UNSIGNED says which.  */
 DEFTREECODE (BIT_FIELD_REF, "bit_field_ref", 'r', 3)
    
 /* C unary `*' or Pascal `^'.  One operand, an expression for a pointer.  */
diff --git a/gcc/tree.h b/gcc/tree.h
index d57e4abf4106..c2138dc44fc8 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -264,8 +264,10 @@ struct tree_common GTY(())
 
        TYPE_UNSIGNED in
            all types
-       TREE_UNSIGNED in
-           FIELD_DECL
+       DECL_UNSIGNED in
+           all decls
+       BIT_FIELD_REF_UNSIGNED in
+           BIT_FIELD_REF
        SAVE_EXPR_NOPLACEHOLDER in
 	   SAVE_EXPR
 
@@ -710,9 +712,12 @@ extern void tree_operand_check_failed (int, enum tree_code,
    if the value is constant.  */
 #define TREE_CONSTANT(NODE) ((NODE)->common.constant_flag)
 
-/* In INTEGER_TYPE or ENUMERAL_TYPE nodes, means an unsigned type.
-   In FIELD_DECL nodes, means an unsigned bit field.  */
-#define TREE_UNSIGNED(NODE) ((NODE)->common.unsigned_flag)
+/* In a decl (most significantly a FIELD_DECL), means an unsigned field.  */
+#define DECL_UNSIGNED(NODE) (DECL_CHECK (NODE)->common.unsigned_flag)
+
+/* In a BIT_FIELD_REF, means the bitfield is to be interpreted as unsigned.  */
+#define BIT_FIELD_REF_UNSIGNED(NODE) \
+  (BIT_FIELD_REF_CHECK (NODE)->common.unsigned_flag)
 
 /* In integral and pointer types, means an unsigned type.  */
 #define TYPE_UNSIGNED(NODE) (TYPE_CHECK (NODE)->common.unsigned_flag)
-- 
GitLab