summaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2011-01-11 11:12:15 -0500
committerRuss Cox <rsc@golang.org>2011-01-11 11:12:15 -0500
commit86483b5a3a2f263ed94c844fe017871fc9718d03 (patch)
tree60029b23050c67503570f949c904645f270bba9b /src/cmd
parent85fee96d24c522aa38b5dd4a087683be5e1bfc5a (diff)
downloadgo-86483b5a3a2f263ed94c844fe017871fc9718d03.tar.gz
godefs: better handling of enums
Fixes issue 432. R=r, r2 CC=golang-dev http://codereview.appspot.com/3869043
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/godefs/main.c2
-rw-r--r--src/cmd/godefs/stabs.c13
2 files changed, 13 insertions, 2 deletions
diff --git a/src/cmd/godefs/main.c b/src/cmd/godefs/main.c
index cdecd6e8d..69ee1be5d 100644
--- a/src/cmd/godefs/main.c
+++ b/src/cmd/godefs/main.c
@@ -373,6 +373,8 @@ Continue:
prefix = prefixlen(t);
for(j=0; j<t->nf; j++) {
f = &t->f[j];
+ if(f->type->kind == 0)
+ continue;
// padding
if(t->kind == Struct || lang == &go) {
if(f->offset%8 != 0 || f->size%8 != 0) {
diff --git a/src/cmd/godefs/stabs.c b/src/cmd/godefs/stabs.c
index 8d3be1913..1bc96d4c8 100644
--- a/src/cmd/godefs/stabs.c
+++ b/src/cmd/godefs/stabs.c
@@ -363,13 +363,22 @@ parsedef(char **pp, char *name)
return nil;
}
+ while(f->type->kind == Typedef)
+ f->type = f->type->type;
+ if(f->type->kind == 0 && f->size <= 64 && (f->size&(f->size-1)) == 0) {
+ // unknown type but <= 64 bits and bit size is a power of two.
+ // could be enum - make Uint64 and then let it reduce
+ tt = emalloc(sizeof *tt);
+ *tt = *f->type;
+ f->type = tt;
+ tt->kind = Uint64;
+ }
+
// rewrite
// uint32 x : 8;
// into
// uint8 x;
// hooray for bitfields.
- while(f->type->kind == Typedef)
- f->type = f->type->type;
while(Int16 <= f->type->kind && f->type->kind <= Uint64 && kindsize[f->type->kind] > f->size) {
tt = emalloc(sizeof *tt);
*tt = *f->type;