Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3993 from klickverbot/2.066
Fix Issue 13478 - [REG2.066] Templates not emitted when also referenced in speculative contexts
- Loading branch information
Showing
4 changed files
with
31 additions
and
1 deletion.
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,8 @@ | ||
module imports.template13478a; | ||
|
||
bool foo(T)() { | ||
// Make sure this is not inlined so template13478.o actually | ||
// needs to reference it. | ||
asm { nop; } | ||
return false; | ||
} |
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,7 @@ | ||
import imports.template13478b; | ||
|
||
import imports.template13478a; | ||
|
||
// Note that foo is only used in the template constraint here. | ||
T barImpl(T)(T t) if (is(typeof({ foo!T(); }))) { return t; } | ||
int bar(int a) { return barImpl(a); } |
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,10 @@ | ||
/// Tests emission of templates also referenced in speculative contexts. | ||
/// Failure triggered with -inline. | ||
module template13478; | ||
|
||
import imports.template13478a; | ||
import imports.template13478b; | ||
|
||
int main() { | ||
return foo!int(); | ||
} |