summaryrefslogtreecommitdiff
path: root/gcc/c-decl.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2007-06-04 23:19:19 +0000
committerTom Tromey <tromey@gcc.gnu.org>2007-06-04 23:19:19 +0000
commit7114359fb661692c92e7d57f7cb96a8787eb0db3 (patch)
tree6521609daacb24a634b68fedc99b126c449c8899 /gcc/c-decl.c
parent762f7d9d8aa388aba0272677ab170741fe218260 (diff)
downloadgcc-7114359fb661692c92e7d57f7cb96a8787eb0db3.tar.gz
c-tree.h (start_enum): Update.
* c-tree.h (start_enum): Update. (build_enumerator): Likewise. * c-decl.c (enum_next_value): Removed. (enum_overflow): Likewise. (start_enum): Add c_enum_contents argument. Don't use globals. (build_enumerator): Likewise. * c-tree.h (struct c_enum_contents): New struct. From-SVN: r125322
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r--gcc/c-decl.c29
1 files changed, 9 insertions, 20 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 1f8943f05a7..838869c1782 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -81,18 +81,6 @@ location_t pending_invalid_xref_location;
/* True means we've initialized exception handling. */
bool c_eh_initialized_p;
-/* While defining an enum type, this is 1 plus the last enumerator
- constant value. Note that will do not have to save this or `enum_overflow'
- around nested function definition since such a definition could only
- occur in an enum value expression and we don't use these variables in
- that case. */
-
-static tree enum_next_value;
-
-/* Nonzero means that there was overflow computing enum_next_value. */
-
-static int enum_overflow;
-
/* The file and line that the prototype came from if this is an
old-style definition; used for diagnostics in
store_parm_decls_oldstyle. */
@@ -5801,7 +5789,7 @@ layout_array_type (tree t)
may be used to declare the individual values as they are read. */
tree
-start_enum (tree name)
+start_enum (struct c_enum_contents *the_enum, tree name)
{
tree enumtype = 0;
@@ -5833,8 +5821,8 @@ start_enum (tree name)
TYPE_VALUES (enumtype) = 0;
}
- enum_next_value = integer_zero_node;
- enum_overflow = 0;
+ the_enum->enum_next_value = integer_zero_node;
+ the_enum->enum_overflow = 0;
if (flag_short_enums)
TYPE_PACKED (enumtype) = 1;
@@ -5987,7 +5975,7 @@ finish_enum (tree enumtype, tree values, tree attributes)
Assignment of sequential values by default is handled here. */
tree
-build_enumerator (tree name, tree value)
+build_enumerator (struct c_enum_contents *the_enum, tree name, tree value)
{
tree decl, type;
@@ -6017,8 +6005,8 @@ build_enumerator (tree name, tree value)
in the default. */
if (value == 0)
{
- value = enum_next_value;
- if (enum_overflow)
+ value = the_enum->enum_next_value;
+ if (the_enum->enum_overflow)
error ("overflow in enumeration values");
}
@@ -6031,8 +6019,9 @@ build_enumerator (tree name, tree value)
}
/* Set basis for default for next value. */
- enum_next_value = build_binary_op (PLUS_EXPR, value, integer_one_node, 0);
- enum_overflow = tree_int_cst_lt (enum_next_value, value);
+ the_enum->enum_next_value = build_binary_op (PLUS_EXPR, value,
+ integer_one_node, 0);
+ the_enum->enum_overflow = tree_int_cst_lt (the_enum->enum_next_value, value);
/* Now create a declaration for the enum value name. */