aboutsummaryrefslogtreecommitdiff
path: root/test/CXX/temp/temp.decls/temp.friend/p1.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/CXX/temp/temp.decls/temp.friend/p1.cpp')
-rw-r--r--test/CXX/temp/temp.decls/temp.friend/p1.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/CXX/temp/temp.decls/temp.friend/p1.cpp b/test/CXX/temp/temp.decls/temp.friend/p1.cpp
new file mode 100644
index 000000000000..fc392da00acf
--- /dev/null
+++ b/test/CXX/temp/temp.decls/temp.friend/p1.cpp
@@ -0,0 +1,56 @@
+// RUN: clang-cc -emit-llvm-only %s
+
+template <typename T> struct Num {
+ T value_;
+
+public:
+ Num(T value) : value_(value) {}
+ T get() const { return value_; }
+
+ template <typename U> struct Rep {
+ U count_;
+ Rep(U count) : count_(count) {}
+
+ friend Num operator*(const Num &a, const Rep &n) {
+ Num x = 0;
+ for (U count = n.count_; count; --count)
+ x += a;
+ return x;
+ }
+ };
+
+ friend Num operator+(const Num &a, const Num &b) {
+ return a.value_ + b.value_;
+ }
+
+ Num& operator+=(const Num& b) {
+ value_ += b.value_;
+ return *this;
+ }
+
+ class Representation {};
+ friend class Representation;
+};
+
+class A {
+ template <typename T> friend bool iszero(const A &a) throw();
+};
+
+template <class T> class B_iterator;
+template <class T> class B {
+ friend class B_iterator<T>;
+};
+
+int calc1() {
+ Num<int> left = -1;
+ Num<int> right = 1;
+ Num<int> result = left + right;
+ return result.get();
+}
+
+int calc2() {
+ Num<int> x = 3;
+ Num<int>::Rep<char> n = (char) 10;
+ Num<int> result = x * n;
+ return result.get();
+}