aboutsummaryrefslogtreecommitdiff
path: root/test/SemaTemplate
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2012-05-03 16:53:59 +0000
committerDimitry Andric <dim@FreeBSD.org>2012-05-03 16:53:59 +0000
commit6b9a6e390fbb92c40eb9c6ac9e7abbd88dd7a767 (patch)
tree2e51705e103e92c7be1b21e8bd8ffd5b5d0e4d52 /test/SemaTemplate
parentdbe13110f59f48b4dbb7552b3ac2935acdeece7f (diff)
downloadsrc-6b9a6e390fbb92c40eb9c6ac9e7abbd88dd7a767.tar.gz
src-6b9a6e390fbb92c40eb9c6ac9e7abbd88dd7a767.zip
Vendor import of clang release_31 branch r155985:vendor/clang/clang-release_31-r155985
Notes
Notes: svn path=/vendor/clang/dist/; revision=234973 svn path=/vendor/clang/clang-release_31-r155985/; revision=234974; tag=vendor/clang/clang-release_31-r155985
Diffstat (limited to 'test/SemaTemplate')
-rw-r--r--test/SemaTemplate/default-expr-arguments.cpp11
-rw-r--r--test/SemaTemplate/dependent-names.cpp32
-rw-r--r--test/SemaTemplate/instantiate-declref.cpp10
-rw-r--r--test/SemaTemplate/instantiate-exception-spec-cxx11.cpp133
4 files changed, 186 insertions, 0 deletions
diff --git a/test/SemaTemplate/default-expr-arguments.cpp b/test/SemaTemplate/default-expr-arguments.cpp
index 5d301be2fb13..1eefa9f8956b 100644
--- a/test/SemaTemplate/default-expr-arguments.cpp
+++ b/test/SemaTemplate/default-expr-arguments.cpp
@@ -292,3 +292,14 @@ namespace PR8401 {
f();
}
}
+
+namespace PR12581 {
+ const int a = 0;
+ template < typename > struct A;
+ template < typename MatrixType, int =
+ A < MatrixType >::Flags ? : A < MatrixType >::Flags & a > class B;
+ void
+ fn1 ()
+ {
+ }
+}
diff --git a/test/SemaTemplate/dependent-names.cpp b/test/SemaTemplate/dependent-names.cpp
index 36e1ad8f17f0..924bad9257b9 100644
--- a/test/SemaTemplate/dependent-names.cpp
+++ b/test/SemaTemplate/dependent-names.cpp
@@ -292,3 +292,35 @@ namespace PR10187 {
template void f<S>(); // expected-note {{here}}
}
}
+
+namespace rdar11242625 {
+
+template <typename T>
+struct Main {
+ struct default_names {
+ typedef int id;
+ };
+
+ template <typename T2 = typename default_names::id>
+ struct TS {
+ T2 q;
+ };
+};
+
+struct Sub : public Main<int> {
+ TS<> ff;
+};
+
+int arr[sizeof(Sub)];
+
+}
+
+namespace PR11421 {
+template < unsigned > struct X {
+ static const unsigned dimension = 3;
+ template<unsigned dim=dimension>
+ struct Y: Y<dim> { }; // expected-error {{incomplete type}} expected-note {{is not complete until the closing}}
+};
+typedef X<3> X3;
+X3::Y<>::iterator it; // expected-note {{requested here}}
+}
diff --git a/test/SemaTemplate/instantiate-declref.cpp b/test/SemaTemplate/instantiate-declref.cpp
index ced56dfc6abc..7d4a2ff6a3ff 100644
--- a/test/SemaTemplate/instantiate-declref.cpp
+++ b/test/SemaTemplate/instantiate-declref.cpp
@@ -105,3 +105,13 @@ namespace test1 {
}
template void f(int const &); // expected-note {{requested here}}
}
+
+namespace test2 {
+ template<typename T> void f() {
+ T::error; // expected-error {{no member}}
+ }
+ void g() {
+ // This counts as an odr-use, so should trigger the instantiation of f<int>.
+ (void)&f<int>; // expected-note {{here}}
+ }
+}
diff --git a/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp b/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
new file mode 100644
index 000000000000..8a6f9efa68ec
--- /dev/null
+++ b/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
@@ -0,0 +1,133 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -ftemplate-depth 16 -fcxx-exceptions -fexceptions %s
+
+// DR1330: an exception specification for a function template is only
+// instantiated when it is needed.
+
+template<typename T> void f1(T*) throw(T); // expected-error{{incomplete type 'Incomplete' is not allowed in exception specification}}
+struct Incomplete; // expected-note{{forward}}
+
+void test_f1(Incomplete *incomplete_p, int *int_p) {
+ f1(int_p);
+ f1(incomplete_p); // expected-note{{instantiation of exception spec}}
+}
+
+template<typename T> struct A {
+ template<typename U> struct B {
+ static void f() noexcept(A<U>().n);
+ };
+
+ constexpr A() : n(true) {}
+ bool n;
+};
+
+static_assert(noexcept(A<int>::B<char>::f()), "");
+
+template<unsigned N> struct S {
+ static void recurse() noexcept(noexcept(S<N+1>::recurse())); // \
+ // expected-error {{no member named 'recurse'}} \
+ // expected-note 9{{instantiation of exception spec}}
+};
+decltype(S<0>::recurse()) *pVoid1 = 0; // ok, exception spec not needed
+decltype(&S<0>::recurse) pFn = 0; // ok, exception spec not needed
+
+template<> struct S<10> {};
+void (*pFn2)() noexcept = &S<0>::recurse; // expected-note {{instantiation of exception spec}} expected-error {{not superset}}
+
+
+template<typename T> T go(T a) noexcept(noexcept(go(a))); // \
+// expected-error 16{{call to function 'go' that is neither visible}} \
+// expected-note 16{{'go' should be declared prior to the call site}} \
+// expected-error {{recursive template instantiation exceeded maximum depth of 16}} \
+// expected-error {{use of undeclared identifier 'go'}} \
+
+void f() {
+ int k = go(0); // \
+ // expected-note {{in instantiation of exception specification for 'go<int>' requested here}}
+}
+
+
+namespace dr1330_example {
+ template <class T> struct A {
+ void f(...) throw (typename T::X); // expected-error {{'int'}}
+ void f(int);
+ };
+
+ int main() {
+ A<int>().f(42);
+ }
+
+ int test2() {
+ struct S {
+ template<typename T>
+ static int f() noexcept(noexcept(A<T>().f("boo!"))) { return 0; } // \
+ // expected-note {{instantiation of exception spec}}
+ typedef decltype(f<S>()) X;
+ };
+ S().f<S>(); // ok
+ S().f<int>(); // expected-note {{instantiation of exception spec}}
+ }
+}
+
+namespace core_19754_example {
+ template<typename T> T declval() noexcept;
+
+ template<typename T, typename = decltype(T(declval<T&&>()))>
+ struct is_movable { static const bool value = true; };
+
+ template<typename T>
+ struct wrap {
+ T val;
+ void irrelevant(wrap &p) noexcept(is_movable<T>::value);
+ };
+
+ template<typename T>
+ struct base {
+ base() {}
+ base(const typename T::type1 &);
+ base(const typename T::type2 &);
+ };
+
+ template<typename T>
+ struct type1 {
+ wrap<typename T::base> base;
+ };
+
+ template<typename T>
+ struct type2 {
+ wrap<typename T::base> base;
+ };
+
+ struct types {
+ typedef base<types> base;
+ typedef type1<types> type1;
+ typedef type2<types> type2;
+ };
+
+ base<types> val = base<types>();
+}
+
+namespace pr9485 {
+ template <typename T> void f1(T) throw(typename T::exception); // expected-note {{candidate}}
+ template <typename T> void f1(T, int = 0) throw(typename T::noitpecxe); // expected-note {{candidate}}
+
+ template <typename T> void f2(T) noexcept(T::throws); // expected-note {{candidate}}
+ template <typename T> void f2(T, int = 0) noexcept(T::sworht); // expected-note {{candidate}}
+
+ void test() {
+ f1(0); // expected-error {{ambiguous}}
+ f2(0); // expected-error {{ambiguous}}
+ }
+}
+
+struct Exc1 { char c[4]; };
+struct Exc2 { double x, y, z; };
+struct Base {
+ virtual void f() noexcept; // expected-note {{overridden}}
+};
+template<typename T> struct Derived : Base {
+ void f() noexcept (sizeof(T) == 4); // expected-error {{is more lax}}
+ void g() noexcept (T::error);
+};
+
+Derived<Exc1> d1; // ok
+Derived<Exc2> d2; // expected-note {{in instantiation of}}