diff --git a/tests/struct.c b/tests/struct.c index 1e73e9c02..c295534cb 100644 --- a/tests/struct.c +++ b/tests/struct.c @@ -352,10 +352,25 @@ const Point2 p2[] = { { .y = 4, .x = 5 } }; const Point2* getPoint(int index) { return &(p2[index]); } +typedef unsigned char pcre_uchar; +typedef struct spu { + pcre_uchar *hvm; +} spu; + +void pointer_arithm_in_struct() { + pcre_uchar str[] = "abcd"; + spu s; + spu *ps = &s; + ps->hvm = &str[1]; + is_true(ps->hvm == &str[1]); + ps->hvm += 2; + is_true(ps->hvm == &str[3]); + +} int main() { - plan(69); + plan(71); struct programming variable; char *s = "Programming in Software Development."; @@ -614,5 +629,7 @@ int main() struct_inside_union(); + pointer_arithm_in_struct(); + done_testing(); } diff --git a/transpiler/operators.go b/transpiler/operators.go index 27c55c2eb..aa7beca8c 100644 --- a/transpiler/operators.go +++ b/transpiler/operators.go @@ -323,13 +323,8 @@ func transpileCompoundAssignOperator( return nil, "", nil, nil, fmt.Errorf("Expr is nil") } preStmts, postStmts = combinePreAndPostStmts(preStmts, postStmts, newPre, newPost) - var name string - name, err = getName(p, n.Children()[0]) - if err != nil { - return nil, "", nil, nil, err - } v = &goast.BinaryExpr{ - X: goast.NewIdent(name), + X: left, Op: token.ASSIGN, Y: v, }