tree.h (TYPE_IS_SIZETYPE): Add more documentation.
authorMark Mitchell <mark@codesourcery.com>
Sun, 22 Oct 2000 17:50:28 +0000 (17:50 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Sun, 22 Oct 2000 17:50:28 +0000 (17:50 +0000)
* tree.h (TYPE_IS_SIZETYPE): Add more documentation.

* typeck.c (c_sizeof): Return an expression of `size_t' type,
not one with TYPE_IS_SIZETYPE set.
(dubious_conversion_warnings): Remove special-case code.

From-SVN: r37006

gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/tree.h

index 16363cc793091c1eff0ff34dbd4ce9d3982f707c..af93e0b22c2eefb3e6255ed2d45e93eee7a1968f 100644 (file)
@@ -1,3 +1,7 @@
+2000-10-22  Mark Mitchell  <mark@codesourcery.com>
+
+       * tree.h (TYPE_IS_SIZETYPE): Add more documentation.
+
 2000-10-21  Joseph S. Myers  <jsm28@cam.ac.uk>
 
        * diagnostic.c: Remove EGCS reference in comment.
index 9cd863019d5b6f5aeed37c0800b6b29214b47f13..23660c3486bd4c743f0d6b306a83be427f7b4dce 100644 (file)
@@ -1,3 +1,9 @@
+2000-10-22  Mark Mitchell  <mark@codesourcery.com>
+
+       * typeck.c (c_sizeof): Return an expression of `size_t' type, 
+       not one with TYPE_IS_SIZETYPE set.
+       (dubious_conversion_warnings): Remove special-case code.
+
 2000-10-21  Geoffrey Keating  <geoffk@cygnus.com>
 
        * decl2.c (arg_assoc_type): Handle VECTOR_TYPE.
index d72d8e6c00df65ce0eb7844c6978beb4da683455..db7374ba4c2858b71ba6301fab4d735d072ea132 100644 (file)
@@ -1548,6 +1548,7 @@ c_sizeof (type)
      tree type;
 {
   enum tree_code code = TREE_CODE (type);
+  tree size;
 
   if (processing_template_decl)
     return build_min (SIZEOF_EXPR, sizetype, type);
@@ -1591,11 +1592,20 @@ c_sizeof (type)
     }
 
   /* Convert in case a char is more than one unit.  */
-  return size_binop (CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type),
+  size = size_binop (CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type),
                     size_int (TYPE_PRECISION (char_type_node)
                               / BITS_PER_UNIT));
+  /* SIZE will have an integer type with TYPE_IS_SIZETYPE set.
+     TYPE_IS_SIZETYPE means that certain things (like overflow) will
+     never happen.  However, this node should really have type
+     `size_t', which is just a typedef for an ordinary integer type.  */
+  size = fold (build1 (NOP_EXPR, c_size_type_node, size));
+  my_friendly_assert (!TYPE_IS_SIZETYPE (TREE_TYPE (size)), 
+                     20001021);
+  return size;
 }
 
+
 tree
 expr_sizeof (e)
      tree e;
@@ -6354,14 +6364,7 @@ dubious_conversion_warnings (type, expr, errtype, fndecl, parmnum)
                        errtype, expr, type);
        }
 
-      /* Suppress warning for a sizetype since we never used to issue it.
-        ??? This needs to be looked at more carefully someday.  */
-      if (TREE_CODE (expr) == INTEGER_CST
-         && TREE_CODE (TREE_TYPE (expr)) == INTEGER_TYPE
-         && TYPE_IS_SIZETYPE (TREE_TYPE (expr)))
-       TREE_OVERFLOW (expr) = TREE_CONSTANT_OVERFLOW (expr) = 0;
-      else
-       overflow_warning (expr);
+      overflow_warning (expr);
 
       if (TREE_CONSTANT (expr))
        expr = fold (expr);
index d8cc50872d7efb1fd8df4d6b7dc51e806291f0a8..9551c8f0a31c6caecd3a08dd8bd15620c1ff65dc 100644 (file)
@@ -949,9 +949,14 @@ struct tree_block
    its size.  */
 #define TYPE_NO_FORCE_BLK(NODE) (TYPE_CHECK (NODE)->type.no_force_blk_flag)
 
-/* In an INTEGER_TYPE, it means the type represents a size.  We use this
-   both for validity checking and to permit optimziations that are unsafe
-   for other types.  */
+/* In an INTEGER_TYPE, it means the type represents a size.  We use
+   this both for validity checking and to permit optimizations that
+   are unsafe for other types.  Note that the C `size_t' type should
+   *not* have this flag set.  The `size_t' type is simply a typedef
+   for an ordinary integer type that happens to be the type of an
+   expression returned by `sizeof'; `size_t' has no special
+   properties.  Expressions whose type have TYPE_IS_SIZETYPE set are
+   always actual sizes.  */
 #define TYPE_IS_SIZETYPE(NODE) \
   (INTEGER_TYPE_CHECK (NODE)->type.no_force_blk_flag)