mirror of
https://github.com/dlang/dmd.git
synced 2025-04-25 20:50:41 +03:00
This commit is contained in:
parent
649223bff5
commit
dce0ebac9b
2 changed files with 18 additions and 1 deletions
|
@ -119,7 +119,7 @@ public:
|
|||
|
||||
override void visit(ArrayLiteralExp e)
|
||||
{
|
||||
if (e.type.ty != Tarray || !e.elements || !e.elements.length || e.onstack)
|
||||
if (e.type.toBasetype().isTypeSArray() || !e.elements || !e.elements.length || e.onstack)
|
||||
return;
|
||||
if (setGC(e, "this array literal"))
|
||||
return;
|
||||
|
|
|
@ -94,3 +94,20 @@ int[] bar13702(bool b) @nogc
|
|||
auto aux = 1 ~ [2]; // error
|
||||
return aux;
|
||||
}
|
||||
|
||||
/********** Enum and pointer types ***************/
|
||||
// https://github.com/dlang/dmd/issues/21052
|
||||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/nogc3.d(111): Error: this array literal causes a GC allocation in `@nogc` function `f`
|
||||
fail_compilation/nogc3.d(112): Error: this array literal causes a GC allocation in `@nogc` function `f`
|
||||
---
|
||||
*/
|
||||
|
||||
void f() @nogc
|
||||
{
|
||||
enum DA : int[] { a = [1,2,3] }
|
||||
DA da = DA.a;
|
||||
int i = *cast(int*)cast(char[4])['0', '0', '0', '0'];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue