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
This commit is contained in:
parent
762f7d9d8a
commit
7114359fb6
|
@ -1,3 +1,13 @@
|
||||||
|
2007-06-04 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
2007-06-04 Tom Tromey <tromey@redhat.com>
|
2007-06-04 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
* c-common.c (c_common_get_alias_set): Fix indentation.
|
* c-common.c (c_common_get_alias_set): Fix indentation.
|
||||||
|
|
29
gcc/c-decl.c
29
gcc/c-decl.c
|
@ -81,18 +81,6 @@ location_t pending_invalid_xref_location;
|
||||||
/* True means we've initialized exception handling. */
|
/* True means we've initialized exception handling. */
|
||||||
bool c_eh_initialized_p;
|
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
|
/* The file and line that the prototype came from if this is an
|
||||||
old-style definition; used for diagnostics in
|
old-style definition; used for diagnostics in
|
||||||
store_parm_decls_oldstyle. */
|
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. */
|
may be used to declare the individual values as they are read. */
|
||||||
|
|
||||||
tree
|
tree
|
||||||
start_enum (tree name)
|
start_enum (struct c_enum_contents *the_enum, tree name)
|
||||||
{
|
{
|
||||||
tree enumtype = 0;
|
tree enumtype = 0;
|
||||||
|
|
||||||
|
@ -5833,8 +5821,8 @@ start_enum (tree name)
|
||||||
TYPE_VALUES (enumtype) = 0;
|
TYPE_VALUES (enumtype) = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum_next_value = integer_zero_node;
|
the_enum->enum_next_value = integer_zero_node;
|
||||||
enum_overflow = 0;
|
the_enum->enum_overflow = 0;
|
||||||
|
|
||||||
if (flag_short_enums)
|
if (flag_short_enums)
|
||||||
TYPE_PACKED (enumtype) = 1;
|
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. */
|
Assignment of sequential values by default is handled here. */
|
||||||
|
|
||||||
tree
|
tree
|
||||||
build_enumerator (tree name, tree value)
|
build_enumerator (struct c_enum_contents *the_enum, tree name, tree value)
|
||||||
{
|
{
|
||||||
tree decl, type;
|
tree decl, type;
|
||||||
|
|
||||||
|
@ -6017,8 +6005,8 @@ build_enumerator (tree name, tree value)
|
||||||
in the default. */
|
in the default. */
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
{
|
{
|
||||||
value = enum_next_value;
|
value = the_enum->enum_next_value;
|
||||||
if (enum_overflow)
|
if (the_enum->enum_overflow)
|
||||||
error ("overflow in enumeration values");
|
error ("overflow in enumeration values");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6031,8 +6019,9 @@ build_enumerator (tree name, tree value)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set basis for default for next value. */
|
/* Set basis for default for next value. */
|
||||||
enum_next_value = build_binary_op (PLUS_EXPR, value, integer_one_node, 0);
|
the_enum->enum_next_value = build_binary_op (PLUS_EXPR, value,
|
||||||
enum_overflow = tree_int_cst_lt (enum_next_value, 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. */
|
/* Now create a declaration for the enum value name. */
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* Parser for C and Objective-C.
|
/* Parser for C and Objective-C.
|
||||||
Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
||||||
1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Parser actions based on the old Bison parser; structure somewhat
|
Parser actions based on the old Bison parser; structure somewhat
|
||||||
influenced by and fragments based on the C++ parser.
|
influenced by and fragments based on the C++ parser.
|
||||||
|
@ -1698,7 +1698,8 @@ c_parser_enum_specifier (c_parser *parser)
|
||||||
if (c_parser_next_token_is (parser, CPP_OPEN_BRACE))
|
if (c_parser_next_token_is (parser, CPP_OPEN_BRACE))
|
||||||
{
|
{
|
||||||
/* Parse an enum definition. */
|
/* Parse an enum definition. */
|
||||||
tree type = start_enum (ident);
|
struct c_enum_contents the_enum;
|
||||||
|
tree type = start_enum (&the_enum, ident);
|
||||||
tree postfix_attrs;
|
tree postfix_attrs;
|
||||||
/* We chain the enumerators in reverse order, then put them in
|
/* We chain the enumerators in reverse order, then put them in
|
||||||
forward order at the end. */
|
forward order at the end. */
|
||||||
|
@ -1726,7 +1727,7 @@ c_parser_enum_specifier (c_parser *parser)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
enum_value = NULL_TREE;
|
enum_value = NULL_TREE;
|
||||||
enum_decl = build_enumerator (enum_id, enum_value);
|
enum_decl = build_enumerator (&the_enum, enum_id, enum_value);
|
||||||
TREE_CHAIN (enum_decl) = values;
|
TREE_CHAIN (enum_decl) = values;
|
||||||
values = enum_decl;
|
values = enum_decl;
|
||||||
seen_comma = false;
|
seen_comma = false;
|
||||||
|
|
17
gcc/c-tree.h
17
gcc/c-tree.h
|
@ -1,6 +1,6 @@
|
||||||
/* Definitions for C parsing and type checking.
|
/* Definitions for C parsing and type checking.
|
||||||
Copyright (C) 1987, 1993, 1994, 1995, 1997, 1998,
|
Copyright (C) 1987, 1993, 1994, 1995, 1997, 1998,
|
||||||
1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of GCC.
|
This file is part of GCC.
|
||||||
|
|
||||||
|
@ -425,6 +425,17 @@ struct c_label_context_vm
|
||||||
struct c_label_context_vm *next;
|
struct c_label_context_vm *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Used when parsing an enum. Initialized by start_enum. */
|
||||||
|
struct c_enum_contents
|
||||||
|
{
|
||||||
|
/* While defining an enum type, this is 1 plus the last enumerator
|
||||||
|
constant value. */
|
||||||
|
tree enum_next_value;
|
||||||
|
|
||||||
|
/* Nonzero means that there was overflow computing enum_next_value. */
|
||||||
|
int enum_overflow;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* in c-parser.c */
|
/* in c-parser.c */
|
||||||
extern void c_parse_init (void);
|
extern void c_parse_init (void);
|
||||||
|
@ -448,7 +459,7 @@ extern void c_print_identifier (FILE *, tree, int);
|
||||||
extern int quals_from_declspecs (const struct c_declspecs *);
|
extern int quals_from_declspecs (const struct c_declspecs *);
|
||||||
extern struct c_declarator *build_array_declarator (tree, struct c_declspecs *,
|
extern struct c_declarator *build_array_declarator (tree, struct c_declspecs *,
|
||||||
bool, bool);
|
bool, bool);
|
||||||
extern tree build_enumerator (tree, tree);
|
extern tree build_enumerator (struct c_enum_contents *, tree, tree);
|
||||||
extern tree check_for_loop_decls (void);
|
extern tree check_for_loop_decls (void);
|
||||||
extern void mark_forward_parm_decls (void);
|
extern void mark_forward_parm_decls (void);
|
||||||
extern void declare_parm_level (void);
|
extern void declare_parm_level (void);
|
||||||
|
@ -476,7 +487,7 @@ extern struct c_declarator *set_array_declarator_inner (struct c_declarator *,
|
||||||
extern tree c_builtin_function (tree);
|
extern tree c_builtin_function (tree);
|
||||||
extern void shadow_tag (const struct c_declspecs *);
|
extern void shadow_tag (const struct c_declspecs *);
|
||||||
extern void shadow_tag_warned (const struct c_declspecs *, int);
|
extern void shadow_tag_warned (const struct c_declspecs *, int);
|
||||||
extern tree start_enum (tree);
|
extern tree start_enum (struct c_enum_contents *, tree);
|
||||||
extern int start_function (struct c_declspecs *, struct c_declarator *, tree);
|
extern int start_function (struct c_declspecs *, struct c_declarator *, tree);
|
||||||
extern tree start_decl (struct c_declarator *, struct c_declspecs *, bool,
|
extern tree start_decl (struct c_declarator *, struct c_declspecs *, bool,
|
||||||
tree);
|
tree);
|
||||||
|
|
Loading…
Reference in New Issue