Skip to content

Commit

Permalink
Merge pull request #4629 from 9rnsr/fix11003
Browse files Browse the repository at this point in the history
Partial fix Issue 11003 - Improve .di generation
  • Loading branch information
MartinNowak committed May 6, 2015
2 parents 898fc43 + c9972ca commit 13d6970
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/hdrgen.c
Expand Up @@ -1412,6 +1412,34 @@ class PrettyPrintVisitor : public Visitor
hgs->tpltMember--;
return true;
}
if (VarDeclaration *vd = onemember->isVarDeclaration())
{
if (d->constraint)
return false;

StorageClassDeclaration::stcToCBuffer(buf, vd->storage_class);
if (vd->type)
typeToBuffer(vd->type, vd->ident);
else
buf->writestring(vd->ident->toChars());

buf->writeByte('(');
visitTemplateParameters(hgs->ddoc ? d->origParameters : d->parameters);
buf->writeByte(')');

if (vd->init)
{
buf->writestring(" = ");
ExpInitializer *ie = vd->init->isExpInitializer();
if (ie && (ie->exp->op == TOKconstruct || ie->exp->op == TOKblit))
((AssignExp *)ie->exp)->e2->accept(this);
else
vd->init->accept(this);
}
buf->writeByte(';');
buf->writenl();
return true;
}

return false;
}
Expand Down
14 changes: 14 additions & 0 deletions test/compilable/extra-files/header2.d
Expand Up @@ -74,6 +74,20 @@ template MyClass4(T)
class MyClass4 {}
}

enum isInt(T) = is(T == int);
enum bool isString(T) = is(T == string);
static immutable typeName(T) = T.stringof;
int storageFor(T) = 0;

template templateVariableFoo(T)
{
enum int templateVariableFoo = T.stringof.length;
}
template templateVariableBar(T) if (is(T == int))
{
enum int templateVariableBar = T.stringof.length;
}

auto flit = 3 / 2.0;

// 11217
Expand Down
9 changes: 9 additions & 0 deletions test/compilable/extra-files/header2.di
Expand Up @@ -62,6 +62,15 @@ template MyClass4(T) if (is(typeof(T.subtype)))
{
}
}
enum isInt(T) = is(T == int);
enum bool isString(T) = is(T == string);
static immutable typeName(T) = T.stringof;
int storageFor(T) = 0;
enum int templateVariableFoo(T) = T.stringof.length;
template templateVariableBar(T) if (is(T == int))
{
enum int templateVariableBar = T.stringof.length;
}
auto flit = 3 / 2.00000;
void foo11217()(const int[] arr)
{
Expand Down
9 changes: 9 additions & 0 deletions test/compilable/extra-files/header2i.di
Expand Up @@ -75,6 +75,15 @@ template MyClass4(T) if (is(typeof(T.subtype)))
{
}
}
enum isInt(T) = is(T == int);
enum bool isString(T) = is(T == string);
static immutable typeName(T) = T.stringof;
int storageFor(T) = 0;
enum int templateVariableFoo(T) = T.stringof.length;
template templateVariableBar(T) if (is(T == int))
{
enum int templateVariableBar = T.stringof.length;
}
auto flit = 3 / 2.00000;
void foo11217()(const int[] arr)
{
Expand Down

0 comments on commit 13d6970

Please sign in to comment.