diff options
author | mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-10-22 17:50:28 +0000 |
---|---|---|
committer | mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-10-22 17:50:28 +0000 |
commit | 4944c3db4b60e66e99f07fc963d760a53213eab7 (patch) | |
tree | 89e20837c19fa153a271e7fc610c95f367d0b8ba /gcc/cp/typeck.c | |
parent | e2d342dffa63aea98643515fd3b8c782ee8bd15e (diff) | |
download | ppe42-gcc-4944c3db4b60e66e99f07fc963d760a53213eab7.tar.gz ppe42-gcc-4944c3db4b60e66e99f07fc963d760a53213eab7.zip |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37006 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/typeck.c')
-rw-r--r-- | gcc/cp/typeck.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index d72d8e6c00d..db7374ba4c2 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -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); |