aboutsummaryrefslogtreecommitdiff
path: root/test/CXX/temp
diff options
context:
space:
mode:
Diffstat (limited to 'test/CXX/temp')
-rw-r--r--test/CXX/temp/temp.decls/temp.friend/p1.cpp3
-rw-r--r--test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp43
-rw-r--r--test/CXX/temp/temp.names/p3-0x.cpp12
-rw-r--r--test/CXX/temp/temp.spec/p5.cpp2
-rw-r--r--test/CXX/temp/temp.spec/temp.expl.spec/p14.cpp2
-rw-r--r--test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp8
-rw-r--r--test/CXX/temp/temp.spec/temp.explicit/p12.cpp49
-rw-r--r--test/CXX/temp/temp.spec/temp.explicit/p9-linkage.cpp2
8 files changed, 113 insertions, 8 deletions
diff --git a/test/CXX/temp/temp.decls/temp.friend/p1.cpp b/test/CXX/temp/temp.decls/temp.friend/p1.cpp
index 63f569be0861..640d03d4c96f 100644
--- a/test/CXX/temp/temp.decls/temp.friend/p1.cpp
+++ b/test/CXX/temp/temp.decls/temp.friend/p1.cpp
@@ -302,6 +302,7 @@ namespace test14 {
};
template <class T> class B {
+ public:
void foo() { return A<long>::foo(); } // expected-error {{'foo' is a private member of 'test14::A<long>'}}
};
@@ -320,10 +321,12 @@ namespace test15 {
};
template <class T> class B {
+ public:
void foo() { return A<long>::foo(); } // expected-error {{'foo' is a private member of 'test15::A<long>'}}
};
template <> class B<float> {
+ public:
void foo() { return A<float>::foo(); }
template <class U> void bar(U u) {
(void) A<float>::foo();
diff --git a/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp b/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp
index 21aa24fb522d..485068e6486a 100644
--- a/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp
+++ b/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp
@@ -249,3 +249,46 @@ namespace PR10230 {
int (&ir3)[3] = s<int>().f<int, float, double>();
}
}
+
+namespace PR13386 {
+ template<typename...> struct tuple {};
+ template<typename...T>
+ struct S {
+ template<typename...U>
+ void f(T &&...t, U &&...u) {} // expected-note {{candidate}}
+ template<typename...U>
+ void g(U &&...u, T &&...t) {} // expected-note {{candidate}}
+ template<typename...U>
+ void h(tuple<T, U> &&...) {} // expected-note 2{{candidate}}
+
+ template<typename...U>
+ struct X {
+ template<typename...V>
+ void x(tuple<T, U, V> &&...); // expected-error {{different lengths}}
+ };
+ };
+
+ void test() {
+ S<>().f();
+ S<>().f(0);
+ S<int>().f(0);
+ S<int>().f(0, 1);
+ S<int, int>().f(0); // expected-error {{no matching member function for call}}
+
+ S<>().g();
+ S<>().g(0);
+ S<int>().g(0);
+ S<int>().g(0, 1); // expected-error {{no matching member function for call}}
+ S<int>().g<int>(0, 1);
+ S<int, int>().g(0, 1);
+
+ S<>().h();
+ S<>().h(0); // expected-error {{no matching member function for call}}
+ S<int>().h({}); // expected-error {{no matching member function for call}}
+ S<int>().h<int>({});
+ S<int>().h(tuple<int,int>{});
+ S<int, int>().h(tuple<int,int>{}, tuple<int,int>{});
+
+ S<int, int>::X<char>(); // expected-note {{here}}
+ }
+}
diff --git a/test/CXX/temp/temp.names/p3-0x.cpp b/test/CXX/temp/temp.names/p3-0x.cpp
new file mode 100644
index 000000000000..85dc75e30199
--- /dev/null
+++ b/test/CXX/temp/temp.names/p3-0x.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify
+
+template<int i> class X { /* ... */ };
+X< 1>2 > x1; // expected-error{{expected unqualified-id}}
+X<(1>2)> x2; // OK
+template<class T> class Y { /* ... */ };
+Y<X<1>> x3; // OK, same as Y<X<1> > x3;
+Y<X<6>>1>> x4; // expected-error{{expected unqualified-id}}
+Y<X<(6>>1)>> x5;
+
+int a, b;
+Y<decltype(a < b)> x6;
diff --git a/test/CXX/temp/temp.spec/p5.cpp b/test/CXX/temp/temp.spec/p5.cpp
index 0e69a26b04e2..ba92d41e3e8e 100644
--- a/test/CXX/temp/temp.spec/p5.cpp
+++ b/test/CXX/temp/temp.spec/p5.cpp
@@ -14,7 +14,7 @@ struct X0 {
};
template<typename T>
-T X0<T>::value = 3.14; // expected-warning{{implicit conversion turns literal floating-point number into integer}}
+T X0<T>::value = 3.14; // expected-warning{{implicit conversion from 'double' to 'int' changes value from 3.14 to 3}}
template struct X0<int>; // expected-note{{previous explicit instantiation}} \
expected-note{{requested here}}
diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p14.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p14.cpp
index 121cb8eedf2f..aba9d3640801 100644
--- a/test/CXX/temp/temp.spec/temp.expl.spec/p14.cpp
+++ b/test/CXX/temp/temp.spec/temp.expl.spec/p14.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s
template<class T> void f(T) { /* ... */ }
template<class T> inline void g(T) { /* ... */ }
diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp
index 84841cb60f4d..c8b7def5a448 100644
--- a/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp
+++ b/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp
@@ -1,10 +1,14 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
namespace N {
- template<class T> class X;
+ template<class T> class X; // expected-note {{'N::X' declared here}} \
+ // expected-note {{explicitly specialized declaration is here}}
}
-template<> class X<int> { /* ... */ }; // expected-error {{non-template class 'X'}}
+// TODO: Don't add a namespace qualifier to the template if it would trigger
+// the warning about the specialization being outside of the namespace.
+template<> class X<int> { /* ... */ }; // expected-error {{no template named 'X'; did you mean 'N::X'?}} \
+ // expected-warning {{first declaration of class template specialization of 'X' outside namespace 'N' is a C++11 extension}}
namespace N {
diff --git a/test/CXX/temp/temp.spec/temp.explicit/p12.cpp b/test/CXX/temp/temp.spec/temp.explicit/p12.cpp
index c7564868f8ad..9518a0b077b7 100644
--- a/test/CXX/temp/temp.spec/temp.explicit/p12.cpp
+++ b/test/CXX/temp/temp.spec/temp.explicit/p12.cpp
@@ -1,6 +1,49 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-char* p = 0;
-template<class T> T g(T x = &p) { return x; }
-template int g<int>(int); // OK even though &p isn't an int.
+namespace test0 {
+ char* p = 0;
+ template<class T> T g(T x = &p) { return x; }
+ template int g<int>(int); // OK even though &p isn't an int.
+}
+// Don't impose access restrictions on explicit instantiations.
+namespace test1 {
+ class A {
+ class Private {};
+ public:
+ typedef Private Public;
+ };
+
+ template <class T> class Temp {
+ static Temp<A::Public> make() { return Temp<A::Public>(); }
+ };
+ template class Temp<A::Private>;
+
+ // FIXME: this ought to be an error, but it isn't because Sema is
+ // silently failing to create a declaration for the explicit
+ // instantiation.
+ template class Temp<A::Private> Temp<int>::make();
+}
+
+// Don't impose access restrictions on explicit specializations,
+// either. This goes here because it's an extension of the rule for
+// explicit instantiations and doesn't have any independent support.
+namespace test2 {
+ class A {
+ class Private {}; // expected-note {{implicitly declared private here}}
+ public:
+ typedef Private Public;
+ };
+
+ template <class T> class Temp {
+ static Temp<A::Public> make();
+ };
+ template <> class Temp<A::Private> {
+ public:
+ Temp(int x) {}
+ };
+
+ template <> class Temp<A::Private> Temp<int>::make() { // expected-error {{'Private' is a private member of 'test2::A'}}
+ return Temp<A::Public>(0);
+ }
+}
diff --git a/test/CXX/temp/temp.spec/temp.explicit/p9-linkage.cpp b/test/CXX/temp/temp.spec/temp.explicit/p9-linkage.cpp
index 04e7df5741e2..ff24ad997dfd 100644
--- a/test/CXX/temp/temp.spec/temp.explicit/p9-linkage.cpp
+++ b/test/CXX/temp/temp.spec/temp.explicit/p9-linkage.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -O1 -emit-llvm -std=c++11 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -emit-llvm -std=c++11 -o - %s | FileCheck %s
template<typename T>
struct X0 {