summaryrefslogtreecommitdiffstats
path: root/test/CXX/temp/temp.decls
diff options
context:
space:
mode:
Diffstat (limited to 'test/CXX/temp/temp.decls')
-rw-r--r--test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp38
-rw-r--r--test/CXX/temp/temp.decls/temp.friend/p1.cpp83
-rw-r--r--test/CXX/temp/temp.decls/temp.friend/p3.cpp3
-rw-r--r--test/CXX/temp/temp.decls/temp.mem/p1.cpp6
4 files changed, 119 insertions, 11 deletions
diff --git a/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp b/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp
index cfa14f9..97457ea 100644
--- a/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp
+++ b/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp
@@ -1,16 +1,48 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-template<int I, int J, class T> class X {
+template<int I, int J, class T> struct X {
static const int value = 0;
};
-template<int I, int J> class X<I, J, int> {
+template<int I, int J> struct X<I, J, int> {
static const int value = 1;
};
-template<int I> class X<I, I, int> {
+template<int I> struct X<I, I, int> {
static const int value = 2;
};
int array0[X<0, 0, float>::value == 0? 1 : -1];
int array1[X<0, 1, int>::value == 1? 1 : -1];
int array2[X<0, 0, int>::value == 2? 1 : -1];
+
+namespace DependentSubstPartialOrdering {
+ template<typename T, typename U = void, typename V = void>
+ struct X {
+ static const unsigned value = 1;
+ };
+
+ template<typename T, typename U>
+ struct X<T, U, typename T::is_b> {
+ static const unsigned value = 2;
+ };
+
+ template<typename T>
+ struct X<T, typename T::is_a, typename T::is_b> {
+ static const unsigned value = 3;
+ };
+
+ struct X1 { };
+
+ struct X2 {
+ typedef void is_b;
+ };
+
+ struct X3 {
+ typedef void is_a;
+ typedef void is_b;
+ };
+
+ int check_X1[X<X1, void, void>::value == 1? 1 : -1];
+ int check_X2[X<X2, void, void>::value == 2? 1 : -1];
+ int check_X3[X<X3, void, void>::value == 3? 1 : -1];
+}
diff --git a/test/CXX/temp/temp.decls/temp.friend/p1.cpp b/test/CXX/temp/temp.decls/temp.friend/p1.cpp
index c9dc546..073b2a1 100644
--- a/test/CXX/temp/temp.decls/temp.friend/p1.cpp
+++ b/test/CXX/temp/temp.decls/temp.friend/p1.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -faccess-control -verify -emit-llvm-only %s
+// RUN: %clang_cc1 -verify -emit-llvm-only %s
namespace test0 {
template <typename T> struct Num {
@@ -155,7 +155,7 @@ namespace Dependent {
}
namespace test7 {
- template <class T> class A { // expected-note {{previous definition is here}}
+ template <class T> class A { // expected-note {{declared here}}
friend class B;
int x; // expected-note {{declared private here}}
};
@@ -174,7 +174,7 @@ namespace test7 {
// This shouldn't crash.
template <class T> class D {
- friend class A; // expected-error {{redefinition of 'A' as different kind of symbol}}
+ friend class A; // expected-error {{elaborated type refers to a template}}
};
template class D<int>;
}
@@ -216,3 +216,80 @@ namespace test9 {
template class A<int>; // expected-note {{in instantiation}}
}
+
+namespace test10 {
+ template <class T> class A;
+ template <class T> A<T> bar(const T*, const A<T>&);
+ template <class T> class A {
+ private:
+ void foo(); // expected-note {{declared private here}}
+ friend A bar<>(const T*, const A<T>&);
+ };
+
+ template <class T> A<T> bar(const T *l, const A<T> &r) {
+ A<T> l1;
+ l1.foo();
+
+ A<char> l2;
+ l2.foo(); // expected-error {{'foo' is a private member of 'test10::A<char>'}}
+
+ return l1;
+ }
+
+ template A<int> bar<int>(const int *, const A<int> &); // expected-note {{in instantiation}}
+}
+
+// PR6752: this shouldn't crash.
+namespace test11 {
+ struct Foo {
+ template<class A>
+ struct IteratorImpl {
+ template<class T> friend class IteratorImpl;
+ };
+ };
+
+ template struct Foo::IteratorImpl<int>;
+ template struct Foo::IteratorImpl<long>;
+}
+
+// PR6827
+namespace test12 {
+ template <typename T> class Foo;
+ template <typename T> Foo<T> foo(T* t){ return Foo<T>(t, true); }
+
+ template <typename T> class Foo {
+ public:
+ Foo(T*);
+ friend Foo<T> foo<T>(T*);
+ private:
+ Foo(T*, bool); // expected-note {{declared private here}}
+ };
+
+ // Should work.
+ int globalInt;
+ Foo<int> f = foo(&globalInt);
+
+ // Shouldn't work.
+ long globalLong;
+ template <> Foo<long> foo(long *t) {
+ Foo<int> s(&globalInt, false); // expected-error {{calling a private constructor}}
+ return Foo<long>(t, true);
+ }
+}
+
+// PR6514
+namespace test13 {
+ template <int N, template <int> class Temp>
+ class Role : public Temp<N> {
+ friend class Temp<N>;
+ int x;
+ };
+
+ template <int N> class Foo {
+ void foo(Role<N, test13::Foo> &role) {
+ (void) role.x;
+ }
+ };
+
+ template class Foo<0>;
+}
diff --git a/test/CXX/temp/temp.decls/temp.friend/p3.cpp b/test/CXX/temp/temp.decls/temp.friend/p3.cpp
index 17d8c85..d116e01 100644
--- a/test/CXX/temp/temp.decls/temp.friend/p3.cpp
+++ b/test/CXX/temp/temp.decls/temp.friend/p3.cpp
@@ -8,6 +8,5 @@ class B {
template <class T> friend class A;
template <class T> friend class Undeclared;
- // FIXME: Diagnostic below could be (and was) better.
- template <class T> friend typename A<T>::Member; // expected-error {{classes or functions}}
+ template <class T> friend typename A<T>::Member; // expected-warning {{non-class type 'typename A<T>::Member' cannot be a friend}}
};
diff --git a/test/CXX/temp/temp.decls/temp.mem/p1.cpp b/test/CXX/temp/temp.decls/temp.mem/p1.cpp
index b057eed..f5f1205 100644
--- a/test/CXX/temp/temp.decls/temp.mem/p1.cpp
+++ b/test/CXX/temp/temp.decls/temp.mem/p1.cpp
@@ -19,17 +19,17 @@ namespace PR6376 {
template<typename T>
struct X {
template<typename Y>
- struct Y { };
+ struct Y1 { }; //
};
template<>
struct X<float> {
template<typename Y>
- struct Y { };
+ struct Y1 { };
};
template<typename T, typename U>
- struct Z : public X<T>::template Y<U> { };
+ struct Z : public X<T>::template Y1<U> { };
Z<float, int> z0;
}
OpenPOWER on IntegriCloud