//===----------------------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <locale>

// template <> class ctype<char>

// ~ctype();

#include <locale>
#include <cassert>
#include <new>

unsigned delete_called = 0;

void* operator new[](size_t sz)
{
    return operator new(sz);
}

void operator delete[](void* p) throw()
{
    operator delete(p);
    ++delete_called;
}

int main()
{
    {
        delete_called = 0;
        std::locale l(std::locale::classic(), new std::ctype<char>);
        assert(delete_called == 0);
    }
    assert(delete_called == 0);
    {
        std::ctype<char>::mask table[256];
        delete_called = 0;
        std::locale l(std::locale::classic(), new std::ctype<char>(table));
        assert(delete_called == 0);
    }
    assert(delete_called == 0);
    {
        delete_called = 0;
        std::locale l(std::locale::classic(),
            new std::ctype<char>(new std::ctype<char>::mask[256], true));
        assert(delete_called == 0);
    }
    assert(delete_called == 1);
}

//===----------------------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <locale>

// template <> class ctype<char>

// ~ctype();

#include <locale>
#include <cassert>
#include <new>

unsigned delete_called = 0;

void* operator new[](size_t sz) throw(std::bad_alloc)
{
    return operator new(sz);
}

void operator delete[](void* p) throw()
{
    operator delete(p);
    ++delete_called;
}

int main()
{
    {
        delete_called = 0;
        std::locale l(std::locale::classic(), new std::ctype<char>);
        assert(delete_called == 0);
    }
    assert(delete_called == 0);
    {
        std::ctype<char>::mask table[256];
        delete_called = 0;
        std::locale l(std::locale::classic(), new std::ctype<char>(table));
        assert(delete_called == 0);
    }
    assert(delete_called == 0);
    {
        delete_called = 0;
        std::locale l(std::locale::classic(),
            new std::ctype<char>(new std::ctype<char>::mask[256], true));
        assert(delete_called == 0);
    }
    assert(delete_called == 1);
}

Fix warning in test - missing exception specifier for overload of operator new
Fix warning in test - missing exception specifier for overload of operator new

git-svn-id: 756ef344af921d95d562d9e9f9389127a89a6314@212723 91177308-0d34-0410-b5e6-96231b3b80d8
