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