Skip to content

Commit

Permalink
Merge pull request #7687 from quickfur/issue18232
Browse files Browse the repository at this point in the history
Fix issue 18232: local vars in union member functions needs initializer.
merged-on-behalf-of: Sebastian Wilzbach <sebi.wilzbach@gmail.com>
  • Loading branch information
dlang-bot committed Jan 15, 2018
2 parents 97105b8 + aa3ca3e commit 4cf228e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/dmd/dsymbolsem.d
Expand Up @@ -785,7 +785,6 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
bool isBlit = false;
d_uns64 sz;
if (!dsym._init &&
!sc.inunion &&
!(dsym.storage_class & (STC.static_ | STC.gshared | STC.extern_)) &&
fd &&
(!(dsym.storage_class & (STC.field | STC.in_ | STC.foreach_ | STC.parameter | STC.result)) ||
Expand Down
19 changes: 19 additions & 0 deletions test/runnable/xtest46.d
Expand Up @@ -7987,6 +7987,24 @@ struct S17915(T)
T owner;
}

void test18232()
{
static struct Canary
{
int x = 0x900D_900D;
}
union U
{
Canary method()
{
Canary c;
return c;
}
}
U u;
assert(u.method() == Canary.init);
}

/***************************************************/

int main()
Expand Down Expand Up @@ -8308,6 +8326,7 @@ int main()
test16408();
test17349();
test17915();
test18232();

printf("Success\n");
return 0;
Expand Down

0 comments on commit 4cf228e

Please sign in to comment.