summaryrefslogtreecommitdiff
path: root/clang/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp
diff options
context:
space:
mode:
authorZancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au>2012-09-24 09:58:17 +1000
committerZancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au>2012-09-24 09:58:17 +1000
commit222e2a7620e6520ffaf4fc4e69d79c18da31542e (patch)
tree7bfbc05bfa3b41c8f9d2e56d53a0bc3e310df239 /clang/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp
parent3d206f03985b50beacae843d880bccdc91a9f424 (diff)
Add the clang library to the repo (with some of my changes, too).
Diffstat (limited to 'clang/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp')
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp101
1 files changed, 101 insertions, 0 deletions
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp
new file mode 100644
index 0000000..030c90c
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp
@@ -0,0 +1,101 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+
+struct A {
+ int &f(int*);
+ float &f(int*) const noexcept;
+
+ int *ptr;
+ auto g1() noexcept(noexcept(f(ptr))) -> decltype(f(this->ptr));
+ auto g2() const noexcept(noexcept(f((*this).ptr))) -> decltype(f(ptr));
+};
+
+void testA(A &a) {
+ int &ir = a.g1();
+ float &fr = a.g2();
+ static_assert(!noexcept(a.g1()), "exception-specification failure");
+ static_assert(noexcept(a.g2()), "exception-specification failure");
+}
+
+struct B {
+ char g();
+ template<class T> auto f(T t) -> decltype(t + g())
+ { return t + g(); }
+};
+
+template auto B::f(int t) -> decltype(t + g());
+
+template<typename T>
+struct C {
+ int &f(T*);
+ float &f(T*) const noexcept;
+
+ T* ptr;
+ auto g1() noexcept(noexcept(f(ptr))) -> decltype(f((*this).ptr));
+ auto g2() const noexcept(noexcept(f(((this))->ptr))) -> decltype(f(ptr));
+};
+
+void test_C(C<int> ci) {
+ int *p = 0;
+ int &ir = ci.g1();
+ float &fr = ci.g2();
+ static_assert(!noexcept(ci.g1()), "exception-specification failure");
+ static_assert(noexcept(ci.g2()), "exception-specification failure");
+}
+
+namespace PR10036 {
+ template <class I>
+ void
+ iter_swap(I x, I y) noexcept;
+
+ template <class T>
+ class A
+ {
+ T t_;
+ public:
+ void swap(A& a) noexcept(noexcept(iter_swap(&t_, &a.t_)));
+ };
+
+ void test() {
+ A<int> i, j;
+ i.swap(j);
+ }
+}
+
+namespace Static {
+ struct X1 {
+ int m;
+ static auto f() -> decltype(m); // expected-error{{'this' cannot be implicitly used in a static member function declaration}}
+ static auto g() -> decltype(this->m); // expected-error{{'this' cannot be used in a static member function declaration}}
+
+ static int h();
+
+ static int i() noexcept(noexcept(m + 2)); // expected-error{{'this' cannot be implicitly used in a static member function declaration}}
+ };
+
+ auto X1::h() -> decltype(m) { return 0; } // expected-error{{'this' cannot be implicitly used in a static member function declaration}}
+
+ template<typename T>
+ struct X2 {
+ int m;
+
+ T f(T*);
+ static T f(int);
+
+ auto g(T x) -> decltype(f(x)) { return 0; }
+ };
+
+ void test_X2() {
+ X2<int>().g(0);
+ }
+}
+
+namespace PR12564 {
+ struct Base {
+ void bar(Base&) {} // unexpected-note {{here}}
+ };
+
+ struct Derived : Base {
+ // FIXME: This should be accepted.
+ void foo(Derived& d) noexcept(noexcept(d.bar(d))) {} // unexpected-error {{cannot bind to a value of unrelated type}}
+ };
+}