]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/g++.dg/cpp0x/constexpr-virtual6.C
Regenerate riscv.opt.urls and i386.opt.urls
[thirdparty/gcc.git] / gcc / testsuite / g++.dg / cpp0x / constexpr-virtual6.C
CommitLineData
88504f34
NS
1// PR c++/70393
2// { dg-do run { target c++11 } }
3
4/* 'ab' has a static initializer, but we flubbed the initializer,
5 because of B being the primary base. */
6
7struct A
8{
9 int a = 1;
10};
11
12struct B
13{
14 B *element = (B*)2;
15
16 virtual int vfunc() = 0;
17
18 int call_element()
19 {
20 return element->vfunc();
21 }
22
23 void set_element()
24 {
25 element = this;
26 }
27};
28
29struct AB : public A, public B
30{
31 int vfunc()
32 {
33 return 0;
34 }
35};
36
37static AB ab;
38
39int main()
40{
41 if (ab.a != 1)
42 return 1;
43 if (ab.element != (void*)2)
44 return 2;
45
46 ab.set_element();
47 return ab.call_element();
48}
49