-
-
Notifications
You must be signed in to change notification settings - Fork 606
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix Issue 10920 - template instantiation order dependent link failure…
… problem
- Loading branch information
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module imports.link10920a; | ||
|
||
struct FormatSpec(C) | ||
{ | ||
void func() {} | ||
} | ||
|
||
struct BitArray | ||
{ | ||
auto toString() | ||
{ | ||
// An auto function may runs semantic3 to calculate return type, | ||
// even if it's non-root symbol. | ||
// But inside the function body, all instantiations should be treated | ||
// as speculative. | ||
FormatSpec!char fs; | ||
fs.func(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// PERMUTE_ARGS: -version=A | ||
|
||
// It's imported but won't be linked. | ||
import imports.link10920a; | ||
|
||
void main() | ||
{ | ||
BitArray ba; | ||
version(A) | ||
{ | ||
// Run semantic3 of BitArray.toString() | ||
// before the FormatSpec instantiation in main(). | ||
pragma(msg, typeof(ba.toString())); | ||
} | ||
|
||
// The instance codegen should be run always, unrelated with -version=A. | ||
FormatSpec!char fs; | ||
fs.func(); | ||
} |