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 #6164 from WalterBright/fix15989
fix Issue 15989 - Initializing manifest constants with CTFE allocated…
- Loading branch information
Showing
3 changed files
with
82 additions
and
30 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
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,52 @@ | ||
/* | ||
PERMUTE_ARGS: | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/test15989.d(40): Error: variable test15989.main.ctRegex : Unable to initialize enum with class or pointer to struct. Use static const variable instead. | ||
fail_compilation/test15989.d(49): Error: variable test15989.test.c : Unable to initialize enum with class or pointer to struct. Use static const variable instead. | ||
fail_compilation/test15989.d(50): Error: cannot use non-constant CTFE pointer in an initializer '&[3][0]' | ||
--- | ||
*/ | ||
|
||
// https://issues.dlang.org/show_bug.cgi?id=15989 | ||
|
||
import core.stdc.stdio; | ||
|
||
interface Kickstart{ | ||
bool foo( int ); | ||
} | ||
|
||
class ShiftOr : Kickstart | ||
{ | ||
bool foo( int i ) | ||
{ | ||
printf("i = %d\n", i); | ||
return false; | ||
} | ||
} | ||
|
||
struct Regex | ||
{ | ||
Kickstart kickstart; | ||
} | ||
|
||
Regex regex() | ||
{ | ||
return Regex(new ShiftOr()); | ||
} | ||
|
||
void main() | ||
{ | ||
enum ctRegex = regex(); | ||
Regex r = ctRegex; | ||
r.kickstart.foo(7); | ||
} | ||
|
||
class C { } | ||
|
||
void test() | ||
{ | ||
enum c = new C(); | ||
enum pi = new int(3); | ||
} | ||
|