c2go icon indicating copy to clipboard operation
c2go copied to clipboard

Inline enum as a member of a struct

Open starius opened this issue 6 years ago • 0 comments

Code:

typedef struct aaa {
    enum {
        bar = 1
    } foo;
} aaa;

int main() {
}

Problematic AST:

|-RecordDecl 0x643013d9a6d8 <1.c:1:9, line:5:1> line:1:16 struct aaa definition
| |-EnumDecl 0x643013d9a780 <line:2:5, line:4:5> line:2:5
| | `-EnumConstantDecl 0x643013d9a850 <line:3:9, col:15> col:9 bar 'int'
| |   `-IntegerLiteral 0x643013d9a830 <col:15> 'int' 1
| `-FieldDecl 0x643013d9a8f0 <line:2:5, line:4:7> col:7 foo 'enum (anonymous enum at 1.c:2:5)':'enum aaa::(anonymous at 1.c:2:5)'

Error:

panic: cannot decode: &ast.EnumDecl{Addr:0x643013d9a780, Pos:ast.Position{File:"1.c", Line:2, LineEnd:4, Column:5, ColumnEnd:5, StringValue:""}, Position2:" line:2:5", Name:"", ChildNodes:[]ast.Node{(*ast.EnumConstantDecl)(0xc4200b32c0)}}

goroutine 1 [running]:
github.com/elliotchance/c2go/program.NewStruct(0xc42016c0b0, 0x7118e8)
	c2go/program/struct.go:46 +0x64e

starius avatar Jan 11 '18 23:01 starius