From 7d830ffc1fc79ce83966b5810892a002c1c71e93 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 20 Aug 2003 19:58:41 +0000 Subject: [PATCH] make @defs work properly and don't do uninitialized checks on structs --- tools/qfcc/include/class.h | 2 ++ tools/qfcc/source/class.c | 14 ++++++++++++++ tools/qfcc/source/expr.c | 1 + tools/qfcc/source/qc-parse.y | 4 ++-- tools/qfcc/source/struct.c | 11 ----------- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/tools/qfcc/include/class.h b/tools/qfcc/include/class.h index f3a89e4dd..579d618e0 100644 --- a/tools/qfcc/include/class.h +++ b/tools/qfcc/include/class.h @@ -100,6 +100,8 @@ void category_add_protocol_methods (category_t *category, struct expr_s *protocols); void class_finish_module (void); +void class_to_struct (class_t *class, struct struct_s *strct); + typedef struct protocol_s { const char *name; struct methodlist_s *methods; diff --git a/tools/qfcc/source/class.c b/tools/qfcc/source/class.c index e054b6b7c..a18b55450 100644 --- a/tools/qfcc/source/class.c +++ b/tools/qfcc/source/class.c @@ -851,3 +851,17 @@ clear_classes (void) if (class_hash) 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); +} diff --git a/tools/qfcc/source/expr.c b/tools/qfcc/source/expr.c index ab28ad214..ed00f159c 100644 --- a/tools/qfcc/source/expr.c +++ b/tools/qfcc/source/expr.c @@ -288,6 +288,7 @@ check_initialized (expr_t *e) if (e->type == ex_def && !(e->e.def->type->type == ev_func && e->e.def->global) + && !(e->e.def->type->type == ev_struct) && !e->e.def->external && !e->e.def->initialized) { warning (e, "%s may be used uninitialized", e->e.def->name); diff --git a/tools/qfcc/source/qc-parse.y b/tools/qfcc/source/qc-parse.y index 51dc0cadb..e1366be04 100644 --- a/tools/qfcc/source/qc-parse.y +++ b/tools/qfcc/source/qc-parse.y @@ -244,12 +244,12 @@ storage_class struct_defs : /* empty */ | struct_defs struct_def ';' - | DEFS '(' NAME ')' + | DEFS '(' maybe_class ')' { class_t *class = get_class ($3, 0); if (class) { - copy_struct_fields (current_struct, class->ivars); + class_to_struct (class, current_struct); } else { error (0, "undefined symbol `%s'", $3); } diff --git a/tools/qfcc/source/struct.c b/tools/qfcc/source/struct.c index e561403e0..e4be44735 100644 --- a/tools/qfcc/source/struct.c +++ b/tools/qfcc/source/struct.c @@ -156,17 +156,6 @@ get_struct (const char *name, int create) 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 struct_compare_fields (struct_t *s1, struct_t *s2) {