OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [template/] [friend10.C] - Blame information for rev 693

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
// { dg-do run }
2
 
3
// Copyright (C) 2002 Free Software Foundation, Inc.
4
// Contributed by Nathan Sidwell 24 Dec 2002 
5
 
6
// PR 5116. template instantiation can add a friend into a namespace,
7
// and thus change overload resolution.
8
 
9
#include 
10
 
11
static int right;
12
static int wrong;
13
 
14
struct Buggy {};
15
 
16
template struct Handle
17
{
18
  Handle(T* p) {}
19
 
20
  operator bool() const { wrong++; return true; }
21
 
22
  friend std::ostream& operator<<(std::ostream& ostr, const Handle& r)
23
  {
24
    right++;
25
 
26
    return ostr << "in operator<<(ostream&, const Handle&)";
27
  }
28
};
29
 
30
typedef Handle     Buggy_h;
31
 
32
bool cmp (const Buggy_h& b1, const Buggy_h& b2)
33
{
34
  std::cout << b1 << " " << b2 << std::endl;
35
  return false;
36
}
37
 
38
int main()
39
{
40
  Buggy o;
41
 
42
  cmp (&o, &o);
43
 
44
  return !(right == 2 && !wrong);
45
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.