diff options
author | nathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-12-26 12:23:11 +0000 |
---|---|---|
committer | nathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-12-26 12:23:11 +0000 |
commit | bf1f7a59a384ea79acb2d7fd3ae3981e9686c335 (patch) | |
tree | b5d0e443d07d129ba5e34654dec2cfcdb8cf7dca /gcc/testsuite | |
parent | bebfebd27620392b7bada04cbad9f9b4b3edfed2 (diff) | |
download | gcc-bf1f7a59a384ea79acb2d7fd3ae3981e9686c335.tar.gz |
cp:
PR c++/5116, c++/764
* call.c (build_new_op): Make sure template class operands are
instantiated.
testsuite:
* g++.dg/template/friend10.C: New test.
* g++.dg/template/conv5.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@60514 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/conv5.C | 22 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/friend10.C | 45 |
3 files changed, 72 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8196168626b..a68ab21957b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2002-12-26 Nathan Sidwell <nathan@codesourcery.com> + + * g++.dg/template/friend10.C: New test. + * g++.dg/template/conv5.C: New test. + 2002-12-24 Nathan Sidwell <nathan@codesourcery.com> * g++.dg/lookup/scoped3.C: New test. diff --git a/gcc/testsuite/g++.dg/template/conv5.C b/gcc/testsuite/g++.dg/template/conv5.C new file mode 100644 index 00000000000..80835437a98 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/conv5.C @@ -0,0 +1,22 @@ +// { dg-do compile } + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 26 Dec 2002 <nathan@codesourcery.com> + +// PR 764. Failed to find friend in overload resolution + +template <class T> +struct S +{ + friend bool operator== (const S&, const S&) { + return true; + } +}; + +int main () +{ + // S<int> s; + + const S<int> *p = 0; + *p == *p; // error +} diff --git a/gcc/testsuite/g++.dg/template/friend10.C b/gcc/testsuite/g++.dg/template/friend10.C new file mode 100644 index 00000000000..cab5e346f0b --- /dev/null +++ b/gcc/testsuite/g++.dg/template/friend10.C @@ -0,0 +1,45 @@ +// { dg-do run } + +// Copyright (C) 2002 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 24 Dec 2002 <nathan@codesourcery.com> + +// PR 5116. template instantiation can add a friend into a namespace, +// and thus change overload resolution. + +#include <iostream> + +static int right; +static int wrong; + +struct Buggy {}; + +template <typename T>struct Handle +{ + Handle(T* p) {} + + operator bool() const { wrong++; return true; } + + friend std::ostream& operator<<(std::ostream& ostr, const Handle& r) + { + right++; + + return ostr << "in operator<<(ostream&, const Handle&)"; + } +}; + +typedef Handle<Buggy> Buggy_h; + +bool cmp (const Buggy_h& b1, const Buggy_h& b2) +{ + std::cout << b1 << " " << b2 << std::endl; + return false; +} + +int main() +{ + Buggy o; + + cmp (&o, &o); + + return !(right == 2 && !wrong); +} |