(finish_enum): Handle VALUES being an ERROR_MARK.
From-SVN: r7303
This commit is contained in:
parent
005a35b93f
commit
59116212bf
64
gcc/c-decl.c
64
gcc/c-decl.c
@ -5642,19 +5642,22 @@ finish_enum (enumtype, values)
|
|||||||
|
|
||||||
/* Calculate the maximum value of any enumerator in this type. */
|
/* Calculate the maximum value of any enumerator in this type. */
|
||||||
|
|
||||||
for (pair = values; pair; pair = TREE_CHAIN (pair))
|
if (values == error_mark_node)
|
||||||
{
|
minnode = maxnode = integer_zero_node;
|
||||||
tree value = TREE_VALUE (pair);
|
else
|
||||||
if (pair == values)
|
for (pair = values; pair; pair = TREE_CHAIN (pair))
|
||||||
minnode = maxnode = TREE_VALUE (pair);
|
{
|
||||||
else
|
tree value = TREE_VALUE (pair);
|
||||||
{
|
if (pair == values)
|
||||||
if (tree_int_cst_lt (maxnode, value))
|
minnode = maxnode = TREE_VALUE (pair);
|
||||||
maxnode = value;
|
else
|
||||||
if (tree_int_cst_lt (value, minnode))
|
{
|
||||||
minnode = value;
|
if (tree_int_cst_lt (maxnode, value))
|
||||||
}
|
maxnode = value;
|
||||||
}
|
if (tree_int_cst_lt (value, minnode))
|
||||||
|
minnode = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TYPE_MIN_VALUE (enumtype) = minnode;
|
TYPE_MIN_VALUE (enumtype) = minnode;
|
||||||
TYPE_MAX_VALUE (enumtype) = maxnode;
|
TYPE_MAX_VALUE (enumtype) = maxnode;
|
||||||
@ -5700,25 +5703,28 @@ finish_enum (enumtype, values)
|
|||||||
/* An enum can have some negative values; then it is signed. */
|
/* An enum can have some negative values; then it is signed. */
|
||||||
TREE_UNSIGNED (enumtype) = tree_int_cst_sgn (minnode) >= 0;
|
TREE_UNSIGNED (enumtype) = tree_int_cst_sgn (minnode) >= 0;
|
||||||
|
|
||||||
/* Change the type of the enumerators to be the enum type.
|
if (values != error_mark_node)
|
||||||
Formerly this was done only for enums that fit in an int,
|
|
||||||
but the comment said it was done only for enums wider than int.
|
|
||||||
It seems necessary to do this for wide enums,
|
|
||||||
and best not to change what's done for ordinary narrower ones. */
|
|
||||||
for (pair = values; pair; pair = TREE_CHAIN (pair))
|
|
||||||
{
|
{
|
||||||
TREE_TYPE (TREE_PURPOSE (pair)) = enumtype;
|
/* Change the type of the enumerators to be the enum type.
|
||||||
DECL_SIZE (TREE_PURPOSE (pair)) = TYPE_SIZE (enumtype);
|
Formerly this was done only for enums that fit in an int,
|
||||||
if (TREE_CODE (TREE_PURPOSE (pair)) != FUNCTION_DECL)
|
but the comment said it was done only for enums wider than int.
|
||||||
DECL_ALIGN (TREE_PURPOSE (pair)) = TYPE_ALIGN (enumtype);
|
It seems necessary to do this for wide enums,
|
||||||
|
and best not to change what's done for ordinary narrower ones. */
|
||||||
|
for (pair = values; pair; pair = TREE_CHAIN (pair))
|
||||||
|
{
|
||||||
|
TREE_TYPE (TREE_PURPOSE (pair)) = enumtype;
|
||||||
|
DECL_SIZE (TREE_PURPOSE (pair)) = TYPE_SIZE (enumtype);
|
||||||
|
if (TREE_CODE (TREE_PURPOSE (pair)) != FUNCTION_DECL)
|
||||||
|
DECL_ALIGN (TREE_PURPOSE (pair)) = TYPE_ALIGN (enumtype);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Replace the decl nodes in VALUES with their names. */
|
||||||
|
for (pair = values; pair; pair = TREE_CHAIN (pair))
|
||||||
|
TREE_PURPOSE (pair) = DECL_NAME (TREE_PURPOSE (pair));
|
||||||
|
|
||||||
|
TYPE_VALUES (enumtype) = values;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Replace the decl nodes in VALUES with their names. */
|
|
||||||
for (pair = values; pair; pair = TREE_CHAIN (pair))
|
|
||||||
TREE_PURPOSE (pair) = DECL_NAME (TREE_PURPOSE (pair));
|
|
||||||
|
|
||||||
TYPE_VALUES (enumtype) = values;
|
|
||||||
|
|
||||||
/* Fix up all variant types of this enum type. */
|
/* Fix up all variant types of this enum type. */
|
||||||
for (tem = TYPE_MAIN_VARIANT (enumtype); tem; tem = TYPE_NEXT_VARIANT (tem))
|
for (tem = TYPE_MAIN_VARIANT (enumtype); tem; tem = TYPE_NEXT_VARIANT (tem))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user