* partord1.C: New test.
authorAlexandre Oliva <oliva@dcc.unicamp.br>
Thu, 1 Jul 1999 16:08:07 +0000 (16:08 +0000)
committerAlexandre Oliva <oliva@gcc.gnu.org>
Thu, 1 Jul 1999 16:08:07 +0000 (16:08 +0000)
From-SVN: r27887

gcc/testsuite/g++.old-deja/g++.oliva/ChangeLog
gcc/testsuite/g++.old-deja/g++.oliva/partord1.C [new file with mode: 0644]

index f8076c1..6c45507 100644 (file)
@@ -1,4 +1,6 @@
 1999-07-01  Alexandre Oliva  <oliva@dcc.unicamp.br>
 
+       * partord1.C: New test.
+
        * template1.C: New test.
 
diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/partord1.C b/gcc/testsuite/g++.old-deja/g++.oliva/partord1.C
new file mode 100644 (file)
index 0000000..7ed017a
--- /dev/null
@@ -0,0 +1,28 @@
+// Build don't link:
+
+// Copyright (C) 1999 Free Software Foundation
+
+// by Alexandre Oliva <oliva@dcc.unicamp.br>
+
+template <typename T> void foo(T);
+template <typename T> void foo(T*);
+
+template <typename T> class bar {
+ private:
+  int i; // ERROR - this variable
+  friend void foo<T>(T);
+};
+
+template <typename T> void foo(T) {
+  bar<T>().i = 0; // ok, I'm a friend
+}
+template <typename T> void foo(T*) {
+  bar<T*>().i = 1; // ERROR - not a friend
+}
+
+int main() {
+  int j = 0;
+  foo(j); // calls foo<int>(int), ok
+  foo(&j); // calls foo<int>(int*) // ERROR - not a friend
+  foo<int*>(&j); // calls foo<int*>(int*), ok
+}