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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
// PR libstdc++/48760
2
// { dg-options -std=c++0x }
3
// { dg-do run }
4
 
5
constexpr _Complex int i{1,2};
6
constexpr _Complex int j{3};
7
 
8
#define SA(X) static_assert((X),#X)
9
 
10
SA(__real i == 1);
11
SA(__imag i == 2);
12
SA(__real j == 3);
13
SA(__imag j == 0);
14
 
15
struct A
16
{
17
  _Complex int c;
18
  constexpr A(int i, int j): c{i,j} { }
19
  constexpr A(int i): c{i} { }
20
};
21
 
22
constexpr A a1(1,2);
23
constexpr A a2(3);
24
 
25
SA(__real a1.c == 1);
26
SA(__imag a1.c == 2);
27
SA(__real a2.c == 3);
28
SA(__imag a2.c == 0);
29
 
30
typedef _Complex int ci;
31
 
32
SA((__real ci{1,2} == 1));
33
SA((__imag ci{1,2} == 2));
34
SA((__real ci{3} == 3));
35
SA((__imag ci{3} == 0));
36
 
37
struct B
38
{
39
  _Complex int c;
40
  int i;
41
};
42
 
43
constexpr B b1 = { { 1,2 }, 42 };
44
constexpr B b2 = { { 3 }, 24 };
45
// No brace elision for complex.
46
constexpr B b3 = { 5, 6 };
47
 
48
SA(__real b1.c == 1);
49
SA(__imag b1.c == 2);
50
SA(b1.i == 42);
51
SA(__real b2.c == 3);
52
SA(__imag b2.c == 0);
53
SA(b2.i == 24);
54
SA(__real b3.c == 5);
55
SA(__imag b3.c == 0);
56
SA(b3.i == 6);
57
 
58
int main()
59
{
60
  ci* p = new ci{1,2};
61
  if (__real *p != 1 || __imag *p != 2)
62
    return 1;
63
  delete p;
64
  p = new ci{3};
65
  if (__real *p != 3 || __imag *p != 0)
66
    return 1;
67
}

powered by: WebSVN 2.1.0

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