Commit dc491a25 by Ian Lance Taylor Committed by Ian Lance Taylor

dse.c (struct store_info): Rename bitmap field to bmap.

./:	* dse.c (struct store_info): Rename bitmap field to bmap.  Change
	all uses.

	* c-decl.c (in_struct, struct_types): Remove.
	(struct c_binding): Add in_struct field.
	(c_binding_ptr): Define type, along with VEC.
	(struct c_struct_parse_info): Define.
	(struct_parse_info): New static variable.
	(bind): Initialize in_struct field.
	(start_struct): Remove enclosing_in_struct and
	enclosing_struct_types parameters.  Add
	enclosing_struct_parse_info parameter.  Change all callers.  Set
	struct_parse_info rather than in_struct and struct_types.
	(grokfield): If -Wc++-compat and there is a symbol binding for the
	field name, set the in_struct flag and push it on the
	struct_parse_info->fields vector.
	(warn_cxx_compat_finish_struct): New static function.
	(finish_struct): Remove enclosing_in_struct and
	enclosing_struct_types parameters.  Add
	enclosing_struct_parse_info parameter.  Change all callers.  Don't
	set C_TYPE_DEFINED_IN_STRUCT here.  Call
	warn_cxx_compat_finish_struct.  Free struct_parse_info and set to
	parameter.  Only push on struct_types if warn_cxx_compat.
	(finish_enum): Only push on struct_types if warn_cxx_compat.
	(declspecs_add_type): Add loc parameter.  Change all callers.
	Change all error calls to error_at.  Pass loc, not input_location,
	to pedwarn calls.  Warn if -Wc++-compat and a typedef name is
	defined in a struct.  If -Wc++-compat and parsing a struct, record
	that a typedef name was used.
	* c-parser.c (c_parser_declspecs): Get location to pass to
	declspecs_add_type.
	(c_parser_struct_or_union_specifier): Update calls to start_struct
	and finish_struct.
	* c-tree.h (struct c_struct_parse_info): Declare.
	(finish_struct, start_struct): Update declarations.
	(declspecs_add_type): Update declaration.
objc/:
	* objc-act.c (objc_in_struct, objc_struct_types): Remove.
	(objc_struct_info): New static variable.
	(objc_start_struct): Pass &objc_struct_info, not &objc_in_struct
	and &objc_struct_types, to start_struct.
	(objc_finish_struct): Likewise for finish_struct.
objcp/:
	* objcp-decl.h (start_struct): Remove in_struct and struct_types
	parameters.  Add struct_info parameter.
	(finish_struct): Likewise.
testsuite/:
	* gcc.dg/Wcxx-compat-15.c: New testcase.

