OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [cpp0x/] [noexcept03.C] - Blame information for rev 715

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
// Runtime test for noexcept-specification.
2
// { dg-options "-std=c++0x -Wnoexcept" }
3
// { dg-do run }
4
 
5
#include 
6
#include 
7
 
8
void my_terminate ()
9
{
10
  std::exit (0);
11
}
12
 
13
void my_unexpected ()
14
{
15
  throw;
16
}
17
 
18
void g() { throw 1; }
19
void (*p)() = g;
20
void f () noexcept (false)
21
{
22
  p();
23
}
24
 
25
template 
26
void f(T) noexcept (noexcept (T())) // { dg-warning "false" }
27
{
28
  p();
29
}
30
 
31
template 
32
void f2(T a) noexcept (noexcept (f (a)))
33
{
34
  f(a);
35
}
36
 
37
struct A { A() { } };           // { dg-warning "does not throw" }
38
 
39
int main()
40
{
41
  // noexcept(false) allows throw.
42
  try { f(); } catch (int) { }
43
  // noexcept(noexcept(A())) == noexcept(false).
44
  try { f(A()); } catch (int) { }
45
  try { f2(A()); } catch (int) { }
46
 
47
  std::set_terminate (my_terminate);
48
  // noexcept(noexcept(int())) == noexcept(true).
49
  try { f2(1); } catch (...) { }
50
  return 1;
51
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.