v3: handle union in struct correctly

v3: handle union in struct correctly.

Currently, didn't parse union in the struct. Below is a lack of Imm and Mem.

source:

#include <stdint.h>

typedef struct mem {
	unsigned int	base;
} mem;

typedef struct op {
	union {
		unsigned int reg;
		int32_t imm;
		mem mem;
	};
} op;

actual:

type Mem1 = struct{ Base uint32 } /* union.h:3:9 */
.
.
.
type Mem = Mem1 /* union.h:5:3 */

type Op1 = struct{ X__0 struct{ Reg uint32 } } /* union.h:7:9 */

type Op = Op1 /* union.h:13:3 */

expected:

type Mem1 = struct{ Base uint32 } /* union.h:3:9 */
.
.

type Mem = Mem1 /* union.h:5:3 */

type Op1 = struct {
	X__0 struct {
		Reg uint32
		Imm Int32_t
		Mem Mem
	}
} /* union.h:7:9 */

type Op = Op1 /* union.h:13:3 */

I can generate my project C source, but I don't know whether this change is correct. Send a merge request for just your reference.

Edited by zchee

Merge request reports

Loading