diff --git a/compiler/test/runnable/nogc.d b/compiler/test/runnable/nogc.d index c9a58b7e744b..c71866fc1995 100644 --- a/compiler/test/runnable/nogc.d +++ b/compiler/test/runnable/nogc.d @@ -68,12 +68,37 @@ void test12936() @nogc /***********************/ +version(none) // Pending future enhancements: +void testIndexedArrayLiteral() @nogc +{ + int i = 2; + int x = [10, 20, 30, 40][i]; + assert(x == 30); + + enum arr = [100, 200, 300, 400][1 .. $]; + assert(arr[i] == 400); +} + +void testArrayLiteralLvalue() +{ + // https://github.com/dlang/dmd/pull/16784 + // Test that this array literal is *not* put on the stack because + // it gets its address taken + static int* getPtr(int i) => &[1, 2, 3][i]; + int* x = getPtr(1); + int* y = getPtr(1); + assert(x != y); +} + +/***********************/ + int main() { test1(); test3032(); test12642(); test12936(); + testArrayLiteralLvalue(); printf("Success\n"); return 0;