[qfcc] Create struct fields for "type typename"
Such declarations were being lost, thus in the following, the id field never got added: typedef struct qwaq_mevent_s { int id; int x, y, z; int buttons; } qwaq_mevent_t;
This commit is contained in:
parent
dbbb8a1396
commit
7c9072aebf
|
@ -81,6 +81,7 @@ typedef struct type_s {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
type_t *type;
|
type_t *type;
|
||||||
struct param_s *params;
|
struct param_s *params;
|
||||||
|
struct symbol_s *sym; ///< for dealing with "int id" etc
|
||||||
storage_class_t storage;
|
storage_class_t storage;
|
||||||
unsigned multi_type:1;
|
unsigned multi_type:1;
|
||||||
unsigned multi_store:1;
|
unsigned multi_store:1;
|
||||||
|
|
|
@ -484,6 +484,15 @@ specifiers
|
||||||
type
|
type
|
||||||
: type_specifier
|
: type_specifier
|
||||||
| type type_specifier
|
| type type_specifier
|
||||||
|
{
|
||||||
|
// deal with eg "int id"
|
||||||
|
$1.sym = $2.sym;
|
||||||
|
|
||||||
|
if (!$1.sym) {
|
||||||
|
error (0, "two or more data types in declaration specifiers");
|
||||||
|
}
|
||||||
|
$$ = $1;
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
type_specifier_or_storage_class
|
type_specifier_or_storage_class
|
||||||
|
@ -501,6 +510,7 @@ type_specifier
|
||||||
| TYPE_NAME
|
| TYPE_NAME
|
||||||
{
|
{
|
||||||
$$ = make_spec ($1->type, 0, 0, 0);
|
$$ = make_spec ($1->type, 0, 0, 0);
|
||||||
|
$$.sym = $1;
|
||||||
}
|
}
|
||||||
| OBJECT protocolrefs
|
| OBJECT protocolrefs
|
||||||
{
|
{
|
||||||
|
@ -512,6 +522,7 @@ type_specifier
|
||||||
} else {
|
} else {
|
||||||
$$ = make_spec (&type_id, 0, 0, 0);
|
$$ = make_spec (&type_id, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
$$.sym = $1;
|
||||||
}
|
}
|
||||||
| CLASS_NAME protocolrefs
|
| CLASS_NAME protocolrefs
|
||||||
{
|
{
|
||||||
|
@ -523,6 +534,7 @@ type_specifier
|
||||||
} else {
|
} else {
|
||||||
$$ = make_spec ($1->type, 0, 0, 0);
|
$$ = make_spec ($1->type, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
$$.sym = $1;
|
||||||
}
|
}
|
||||||
// NOTE: fields don't parse the way they should. This is not a problem
|
// NOTE: fields don't parse the way they should. This is not a problem
|
||||||
// for basic types, but functions need special treatment
|
// for basic types, but functions need special treatment
|
||||||
|
@ -656,6 +668,22 @@ struct_def_list
|
||||||
struct_def
|
struct_def
|
||||||
: type struct_decl_list
|
: type struct_decl_list
|
||||||
| type
|
| type
|
||||||
|
{
|
||||||
|
if ($1.sym) {
|
||||||
|
// a type name (id, typedef, etc) was used as a field name.
|
||||||
|
// this is allowed in C
|
||||||
|
print_type ($1.type);
|
||||||
|
printf ("%s\n", $1.sym->name);
|
||||||
|
$1.sym = new_symbol ($1.sym->name);
|
||||||
|
$1.sym->type = $1.type;
|
||||||
|
$1.sym->sy_type = sy_var;
|
||||||
|
symtab_addsymbol (current_symtab, $1.sym);
|
||||||
|
} else {
|
||||||
|
// bare type
|
||||||
|
warning (0, "declaration does not declare anything");
|
||||||
|
}
|
||||||
|
$$ = $1;
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
struct_decl_list
|
struct_decl_list
|
||||||
|
|
Loading…
Reference in New Issue