1 // { dg-do compile }
2 // { dg-options "--std=c++11 -dA -gdwarf-4 -fdebug-types-section -fno-merge-debug-strings" }
3
4 // Check that -fdebug-types-sections does not copy a full referenced type
5 // into a type unit.
6
7 // Checks that at least one type unit is generated.
8 //
9 // { dg-final { scan-assembler "DIE \\(\[^\n\]*\\) DW_TAG_type_unit" } }
10 //
11 // Check that func is declared exactly once in the debug info (in the
12 // compile unit).
13 //
14 // { dg-final { scan-assembler-times "\\.ascii \"func\\\\0\"\[^\n\]*DW_AT_name" 1 { xfail { powerpc-ibm-aix* } } } }
15 //
16 // Check to make sure that no type unit contains a DIE with DW_AT_low_pc
17 // or DW_AT_ranges. These patterns assume that the compile unit is always
18 // emitted after all type units.
19 //
20 // { dg-final { scan-assembler-not "\\.quad\[^\n\]*DW_AT_low_pc.*DIE \\(\[^\n\]*\\) DW_TAG_compile_unit" } }
21 // { dg-final { scan-assembler-not "\\.quad\[^\n\]*DW_AT_ranges.*DIE \\(\[^\n\]*\\) DW_TAG_compile_unit" } }
22
23 struct A {
24 A();
25 virtual ~A();
26 virtual void foo();
27 private:
28 int data;
29 };
30
31 struct B {
32 B();
33 virtual ~B();
34 };
35
36 extern B* table[];
37
38 struct D {
39 template <typename T>
getD40 T* get(int i)
41 {
42 B*& cell = table[i];
43 if (cell == 0)
44 cell = new T();
45 return static_cast<T*>(cell);
46 }
47 };
48
func(D * d)49 void func(D* d)
50 {
51 struct C : B {
52 A a;
53 };
54 d->get<C>(0)->a.foo();
55 }
56