new tests and adjustments for explicit function template qualification
authorJason Merrill <jason@gcc.gnu.org>
Sun, 28 Sep 1997 19:26:50 +0000 (15:26 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Sun, 28 Sep 1997 19:26:50 +0000 (15:26 -0400)
From-SVN: r15777

gcc/testsuite/g++.old-deja/g++.brendan/template9.C
gcc/testsuite/g++.old-deja/g++.jason/tempinst1.C
gcc/testsuite/g++.old-deja/g++.jason/template13.C
gcc/testsuite/g++.old-deja/g++.jason/template38.C
gcc/testsuite/g++.old-deja/g++.law/template2.C
gcc/testsuite/g++.old-deja/g++.pt/explicit36.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.pt/explicit37.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.pt/memtemp20.C

index 8940c17724d58d902fc2968e394963c23b171385..c4c9c831157286e5422c918cb7e482b431f2c8a8 100644 (file)
@@ -1,6 +1,7 @@
 // GROUPS passed templates
 // Test that the compiler will emit the definition of min given just
 // the declaration.  At one point in the past, it did not.
+// Special g++ Options: -fguiding-decls
 #include <iostream.h>
 
 template <class T> inline T min(T a, T b) { return (a < b) ? a : b;};
index 2efcf241bf4ad353ace4bcddc121dfb7b9256c41..0a8a6cc378c0b5b09377130cf6ed4d46824d673b 100644 (file)
@@ -6,12 +6,14 @@ struct ostream {
   ostream& operator<< (const char *) { return *this; };
 };
 
-template <class T> class foo {
-  friend ostream& operator<<(ostream&, foo<T>&);
-};
+template <class T> class foo;
 
 template <class T> ostream& operator<< (ostream& ios, foo<T>&obj) { };
 
+template <class T> class foo {
+  friend ostream& operator<<<>(ostream&, foo<T>&);
+};
+
 int main()
 {
   ostream cout;
index 11d2180184690ffeae5bcf6af13d1d95a8ad63f8..75bd64d7ff33c44a05470061537cb54caf87654d 100644 (file)
@@ -1,6 +1,6 @@
 // Bug: g++ fails to actually instantiate templates to the specifications of
 // guiding decls.
-// Special g++ Options: -g -ansi -pedantic-errors
+// Special g++ Options: -g -ansi -pedantic-errors -fguiding-decls
 
 template <class T> inline T min (T a, T b) { return a<b?a:b; }
 double min (double, double);
index 567dc20e4193f92cb5208fdf4158fcd340ff9d1a..3870cbc5c140728e16c54fb51e58a472e824b54c 100644 (file)
@@ -1,4 +1,4 @@
-// Special g++ Options: -fansi-overloading
+// Special g++ Options: -fguiding-decls
 
 struct A {
   friend int operator== (const A&, const A&);
index 7e5e108a7281d3d3ab949ac1b9077a856bd2f3ca..7fa2c766b83625de78f84393fe8a6b1eb3c8469a 100644 (file)
@@ -1,4 +1,5 @@
 // GROUPS passed templates
+// Special g++ Options: -fguiding-decls
 extern "C" void printf (char *, ...);
 
 template<class T> T max(T a, T b) { return a > b ? a : b; }
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit36.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit36.C
new file mode 100644 (file)
index 0000000..6f9e7c6
--- /dev/null
@@ -0,0 +1,24 @@
+// Build don't run:
+// GROUPS passed templates
+template <class T>
+void foo(T);
+
+class S {
+  friend void foo<>(int);
+
+  int i;
+};
+
+
+template <>
+void foo(int)
+{
+  S s;
+  s.i = 3;
+}
+
+
+int main()
+{
+  foo(3);
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit37.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit37.C
new file mode 100644 (file)
index 0000000..4d911a4
--- /dev/null
@@ -0,0 +1,23 @@
+// Build don't run:
+// GROUPS passed templates
+class ostream {};
+
+template <class T>
+class S;
+
+template <class T>
+void operator<<(ostream&, S<T>) {}
+
+template <class T>
+class S
+{
+  friend void operator<<<>(ostream&, const S<T>);
+};
+
+
+int main()
+{
+  ostream o;
+
+  o << S<int>();
+}
index 29f0aa10f31b37e22bc3f26182e267da3fab764b..a79c53467d5ba16ba1e36d6c9728f168a2f66c2a 100644 (file)
@@ -10,7 +10,6 @@ struct S
   template <class U>
   void foo(char*, U);
 
-  template <>
   void foo(int i);
 };
 
@@ -28,7 +27,6 @@ void S::foo(char*, U u)
 }
 
 
-template <>
 void S::foo(int i)
 {
   printf ("int version\n");