new tests and adjustments for explicit function template qualification

From-SVN: r15777
This commit is contained in:
Jason Merrill 1997-09-28 15:26:50 -04:00
parent 905a881f36
commit a98d45ff1f
8 changed files with 56 additions and 7 deletions

View 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;};

View 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;

View 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);

View File

@ -1,4 +1,4 @@
// Special g++ Options: -fansi-overloading
// Special g++ Options: -fguiding-decls
struct A {
friend int operator== (const A&, const A&);

View 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; }

View File

@ -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);
}

View File

@ -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>();
}

View 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");