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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [cpp0x/] [explicit3.C] - Blame information for rev 715

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
// Test for "contextually converted to bool"
2
// { dg-options "-std=c++0x" }
3
 
4
struct A
5
{
6
  explicit operator bool();
7
};
8
 
9
void f (bool);
10
 
11
struct B
12
{
13
  bool b;
14
};
15
 
16
struct C
17
{
18
  operator int();
19
};
20
 
21
struct D
22
{
23
  operator int();
24
};
25
 
26
int main()
27
{
28
  A a; C c; D d;
29
  // These contexts use an explicit bool conversion.
30
  if (a) {}
31
  for (; a; ) {}
32
  do {} while (a);
33
  while (a) {}
34
  a ? 1 : 0;
35
  a || true;
36
  a && true;
37
  !a;
38
 
39
  a ? c : 1;
40
  a ? c : d;
41
 
42
  // These do not.
43
  switch (a);                   // { dg-error "" }
44
  bool b = a;                   // { dg-error "" }
45
  // { dg-message "candidate" "candidate note" { target *-*-* } 44 }
46
  f(a);                         // { dg-error "" }
47
  B b2 = { a };                 // { dg-error "" }
48
  a + true;                     // { dg-message "" }
49
  b ? a : true;                 // { dg-message "" }
50
  a ? a : true;                 // { dg-message "" }
51
}

powered by: WebSVN 2.1.0

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