view gcc/testsuite/gdc.test/fail_compilation/fail2456.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/fail2456.d(14): Error: cannot put `scope(success)` statement inside finally block
---
*/
void test_success()
{
    try
    {
    }
    finally
    {
        scope(success) {}           // NG
    }
}

/*
TEST_OUTPUT:
---
fail_compilation/fail2456.d(31): Error: cannot put `scope(failure)` statement inside finally block
---
*/
void test_failure()
{
    try
    {
    }
    finally
    {
        scope(failure) {}           // NG
    }
}

/*
TEST_OUTPUT:
---
---
*/
void test_exit()
{
    try
    {
    }
    finally
    {
        scope(exit) {}              // OK
    }
}

/*
TEST_OUTPUT:
---
fail_compilation/fail2456.d(64): Error: cannot put `scope(success)` statement inside `scope(success)`
fail_compilation/fail2456.d(65): Error: cannot put `scope(failure)` statement inside `scope(success)`
fail_compilation/fail2456.d(78): Error: cannot put `scope(success)` statement inside `scope(exit)`
fail_compilation/fail2456.d(79): Error: cannot put `scope(failure)` statement inside `scope(exit)`
---
*/
void test2456a()
{
    scope(success)
    {
        scope(success) {}   // NG
        scope(failure) {}   // NG
        scope(exit) {}      // OK
    }

    scope(failure)
    {
        scope(success) {}   // OK
        scope(failure) {}   // OK
        scope(exit) {}      // OK
    }

    scope(exit)
    {
        scope(success) {}   // NG
        scope(failure) {}   // NG
        scope(exit) {}      // OK
    }
}

/*
TEST_OUTPUT:
---
fail_compilation/fail2456.d(96): Error: cannot put catch statement inside `scope(success)`
fail_compilation/fail2456.d(108): Error: cannot put catch statement inside `scope(exit)`
---
*/
void test2456b()
{
    scope(success)
    {
        try {}
        catch (Throwable) {}    // NG
    }

    scope(failure)
    {
        try {}
        catch (Throwable) {}    // OK
    }

    scope(exit)
    {
        try {}
        catch (Throwable) {}    // NG
    }
}