view gcc/testsuite/gdc.test/fail_compilation/fail13120.d @ 152:2b5abeee2509

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
parents 1830386684a0
children
line wrap: on
line source

/*
TEST_OUTPUT:
---
fail_compilation/fail13120.d(13): Error: pure delegate 'fail13120.g1.__foreachbody2' cannot call impure function 'fail13120.f1'
fail_compilation/fail13120.d(13): Error: @nogc delegate 'fail13120.g1.__foreachbody2' cannot call non-@nogc function 'fail13120.f1'
---
*/
void f1() {}

void g1(char[] s) pure @nogc
{
    foreach (dchar dc; s)
        f1();
}

/*
TEST_OUTPUT:
---
fail_compilation/fail13120.d(34): Error: pure function 'fail13120.h2' cannot call impure function 'fail13120.g2!().g2'
fail_compilation/fail13120.d(34): Error: @safe function 'fail13120.h2' cannot call @system function 'fail13120.g2!().g2'
fail_compilation/fail13120.d(34): Error: @nogc function 'fail13120.h2' cannot call non-@nogc function 'fail13120.g2!().g2'
---
*/
void f2() {}

void g2()(char[] s)
{
    foreach (dchar dc; s)
        f2();
}

void h2() @safe pure @nogc
{
    g2(null);
}