p1.cpp revision 60618fa7f88d5162bb5b40988b6b38d4d75d6fc6
1// RUN: %clang_cc1 -std=c++0x -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
2
3// Simple parser tests, dynamic specification.
4
5namespace dyn {
6
7  struct X { };
8
9  struct Y { };
10
11  void f() throw() { }
12
13  void g(int) throw(X) { }
14
15  void h() throw(X, Y) { }
16
17  class Class {
18    void foo() throw (X, Y) { }
19  };
20
21  void (*fptr)() throw();
22
23}
24
25// Simple parser tests, noexcept specification.
26
27namespace noex {
28
29  void f1() noexcept { }
30  void f2() noexcept (true) { }
31  void f3() noexcept (false) { }
32  void f4() noexcept (1 < 2) { }
33
34  class CA1 {
35    void foo() noexcept { }
36    void bar() noexcept (true) { }
37  };
38
39  void (*fptr1)() noexcept;
40  void (*fptr2)() noexcept (true);
41
42}
43
44namespace mix {
45
46  void f() throw(int) noexcept { } // expected-error {{cannot have both}}
47  void g() noexcept throw(int) { } // expected-error {{cannot have both}}
48
49}
50
51// Sema tests, noexcept specification
52
53namespace noex {
54
55  struct A {};
56
57  void g1() noexcept(A()); // expected-error {{not contextually convertible}}
58  void g2(bool b) noexcept(b); // expected-error {{argument to noexcept specifier must be a constant expression}}
59
60}
61