Skip to content

Commit

Permalink
Regression: translating typedef of array.
Browse files Browse the repository at this point in the history
  • Loading branch information
ciechowoj committed Sep 26, 2016
1 parent b09b2d3 commit 42a5f02
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dstep/translator/MacroDefinition.d
Expand Up @@ -1855,7 +1855,7 @@ Expression parseExpr(ref Token[] tokens, Cursor[string] table, bool defined)
if (auto expr = parseTokenConcat(tokens))
return expr;

if (auto expr = parseCondExpr(tokens, table))
if (auto expr = parseCondExpr(tokens, table, defined))
return expr;

return null;
Expand Down
3 changes: 2 additions & 1 deletion dstep/translator/Translator.d
Expand Up @@ -240,7 +240,8 @@ class Translator
if (child.kind == CXCursorKind.CXCursor_TypeRef)
child = child.referenced;

if (child.kind != CXCursorKind.CXCursor_ParmDecl)
if (child.isDeclaration &&
child.kind != CXCursorKind.CXCursor_ParmDecl)
{
if (child.spelling == cursor.spelling ||
child.spelling == "" ||
Expand Down
15 changes: 15 additions & 0 deletions unit_tests/UnitTests.d
Expand Up @@ -432,6 +432,8 @@ extern (C):
extern __gshared int a;
D", options);

}

// Translate function pointer type with unnamed parameter.
unittest
{
Expand Down Expand Up @@ -464,6 +466,19 @@ D");

}

// Translate array typedef.
unittest
{
assertTranslates(q"C
typedef double foo[2];
C", q"D
extern (C):
alias double[2] foo;
D");

}

// Reduce typedefs when underlying type is alias of primitive type.
unittest
{
Expand Down

0 comments on commit 42a5f02

Please sign in to comment.