Commit 1acc3340 by Janis Johnson Committed by Janis Johnson

* g++.dg/cpp0x/nullptr21.c: Remove printfs, make self-checking.

From-SVN: r189870
parent b0c724c2
2012-07-25 Janis Johnson <janisjo@codesourcery.com>
* g++.dg/cpp0x/nullptr21.c: Remove printfs, make self-checking.
2012-07-25 Eric Botcazou <ebotcazou@adacore.com> 2012-07-25 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/noreturn5.ad[sb]: New test. * gnat.dg/noreturn5.ad[sb]: New test.
......
...@@ -3,42 +3,53 @@ ...@@ -3,42 +3,53 @@
// Test throw and catch // Test throw and catch
#include <cstdio> extern "C" void abort (void);
typedef decltype(nullptr) nullptr_t; typedef decltype(nullptr) nullptr_t;
int result[2];
void __attribute__((noinline))
foo (int i, int j)
{
result[i] = j;
}
int main() int main()
{ {
try { try {
throw nullptr; throw nullptr;
} catch (void*) { } catch (void*) {
printf("Test 1 Fail"); foo (0, 1);
} catch (bool) { } catch (bool) {
printf("Test 1 Fail"); foo (0, 2);
} catch (int) { } catch (int) {
printf("Test 1 Fail"); foo (0, 3);
} catch (long int) { } catch (long int) {
printf("Test 1 Fail"); foo (0, 4);
} catch (nullptr_t) { } catch (nullptr_t) {
printf("Test 1 OK"); foo (0, 5);
} catch (...) { } catch (...) {
printf("Test 1 Fail"); foo (0, 6);
} // { dg-output "Test 1 OK" } }
nullptr_t mynull = 0; nullptr_t mynull = 0;
try { try {
throw mynull; throw mynull;
} catch (void*) { } catch (void*) {
printf("Test 2 Fail"); foo (1, 1);
} catch (bool) { } catch (bool) {
printf("Test 2 Fail"); foo (1, 2);
} catch (int) { } catch (int) {
printf("Test 2 Fail"); foo (1, 3);
} catch (long int) { } catch (long int) {
printf("Test 2 Fail"); foo (1, 4);
} catch (nullptr_t) { } catch (nullptr_t) {
printf("Test 2 OK"); foo (1, 5);
} catch (...) { } catch (...) {
printf("Test 2 Fail"); foo (1, 6);
} // { dg-output "Test 2 OK" } }
if (result[0] != 5 || result[1] != 5)
abort ();
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment