Commit 5c28da24 by Richard Stallman

(finish_enum): Always make an enum signed if it will fit.

From-SVN: r5996
parent e5884dac
...@@ -5566,8 +5566,12 @@ finish_enum (enumtype, values) ...@@ -5566,8 +5566,12 @@ finish_enum (enumtype, values)
TYPE_SIZE (enumtype) = 0; TYPE_SIZE (enumtype) = 0;
layout_type (enumtype); layout_type (enumtype);
/* An enum can have some negative values; then it is signed. */ /* If an enum has no negative values, and it goes beyond the range
TREE_UNSIGNED (enumtype) = ! tree_int_cst_lt (minnode, integer_zero_node); of the signed integral type, make it unsigned. */
TREE_UNSIGNED (enumtype)
= (! tree_int_cst_lt (minnode, integer_zero_node)
&& ! tree_int_cst_lt (maxnode,
TYPE_MAX_VALUE (type_for_size (precision, 0))));
/* Change the type of the enumerators to be the enum type. /* Change the type of the enumerators to be the enum type.
Formerly this was done only for enums that fit in an int, Formerly this was done only for enums that fit in an int,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment