Skip to content

Commit

Permalink
fix Issue 19735 - Error: variable extern symbols cannot have initiali…
Browse files Browse the repository at this point in the history
…zers
  • Loading branch information
ibuclaw committed Mar 13, 2019
1 parent df7e152 commit 792742d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/dmd/semantic3.d
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,9 @@ private extern(C++) final class Semantic3Visitor : Visitor
sc2.sw = null;
sc2.fes = funcdecl.fes;
sc2.linkage = LINK.d;
sc2.stc &= ~(STC.auto_ | STC.scope_ | STC.static_ | STC.abstract_ | STC.deprecated_ | STC.override_ | STC.TYPECTOR | STC.final_ | STC.tls | STC.gshared | STC.ref_ | STC.return_ | STC.property | STC.nothrow_ | STC.pure_ | STC.safe | STC.trusted | STC.system);
sc2.stc &= ~(STC.auto_ | STC.scope_ | STC.static_ | STC.extern_ | STC.abstract_ | STC.deprecated_ | STC.override_ |
STC.TYPECTOR | STC.final_ | STC.tls | STC.gshared | STC.ref_ | STC.return_ | STC.property |
STC.nothrow_ | STC.pure_ | STC.safe | STC.trusted | STC.system);
sc2.protection = Prot(Prot.Kind.public_);
sc2.explicitProtection = 0;
sc2.aligndecl = null;
Expand Down
22 changes: 22 additions & 0 deletions test/runnable/test19735.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// https://issues.dlang.org/show_bug.cgi?id=19735

extern int test1(int par)
{
int var = 42;
return var + par;
}

extern
{
int test2(int par)
{
int var = 42;
return var + par;
}
}

void main()
{
assert(test1(1) == test2(1));
}

0 comments on commit 792742d

Please sign in to comment.