1 // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -g -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:  [ DW_TAG_structure_type ] [Derived<int>] {{.*}} [def]
6 // rdar://problem/15931354
7 template <class A> class Derived;
8 
9 template <class A> class Base {
10   static Derived<A> *create();
11 };
12 
13 template <class A> struct Derived : Base<A> {
14 };
15 
16 Base<int> *f;
17 
18 // During the instantiation of Derived<int>, Base<int> becomes required to be
19 // complete - since the declaration has already been emitted (due to 'f',
20 // above), we immediately try to build debug info for Base<int> which then
21 // requires the (incomplete definition) of Derived<int> which is problematic.
22 //
23 // (if 'f' is not present, the point at which Base<int> becomes required to be
24 // complete during the instantiation of Derived<int> is a no-op because
25 // Base<int> was never emitted so we ignore it and carry on until we
26 // wire up the base class of Derived<int> in the debug info later on)
27 Derived<int> d;
28