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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.old-deja/] [g++.other/] [overcnv2.C] - Blame information for rev 699

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 699 jeremybenn
// { dg-do assemble  }
2
// { dg-options "-Wconversion" }
3
// Test that we resolve this case as mandated by the standard, but also
4
// warn about it.  We choose op char* not because it is a member of B --
5
// the standard says that all conversion ops are treated as coming from
6
// the type of the argument -- but because it is non-const.
7
 
8
struct A  {
9
  operator const char *() const { return ""; }
10
};
11
 
12
struct B : public A {
13
  operator char *() { return 0; }
14
};
15
 
16
int main()
17
{
18
  B b;
19
  if ((const char *)b != 0)  // { dg-warning "choosing 'B" "B" } surprising overload resolution
20
  // { dg-warning "for conversion" "conv" { target *-*-* } 19 }
21
  // { dg-message "note" "note" { target *-*-* } 19 }
22
    return 1;
23
  if ((const char *)(const B)b == 0)
24
    return 2;
25
  if ((const char *)(const B &)b == 0)
26
    return 3;
27
}

powered by: WebSVN 2.1.0

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