def test_nestedstructs(self):
    src = '\n        #include <stdio.h>\n        #include "emscripten.h"\n\n        struct base {\n          int x;\n          float y;\n          union {\n            int a;\n            float b;\n          };\n          char c;\n        };\n\n        struct hashtableentry {\n          int key;\n          base data;\n        };\n\n        struct hashset {\n          typedef hashtableentry entry;\n          struct chain { entry elem; chain *next; };\n        //  struct chainchunk { chain chains[100]; chainchunk *next; };\n        };\n\n        struct hashtable : hashset {\n          hashtable() {\n            base *b = NULL;\n            entry *e = NULL;\n            chain *c = NULL;\n            printf("*%d,%d,%d,%d,%d,%d|%d,%d,%d,%d,%d,%d,%d,%d|%d,%d,%d,%d,%d,%d,%d,%d,%d,%d*\\n",\n              sizeof(base),\n              int(&(b->x)), int(&(b->y)), int(&(b->a)), int(&(b->b)), int(&(b->c)),\n              sizeof(hashtableentry),\n              int(&(e->key)), int(&(e->data)), int(&(e->data.x)), int(&(e->data.y)), int(&(e->data.a)), int(&(e->data.b)), int(&(e->data.c)),\n              sizeof(hashset::chain),\n              int(&(c->elem)), int(&(c->next)), int(&(c->elem.key)), int(&(c->elem.data)), int(&(c->elem.data.x)), int(&(c->elem.data.y)), int(&(c->elem.data.a)), int(&(c->elem.data.b)), int(&(c->elem.data.c))\n            );\n          }\n        };\n\n        struct B { char buffer[62]; int last; char laster; char laster2; };\n\n        struct Bits {\n          unsigned short A : 1;\n          unsigned short B : 1;\n          unsigned short C : 1;\n          unsigned short D : 1;\n          unsigned short x1 : 1;\n          unsigned short x2 : 1;\n          unsigned short x3 : 1;\n          unsigned short x4 : 1;\n        };\n\n        int main() {\n          hashtable t;\n\n          // Part 2 - the char[] should be compressed, BUT have a padding space at the end so the next\n          // one is aligned properly. Also handle char; char; etc. properly.\n          B *b = NULL;\n          printf("*%d,%d,%d,%d,%d,%d,%d,%d,%d*\\n", int(b), int(&(b->buffer)), int(&(b->buffer[0])), int(&(b->buffer[1])), int(&(b->buffer[2])),\n                                                    int(&(b->last)), int(&(b->laster)), int(&(b->laster2)), sizeof(B));\n\n          // Part 3 - bitfields, and small structures\n          Bits *b2 = NULL;\n          printf("*%d*\\n", sizeof(Bits));\n\n          return 0;\n        }\n        '
    self.do_run(src, '*16,0,4,8,8,12|20,0,4,4,8,12,12,16|24,0,20,0,4,4,8,12,12,16*\n*0,0,0,1,2,64,68,69,72*\n*2*')
def test_nestedstructs(self):
    src = '\n        #include <stdio.h>\n        #include "emscripten.h"\n\n        struct base {\n          int x;\n          float y;\n          union {\n            int a;\n            float b;\n          };\n          char c;\n        };\n\n        struct hashtableentry {\n          int key;\n          base data;\n        };\n\n        struct hashset {\n          typedef hashtableentry entry;\n          struct chain { entry elem; chain *next; };\n        //  struct chainchunk { chain chains[100]; chainchunk *next; };\n        };\n\n        struct hashtable : hashset {\n          hashtable() {\n            base *b = NULL;\n            entry *e = NULL;\n            chain *c = NULL;\n            printf("*%d,%d,%d,%d,%d,%d|%d,%d,%d,%d,%d,%d,%d,%d|%d,%d,%d,%d,%d,%d,%d,%d,%d,%d*\\n",\n              sizeof(base),\n              int(&(b->x)), int(&(b->y)), int(&(b->a)), int(&(b->b)), int(&(b->c)),\n              sizeof(hashtableentry),\n              int(&(e->key)), int(&(e->data)), int(&(e->data.x)), int(&(e->data.y)), int(&(e->data.a)), int(&(e->data.b)), int(&(e->data.c)),\n              sizeof(hashset::chain),\n              int(&(c->elem)), int(&(c->next)), int(&(c->elem.key)), int(&(c->elem.data)), int(&(c->elem.data.x)), int(&(c->elem.data.y)), int(&(c->elem.data.a)), int(&(c->elem.data.b)), int(&(c->elem.data.c))\n            );\n          }\n        };\n\n        struct B { char buffer[62]; int last; char laster; char laster2; };\n\n        struct Bits {\n          unsigned short A : 1;\n          unsigned short B : 1;\n          unsigned short C : 1;\n          unsigned short D : 1;\n          unsigned short x1 : 1;\n          unsigned short x2 : 1;\n          unsigned short x3 : 1;\n          unsigned short x4 : 1;\n        };\n\n        int main() {\n          hashtable t;\n\n          // Part 2 - the char[] should be compressed, BUT have a padding space at the end so the next\n          // one is aligned properly. Also handle char; char; etc. properly.\n          B *b = NULL;\n          printf("*%d,%d,%d,%d,%d,%d,%d,%d,%d*\\n", int(b), int(&(b->buffer)), int(&(b->buffer[0])), int(&(b->buffer[1])), int(&(b->buffer[2])),\n                                                    int(&(b->last)), int(&(b->laster)), int(&(b->laster2)), sizeof(B));\n\n          // Part 3 - bitfields, and small structures\n          Bits *b2 = NULL;\n          printf("*%d*\\n", sizeof(Bits));\n\n          return 0;\n        }\n        '
    self.do_run(src, '*16,0,4,8,8,12|20,0,4,4,8,12,12,16|24,0,20,0,4,4,8,12,12,16*\n*0,0,0,1,2,64,68,69,72*\n*2*')