make @defs work properly and don't do uninitialized checks on structs

This commit is contained in:
Bill Currie 2003-08-20 19:58:41 +00:00
parent 83334ce633
commit 7d830ffc1f
5 changed files with 19 additions and 13 deletions

View file

@ -100,6 +100,8 @@ void category_add_protocol_methods (category_t *category,
struct expr_s *protocols); struct expr_s *protocols);
void class_finish_module (void); void class_finish_module (void);
void class_to_struct (class_t *class, struct struct_s *strct);
typedef struct protocol_s { typedef struct protocol_s {
const char *name; const char *name;
struct methodlist_s *methods; struct methodlist_s *methods;

View file

@ -851,3 +851,17 @@ clear_classes (void)
if (class_hash) if (class_hash)
class_Class.super_class = get_class ("Object", 1); class_Class.super_class = get_class ("Object", 1);
} }
void
class_to_struct (class_t *class, struct_t *strct)
{
struct_field_t *s = class->ivars->struct_head;
if (class->super_class) {
class_to_struct (class->super_class, strct);
s = s->next;
}
for (; s; s = s->next)
new_struct_field (strct, s->type, s->name, vis_public);
}

View file

@ -288,6 +288,7 @@ check_initialized (expr_t *e)
if (e->type == ex_def if (e->type == ex_def
&& !(e->e.def->type->type == ev_func && !(e->e.def->type->type == ev_func
&& e->e.def->global) && e->e.def->global)
&& !(e->e.def->type->type == ev_struct)
&& !e->e.def->external && !e->e.def->external
&& !e->e.def->initialized) { && !e->e.def->initialized) {
warning (e, "%s may be used uninitialized", e->e.def->name); warning (e, "%s may be used uninitialized", e->e.def->name);

View file

@ -244,12 +244,12 @@ storage_class
struct_defs struct_defs
: /* empty */ : /* empty */
| struct_defs struct_def ';' | struct_defs struct_def ';'
| DEFS '(' NAME ')' | DEFS '(' maybe_class ')'
{ {
class_t *class = get_class ($3, 0); class_t *class = get_class ($3, 0);
if (class) { if (class) {
copy_struct_fields (current_struct, class->ivars); class_to_struct (class, current_struct);
} else { } else {
error (0, "undefined symbol `%s'", $3); error (0, "undefined symbol `%s'", $3);
} }

View file

@ -156,17 +156,6 @@ get_struct (const char *name, int create)
return s; return s;
} }
void
copy_struct_fields (struct_t *dst, struct_t *src)
{
struct_field_t *s;
if (!src)
return;
for (s = src->struct_head; s; s = s->next)
new_struct_field (dst, s->type, s->name, s->visibility);
}
int int
struct_compare_fields (struct_t *s1, struct_t *s2) struct_compare_fields (struct_t *s1, struct_t *s2)
{ {