1 // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
5 float &f(int*) const noexcept
;
8 auto g1() noexcept(noexcept(f(ptr
))) -> decltype(f(this->ptr
));
9 auto g2() const noexcept(noexcept(f((*this).ptr
))) -> decltype(f(ptr
));
15 static_assert(!noexcept(a
.g1()), "exception-specification failure");
16 static_assert(noexcept(a
.g2()), "exception-specification failure");
21 template<class T
> auto f(T t
) -> decltype(t
+ g())
25 template auto B::f(int t
) -> decltype(t
+ g());
30 float &f(T
*) const noexcept
;
33 auto g1() noexcept(noexcept(f(ptr
))) -> decltype(f(ptr
));
34 auto g2() const noexcept(noexcept(f(((this))->ptr
))) -> decltype(f(ptr
));
35 auto g3() noexcept(noexcept(f(this->ptr
))) -> decltype(f((*this).ptr
));
36 auto g4() const noexcept(noexcept(f(((this))->ptr
))) -> decltype(f(this->ptr
));
37 auto g5() noexcept(noexcept(this->f(ptr
))) -> decltype(this->f(ptr
));
38 auto g6() const noexcept(noexcept(this->f(((this))->ptr
))) -> decltype(this->f(ptr
));
39 auto g7() noexcept(noexcept(this->f(this->ptr
))) -> decltype(this->f((*this).ptr
));
40 auto g8() const noexcept(noexcept(this->f(((this))->ptr
))) -> decltype(this->f(this->ptr
));
43 void test_C(C
<int> ci
) {
52 static_assert(!noexcept(ci
.g1()), "exception-specification failure");
53 static_assert(noexcept(ci
.g2()), "exception-specification failure");
54 static_assert(!noexcept(ci
.g3()), "exception-specification failure");
55 static_assert(noexcept(ci
.g4()), "exception-specification failure");
56 static_assert(!noexcept(ci
.g5()), "exception-specification failure");
57 static_assert(noexcept(ci
.g6()), "exception-specification failure");
58 static_assert(!noexcept(ci
.g7()), "exception-specification failure");
59 static_assert(noexcept(ci
.g8()), "exception-specification failure");
63 template<typename T
> struct X
{
67 auto g() -> decltype(this->f()) { return f(); }
68 auto g() const -> decltype(this->f()) { return f(); }
70 template struct X
<int>;
76 iter_swap(I x
, I y
) noexcept
;
83 void swap(A
& a
) noexcept(noexcept(iter_swap(&t_
, &a
.t_
)));
96 friend int add_to_v(A
&t
) noexcept(noexcept(v_
+ 42))
111 // FIXME: This should be accepted.
112 static auto f() -> decltype(m
); // expected-error{{'this' cannot be implicitly used in a static member function declaration}}
113 static auto g() -> decltype(this->m
); // expected-error{{'this' cannot be used in a static member function declaration}}
117 static int i() noexcept(noexcept(m
+ 2)); // expected-error{{'this' cannot be implicitly used in a static member function declaration}}
120 auto X1::h() -> decltype(m
) { return 0; } // expected-error{{'this' cannot be implicitly used in a static member function declaration}}
129 auto g(T x
) -> decltype(f(x
)) { return 0; }
142 struct Derived
: Base
{
143 void foo(Derived
& d
) noexcept(noexcept(d
.bar(d
))) {}
147 namespace rdar13473493
{
148 template <typename F
>
152 template <typename
... Args
>
153 auto operator()(Args
&&... args
) const -> decltype(wrapped(args
...)) // expected-note{{candidate template ignored: substitution failure [with Args = <int>]: member 'wrapped' used before its declaration}}
155 return wrapped(args
...);
162 void test(wrap
<int (*)(int)> w
) {
163 w(5); // expected-error{{no matching function for call to object of type 'wrap<int (*)(int)>'}}