From-SVN: r148709
parent 88eeff6f
2009-06-19 Ian Lance Taylor <iant@google.com>
* dse.c (struct store_info): Rename bitmap field to bmap. Change
all uses.
* c-decl.c (in_struct, struct_types): Remove.
(struct c_binding): Add in_struct field.
(c_binding_ptr): Define type, along with VEC.
(struct c_struct_parse_info): Define.
(struct_parse_info): New static variable.
(bind): Initialize in_struct field.
(start_struct): Remove enclosing_in_struct and
enclosing_struct_types parameters. Add
enclosing_struct_parse_info parameter. Change all callers. Set
struct_parse_info rather than in_struct and struct_types.
(grokfield): If -Wc++-compat and there is a symbol binding for the
field name, set the in_struct flag and push it on the
struct_parse_info->fields vector.
(warn_cxx_compat_finish_struct): New static function.
(finish_struct): Remove enclosing_in_struct and
enclosing_struct_types parameters. Add
enclosing_struct_parse_info parameter. Change all callers. Don't
set C_TYPE_DEFINED_IN_STRUCT here. Call
warn_cxx_compat_finish_struct. Free struct_parse_info and set to
parameter. Only push on struct_types if warn_cxx_compat.
(finish_enum): Only push on struct_types if warn_cxx_compat.
(declspecs_add_type): Add loc parameter. Change all callers.
Change all error calls to error_at. Pass loc, not input_location,
to pedwarn calls. Warn if -Wc++-compat and a typedef name is
defined in a struct. If -Wc++-compat and parsing a struct, record
that a typedef name was used.
* c-parser.c (c_parser_declspecs): Get location to pass to
declspecs_add_type.
(c_parser_struct_or_union_specifier): Update calls to start_struct
and finish_struct.
* c-tree.h (struct c_struct_parse_info): Declare.
(finish_struct, start_struct): Update declarations.
(declspecs_add_type): Update declaration.
2009-06-19 Ian Lance Taylor <iant@google.com>
* c-decl.c (grokdeclarator): If -Wc++-compat, warn about a global
variable with an anonymous type.
......
......@@ -1447,6 +1447,7 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs,
{
struct c_typespec t;
tree attrs;
location_t loc = c_parser_peek_token (parser)->location;
if (c_parser_next_token_is (parser, CPP_NAME))
{
tree value = c_parser_peek_token (parser)->value;
......@@ -1482,7 +1483,7 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs,
t.expr = NULL_TREE;
t.expr_const_operands = true;
}
declspecs_add_type (specs, t);
declspecs_add_type (loc, specs, t);
continue;
}
if (c_parser_next_token_is (parser, CPP_LESS))
......@@ -1498,7 +1499,7 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs,
t.spec = objc_get_protocol_qualified_type (NULL_TREE, proto);
t.expr = NULL_TREE;
t.expr_const_operands = true;
declspecs_add_type (specs, t);
declspecs_add_type (loc, specs, t);
continue;
}
gcc_assert (c_parser_next_token_is (parser, CPP_KEYWORD));
......@@ -1547,7 +1548,7 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs,
t.spec = c_parser_peek_token (parser)->value;
t.expr = NULL_TREE;
t.expr_const_operands = true;
declspecs_add_type (specs, t);
declspecs_add_type (loc, specs, t);
c_parser_consume_token (parser);
break;
case RID_ENUM:
......@@ -1556,7 +1557,7 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs,
attrs_ok = true;
seen_type = true;
t = c_parser_enum_specifier (parser);
declspecs_add_type (specs, t);
declspecs_add_type (loc, specs, t);
break;
case RID_STRUCT:
case RID_UNION:
......@@ -1566,7 +1567,7 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs,
seen_type = true;
t = c_parser_struct_or_union_specifier (parser);
invoke_plugin_callbacks (PLUGIN_FINISH_TYPE, t.spec);
declspecs_add_type (specs, t);
declspecs_add_type (loc, specs, t);
break;
case RID_TYPEOF:
/* ??? The old parser rejected typeof after other type
......@@ -1577,7 +1578,7 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs,
attrs_ok = true;
seen_type = true;
t = c_parser_typeof_specifier (parser);
declspecs_add_type (specs, t);
declspecs_add_type (loc, specs, t);
break;
case RID_CONST:
case RID_VOLATILE:
......@@ -1815,10 +1816,8 @@ c_parser_struct_or_union_specifier (c_parser *parser)
{
/* Parse a struct or union definition. Start the scope of the
tag before parsing components. */
bool in_struct;
VEC(tree,heap) *struct_types;
tree type = start_struct (struct_loc, code, ident,
&in_struct, &struct_types);
struct c_struct_parse_info *struct_info;
tree type = start_struct (struct_loc, code, ident, &struct_info);
tree postfix_attrs;
/* We chain the components in reverse order, then put them in
forward order at the end. Each struct-declaration may
......@@ -1908,8 +1907,7 @@ c_parser_struct_or_union_specifier (c_parser *parser)
}
postfix_attrs = c_parser_attributes (parser);
ret.spec = finish_struct (struct_loc, type, nreverse (contents),
chainon (attrs, postfix_attrs),
in_struct, struct_types);
chainon (attrs, postfix_attrs), struct_info);
ret.kind = ctsk_tagdef;
ret.expr = NULL_TREE;
ret.expr_const_operands = true;
......
......@@ -430,6 +430,7 @@ extern void gen_aux_info_record (tree, int, int, int);
/* in c-decl.c */
struct c_spot_bindings;
struct c_struct_parse_info;
extern struct obstack parser_obstack;
extern tree c_break_label;
extern tree c_cont_label;
......@@ -465,7 +466,8 @@ extern void c_maybe_initialize_eh (void);
extern void finish_decl (tree, location_t, tree, tree, tree);
extern tree finish_enum (tree, tree, tree);
extern void finish_function (void);
extern tree finish_struct (location_t, tree, tree, tree, bool, VEC(tree,heap) *);
extern tree finish_struct (location_t, tree, tree, tree,
struct c_struct_parse_info *);
extern struct c_arg_info *get_parm_info (bool);
extern tree grokfield (location_t, struct c_declarator *,
struct c_declspecs *, tree, tree *);
......@@ -487,7 +489,8 @@ extern tree start_enum (location_t, struct c_enum_contents *, tree);
extern int start_function (struct c_declspecs *, struct c_declarator *, tree);
extern tree start_decl (struct c_declarator *, struct c_declspecs *, bool,
tree);
extern tree start_struct (location_t, enum tree_code, tree, bool *, VEC(tree,heap) **);
extern tree start_struct (location_t, enum tree_code, tree,
struct c_struct_parse_info **);
extern void store_parm_decls (void);
extern void store_parm_decls_from (struct c_arg_info *);
extern tree xref_tag (enum tree_code, tree);
......@@ -504,7 +507,8 @@ extern struct c_declarator *make_pointer_declarator (struct c_declspecs *,
struct c_declarator *);
extern struct c_declspecs *build_null_declspecs (void);
extern struct c_declspecs *declspecs_add_qual (struct c_declspecs *, tree);
extern struct c_declspecs *declspecs_add_type (struct c_declspecs *,
extern struct c_declspecs *declspecs_add_type (location_t,
struct c_declspecs *,
struct c_typespec);
extern struct c_declspecs *declspecs_add_scspec (struct c_declspecs *, tree);
extern struct c_declspecs *declspecs_add_attrs (struct c_declspecs *, tree);
......
......@@ -244,7 +244,7 @@ struct store_info
{
/* A bitmap with one bit per byte. Cleared bit means the position
is needed. Used if IS_LARGE is false. */
bitmap bitmap;
bitmap bmap;
/* Number of set bits (i.e. unneeded bytes) in BITMAP. If it is
equal to END - BEGIN, the whole store is unused. */
......@@ -791,7 +791,7 @@ free_store_info (insn_info_t insn_info)
{
store_info_t next = store_info->next;
if (store_info->is_large)
BITMAP_FREE (store_info->positions_needed.large.bitmap);
BITMAP_FREE (store_info->positions_needed.large.bmap);
if (store_info->cse_base)
pool_free (cse_store_info_pool, store_info);
else
......@@ -1213,10 +1213,10 @@ set_position_unneeded (store_info_t s_info, int pos)
{
if (__builtin_expect (s_info->is_large, false))
{
if (!bitmap_bit_p (s_info->positions_needed.large.bitmap, pos))
if (!bitmap_bit_p (s_info->positions_needed.large.bmap, pos))
{
s_info->positions_needed.large.count++;
bitmap_set_bit (s_info->positions_needed.large.bitmap, pos);
bitmap_set_bit (s_info->positions_needed.large.bmap, pos);
}
}
else
......@@ -1233,7 +1233,7 @@ set_all_positions_unneeded (store_info_t s_info)
{
int pos, end = s_info->end - s_info->begin;
for (pos = 0; pos < end; pos++)
bitmap_set_bit (s_info->positions_needed.large.bitmap, pos);
bitmap_set_bit (s_info->positions_needed.large.bmap, pos);
s_info->positions_needed.large.count = end;
}
else
......@@ -1263,7 +1263,7 @@ all_positions_needed_p (store_info_t s_info, int start, int width)
{
int end = start + width;
while (start < end)
if (bitmap_bit_p (s_info->positions_needed.large.bitmap, start++))
if (bitmap_bit_p (s_info->positions_needed.large.bmap, start++))
return false;
return true;
}
......@@ -1605,7 +1605,7 @@ record_store (rtx body, bb_info_t bb_info)
{
store_info->is_large = true;
store_info->positions_needed.large.count = 0;
store_info->positions_needed.large.bitmap = BITMAP_ALLOC (NULL);
store_info->positions_needed.large.bmap = BITMAP_ALLOC (NULL);
}
else
{
......@@ -2721,7 +2721,7 @@ dse_step1 (void)
for (s_info = ptr->store_rec; s_info; s_info = s_info->next)
if (s_info->is_large)
{
BITMAP_FREE (s_info->positions_needed.large.bitmap);
BITMAP_FREE (s_info->positions_needed.large.bmap);
s_info->is_large = false;
}
}
......
2009-06-19 Ian Lance Taylor <iant@google.com>
* objc-act.c (objc_in_struct, objc_struct_types): Remove.
(objc_struct_info): New static variable.
(objc_start_struct): Pass &objc_struct_info, not &objc_in_struct
and &objc_struct_types, to start_struct.
(objc_finish_struct): Likewise for finish_struct.
2009-06-15 Ian Lance Taylor <iant@google.com>
* objc-act.c (objc_start_function): Don't set
......
......@@ -420,8 +420,7 @@ static int generating_instance_variables = 0;
is compiled as part of obj-c++. */
static bool objc_building_struct;
static bool objc_in_struct ATTRIBUTE_UNUSED;
static VEC(tree,heap) *objc_struct_types ATTRIBUTE_UNUSED;
static struct c_struct_parse_info *objc_struct_info ATTRIBUTE_UNUSED;
/* Start building a struct for objc. */
......@@ -430,8 +429,7 @@ objc_start_struct (tree name)
{
gcc_assert (!objc_building_struct);
objc_building_struct = true;
return start_struct (input_location, RECORD_TYPE,
name, &objc_in_struct, &objc_struct_types);
return start_struct (input_location, RECORD_TYPE, name, &objc_struct_info);
}
/* Finish building a struct for objc. */
......@@ -442,7 +440,7 @@ objc_finish_struct (tree type, tree fieldlist)
gcc_assert (objc_building_struct);
objc_building_struct = false;
return finish_struct (input_location, type, fieldlist, NULL_TREE,
objc_in_struct, objc_struct_types);
objc_struct_info);
}
/* Some platforms pass small structures through registers versus
......
2009-06-19 Ian Lance Taylor <iant@google.com>
* objcp-decl.h (start_struct): Remove in_struct and struct_types
parameters. Add struct_info parameter.
(finish_struct): Likewise.
2009-06-13 Aldy Hernandez <aldyh@redhat.com>
* objcp-decl.h (start_struct): Add location argument.
......
......@@ -37,9 +37,9 @@ extern tree objcp_end_compound_stmt (tree, int);
invoke the original C++ functions if needed). */
#ifdef OBJCP_REMAP_FUNCTIONS
#define start_struct(loc, code, name, in_struct, struct_types) \
#define start_struct(loc, code, name, struct_info) \
objcp_start_struct (loc, code, name)
#define finish_struct(loc, t, fieldlist, attributes, in_struct, struct_types) \
#define finish_struct(loc, t, fieldlist, attributes, struct_info) \
objcp_finish_struct (loc, t, fieldlist, attributes)
#define finish_function() \
objcp_finish_function ()
......
2009-06-19 Ian Lance Taylor <iant@google.com>
* gcc.dg/Wcxx-compat-15.c: New testcase.
2009-06-19 Ian Lance Taylor <iant@google.com>
* gcc.dg/Wcxx-compat-16.c: New testcase.
2009-06-19 Uros Bizjak <ubizjak@gmail.com>
......
/* { dg-do compile } */
/* { dg-options "-Wc++-compat" } */
typedef int myint1;
typedef int myint2;
typedef int myint3;
struct s1
{
myint1 myint1; /* { dg-warning "invalid in C\[+\]\[+\]" } */
myint2 *myint2; /* { dg-warning "invalid in C\[+\]\[+\]" } */
int myint3;
struct s2
{
myint3 f2; /* { dg-warning "C\[+\]\[+\]" } */
} f1;
};
struct s3
{
int myint1;
struct s4
{
int myint1;
} f1;
struct s5
{
int myint1;
struct s6
{
myint1 f4; /* { dg-warning "C\[+\]\[+\]" } */
} f3;
} f2;
};
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