Skip to content

Commit

Permalink
Merge pull request #829 from 9rnsr/fix7754
Browse files Browse the repository at this point in the history
Issue 7754 - static this() in template is stripped during header gen
  • Loading branch information
WalterBright committed Mar 27, 2012
2 parents 58f284e + 5321035 commit 311d170
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/func.c
Original file line number Diff line number Diff line change
Expand Up @@ -3640,7 +3640,7 @@ int StaticCtorDeclaration::addPostInvariant()

void StaticCtorDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
{
if (hgs->hdrgen)
if (hgs->hdrgen && !hgs->tpltMember)
{ buf->writestring("static this();");
buf->writenl();
return;
Expand Down
10 changes: 10 additions & 0 deletions test/compilable/extra-files/test7754-postscript.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

grep -v "D import file generated from" ${RESULTS_DIR}/compilable/test7754.di > ${RESULTS_DIR}/compilable/test7754.di.2
diff --strip-trailing-cr compilable/extra-files/test7754.di ${RESULTS_DIR}/compilable/test7754.di.2
if [ $? -ne 0 ]; then
exit 1;
fi

rm ${RESULTS_DIR}/compilable/test7754.di{,.2}

12 changes: 12 additions & 0 deletions test/compilable/extra-files/test7754.di
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
template Foo(T)
{
struct Foo
{
shared static this()
{
}
static this()
{
}
}
}
15 changes: 15 additions & 0 deletions test/compilable/test7754.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// PERMUTE_ARGS:
// REQUIRED_ARGS: -H -Hdtest_results/compilable
// POST_SCRIPT: compilable/extra-files/test7754-postscript.sh
// REQUIRED_ARGS: -d

struct Foo(T)
{
shared static this()
{
}

static this()
{
}
}

0 comments on commit 311d170

Please sign in to comment.