xref: /llvm-project/clang/test/CodeGenCXX/debug-info-template-fwd.cpp (revision 0f1c1be1968076d6f96f8a7bcc4a15cf195ecd97)
1 // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -debug-info-kind=limited -emit-llvm -o - | FileCheck %s
2 // This test is for a crash when emitting debug info for not-yet-completed
3 // types.
4 // Test that we don't actually emit a forward decl for the offending class:
5 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Derived<int>"
6 // CHECK-NOT:              DIFlagFwdDecl
7 // CHECK-SAME:             ){{$}}
8 template <class A> class Derived;
9 
10 template <class A> class Base {
11   static Derived<A> *create();
12 };
13 
14 template <class A> struct Derived : Base<A> {
15 };
16 
17 Base<int> *f;
18 
19 // During the instantiation of Derived<int>, Base<int> becomes required to be
20 // complete - since the declaration has already been emitted (due to 'f',
21 // above), we immediately try to build debug info for Base<int> which then
22 // requires the (incomplete definition) of Derived<int> which is problematic.
23 //
24 // (if 'f' is not present, the point at which Base<int> becomes required to be
25 // complete during the instantiation of Derived<int> is a no-op because
26 // Base<int> was never emitted so we ignore it and carry on until we
27 // wire up the base class of Derived<int> in the debug info later on)
28 Derived<int> d;
29