xref: /aosp_15_r20/external/clang/test/Index/pch-with-errors.c (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li #ifndef HEADER
2*67e74705SXin Li #define HEADER
3*67e74705SXin Li 
4*67e74705SXin Li #include "blahblah.h"
5*67e74705SXin Li void erroneous(int);
6*67e74705SXin Li void erroneous(float);
7*67e74705SXin Li 
8*67e74705SXin Li struct bar;
9*67e74705SXin Li struct zed {
10*67e74705SXin Li   bar g;
11*67e74705SXin Li };
12*67e74705SXin Li struct baz {
13*67e74705SXin Li   zed h;
14*67e74705SXin Li };
15*67e74705SXin Li 
16*67e74705SXin Li void errparm(zed e);
17*67e74705SXin Li 
18*67e74705SXin Li struct S {
19*67e74705SXin Li   {
20*67e74705SXin Li ;
21*67e74705SXin Li 
22*67e74705SXin Li #else
23*67e74705SXin Li 
fooS24*67e74705SXin Li void foo(void) {
25*67e74705SXin Li   erroneous(0);
26*67e74705SXin Li }
27*67e74705SXin Li 
28*67e74705SXin Li #endif
29*67e74705SXin Li 
30*67e74705SXin Li // RUN: c-index-test -write-pch %t.h.pch %s -Xclang -detailed-preprocessing-record
31*67e74705SXin Li // RUN: c-index-test -test-load-source local %s -include %t.h -Xclang -detailed-preprocessing-record | FileCheck -check-prefix=CHECK-PARSE %s
32*67e74705SXin Li // RUN: c-index-test -index-file %s -include %t.h -Xclang -detailed-preprocessing-record | FileCheck -check-prefix=CHECK-INDEX %s
33*67e74705SXin Li 
34*67e74705SXin Li // CHECK-PARSE: pch-with-errors.c:{{.*}}:6: FunctionDecl=foo
35*67e74705SXin Li // CHECK-PARSE: pch-with-errors.c:{{.*}}:3: CallExpr=erroneous
36*67e74705SXin Li 
37*67e74705SXin Li // CHECK-INDEX: [indexDeclaration]: kind: function | name: foo
38*67e74705SXin Li // CHECK-INDEX: [indexEntityReference]: kind: function | name: erroneous
39*67e74705SXin Li 
40*67e74705SXin Li // RUN: not %clang -fsyntax-only %s -include %t.h 2>&1 | FileCheck -check-prefix=PCH-ERR %s
41*67e74705SXin Li // PCH-ERR: error: PCH file contains compiler errors
42*67e74705SXin Li 
43*67e74705SXin Li // RUN: not c-index-test -write-pch %t.pch foobar.c 2>&1 | FileCheck -check-prefix=NONEXISTENT %s
44*67e74705SXin Li // NONEXISTENT: Unable to load translation unit
45