new tests and adjustments for explicit function template qualification
From-SVN: r15777
This commit is contained in:
parent
905a881f36
commit
a98d45ff1f
8 changed files with 56 additions and 7 deletions
|
@ -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;};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Special g++ Options: -fansi-overloading
|
||||
// Special g++ Options: -fguiding-decls
|
||||
|
||||
struct A {
|
||||
friend int operator== (const A&, const A&);
|
||||
|
|
|
@ -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; }
|
||||
|
|
24
gcc/testsuite/g++.old-deja/g++.pt/explicit36.C
Normal file
24
gcc/testsuite/g++.old-deja/g++.pt/explicit36.C
Normal 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);
|
||||
}
|
23
gcc/testsuite/g++.old-deja/g++.pt/explicit37.C
Normal file
23
gcc/testsuite/g++.old-deja/g++.pt/explicit37.C
Normal 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>();
|
||||
}
|
|
@ -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");
|
||||
|
|
Loading…
Add table
Reference in a new issue