These tests got moved to test/Programs/SingleSource/Regression/C++/EH

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8785 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2003-09-30 18:57:56 +00:00
parent 39882e847a
commit 3a7fbe2e3e
7 changed files with 0 additions and 220 deletions

View File

@ -1,23 +0,0 @@
#include <stdio.h>
static int c;
struct A {
A() { ++c; }
A(const A&) { ++c; }
~A() { --c; }
};
struct B {
A a;
B() { A a; throw 1; }
};
int main() {
try {
B b;
} catch (...) {}
if (!c) printf("All ok!\n");
return c;
}

View File

@ -1,13 +0,0 @@
// This testcase doesn't actually DO any EH
#include <stdio.h>
static void foo() {}
int main() {
try {
foo();
} catch(...) {
return 1;
}
printf("All ok\n");
return 0;
}

View File

@ -1,51 +0,0 @@
// This tests that exception specifications interact properly with unexpected
// handlers.
#include <exception>
#include <stdio.h>
#include <stdlib.h>
static void TerminateHandler() {
printf("std::terminate called\n");
exit(1);
}
static void UnexpectedHandler1() {
printf("std::unexpected called: throwing a double\n");
throw 1.0;
}
static void UnexpectedHandler2() {
printf("std::unexpected called: throwing an int!\n");
throw 1;
}
void test(bool Int) throw (double) {
if (Int) {
printf("Throwing an int from a function which only allows doubles!\n");
throw 1;
} else {
printf("Throwing a double from a function which allows doubles!\n");
throw 1.0;
}
}
int main() {
try {
test(false);
} catch (double D) {
printf("Double successfully caught!\n");
}
std::set_terminate(TerminateHandler);
std::set_unexpected(UnexpectedHandler1);
try {
test(true);
} catch (double D) {
printf("Double successfully caught!\n");
}
std::set_unexpected(UnexpectedHandler2);
test(true);
}

View File

@ -1,55 +0,0 @@
#include <stdio.h>
static unsigned NumAs = 0;
struct A {
unsigned ANum;
A() : ANum(NumAs++) { printf("Created A #%d\n", ANum); }
A(const A &a) : ANum(NumAs++) { printf("Copy Created A #%d\n", ANum); }
~A() { printf("Destroyed A #%d\n", ANum); }
};
static bool ShouldThrow = false;
int throws()
try
{
if (ShouldThrow) throw 7; return 123;
} catch (...) {
printf("'throws' threw an exception: rethrowing!\n");
throw;
}
struct B {
A a0, a1, a2;
int i;
A a3, a4;
B();
~B() { printf("B destructor!\n"); }
};
B::B()
try
: i(throws())
{
printf("In B constructor!\n");
}
catch (int i) {
printf("In B catch block with int %d: auto rethrowing\n", i);
}
int main() {
{
B b; // Shouldn't throw.
}
try {
ShouldThrow = true;
B b;
} catch (...) {
printf("Caught exception!\n");
}
}

View File

@ -1,25 +0,0 @@
#include <stdio.h>
int throws() {
printf("Throwing int\n");
throw 16;
};
int callsthrows() {
try {
throws();
} catch (...) {
printf("Caught something, rethrowing...\n");
throw;
}
}
int main() {
try {
callsthrows();
} catch (int i) {
printf("Caught int: %d\n", i);
return i-16;
}
return 1;
}

View File

@ -1,13 +0,0 @@
// Test throwing a constant int
#include <stdio.h>
static void foo() { throw 5; }
int main() {
try {
foo();
} catch (...) {
printf("All ok\n");
return 0;
}
return 1;
}

View File

@ -1,40 +0,0 @@
// This tests hard situations for throwing, including the case where an
// exception is active in more than one handler at a time (ie, it needs
// refcounting)
#include <cstdio>
struct foo {
int i;
foo() : i(1) { }
foo(const foo&) : i(2) {}
};
int callee(unsigned i) {
if (i < 3) throw (int)i;
if (i < 6) throw 1.0;
if (i < 9) throw foo();
return 0;
}
void rethrow() {
throw;
}
int main() {
for (unsigned i = 0; i < 10; ++i) {
try {
return callee(i);
} catch (foo &F) {
try {
rethrow();
} catch (foo &F) {
std::printf("%d: 3\n", i);
}
} catch (int) {
std::printf("%d: 1\n", i);
} catch (...) {
std::printf("%d: 2\n", i);
}
}
}