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