Skip to content

Commit

Permalink
Remove unused if statement for "type" as a variable name (#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin8105 authored and elliotchance committed Dec 5, 2017
1 parent ec7dae0 commit af25cba
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
6 changes: 5 additions & 1 deletion tests/operators.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

int main()
{
plan(35);
plan(36);

int i = 10;
signed char j = 1;
Expand Down Expand Up @@ -120,5 +120,9 @@ int main()
is_eq(s1, 2);
is_eq(({ int foo = s1 * 3; foo + 1; }), 7);

diag("Not allowable var name for Go")
int type = 42;
is_eq(type,42);

done_testing();
}
10 changes: 9 additions & 1 deletion tests/struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct xx {

int main()
{
plan(15);
plan(16);

struct programming variable;
char *s = "Programming in Software Development.";
Expand Down Expand Up @@ -116,5 +116,13 @@ int main()
yy.y = 42;
is_eq(yy.y,42);

diag("Not allowable var name for Go")
struct type{
int type;
};
struct type t;
t.type = 42;
is_eq(t.type, 42);

done_testing();
}
6 changes: 0 additions & 6 deletions transpiler/declarations.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,12 +410,6 @@ func transpileVarDecl(p *program.Program, n *ast.VarDecl) (decls []goast.Decl, t
return
}

// TODO: The name of a variable or field cannot be "type"
// https://github.com/elliotchance/c2go/issues/83
if name == "type" {
name = "type_"
}

defaultValue, _, newPre, newPost, err := getDefaultValueForVar(p, n)
if err != nil {
p.AddMessage(p.GenerateErrorMessage(err, n))
Expand Down

0 comments on commit af25cba

Please sign in to comment.