Debian Codegraph @

gcc/testsuite/g++.dg/tree-ssa/pr101839.C

raw
1 // { dg-do run }
2 // { dg-options "-O2 -fdump-tree-optimized" }
3 // { dg-require-effective-target c++11 }
4 // { dg-skip-if "requires hosted libstdc++ for iostream" { ! hostedlib } }
5
6 #include <string.h>
7 #include <iostream>
8 #include <map>
9 namespace {
10 struct Buf {
11 char * buf; int a{0}; int b{0};
12 Buf(char * b) : buf(b) { }
13 void add(int v) {
14 ::memcpy(buf, &v, sizeof(v));
15 a += sizeof(v);
16 b += sizeof(v);
17 }
18 };
19 struct A {
20 virtual void fill(Buf &buf) {
21 buf.add(type());
22 buf.add(type());
23 }
24 virtual ~A() {}
25 virtual int type() = 0;
26 };
27 struct BA : A {
28 void fill(Buf &buf) {
29 A::fill(buf);
30 buf.add(type());
31 buf.add(type());
32 }
33 int type() final {
34 return 1;
35 }
36 };
37 struct CBA final : BA {
38 };
39 struct CA final : A {
40 ::std::map<int, int> m;
41 int type() final {
42 return 2;
43 }
44 };
45 }
46 int main(int argc, char ** ) {
47 char d[1024];
48 CBA cba;
49 Buf buf(d);
50 cba.fill(buf);
51 CA ca;
52 return 0;
53 }
54 // { dg-final { scan-tree-dump-not "__builtin_unreachable" "optimized" } }