48 lines · c
1#ifndef HEADER2#define HEADER3 4#include "blahblah.h"5void erroneous(int);6void erroneous(float);7 8struct bar;9struct zed {10 bar g;11};12struct baz {13 zed h;14};15 16void errparm(zed e);17 18struct S {19 {20;21 22#else23 24void foo(void) {25 erroneous(0);26}27 28#endif29 30// RUN: c-index-test -write-pch %t.h.pch %s -Xclang -detailed-preprocessing-record31// RUN: c-index-test -test-load-source local %s -include %t.h -Xclang -detailed-preprocessing-record | FileCheck -check-prefix=CHECK-PARSE %s32// RUN: c-index-test -index-file %s -include %t.h -Xclang -detailed-preprocessing-record | FileCheck -check-prefix=CHECK-INDEX %s33 34// CHECK-PARSE: pch-with-errors.c:{{.*}}:6: FunctionDecl=foo35// CHECK-PARSE: pch-with-errors.c:{{.*}}:3: CallExpr=erroneous36 37// CHECK-INDEX: [indexDeclaration]: kind: function | name: foo38// CHECK-INDEX: [indexEntityReference]: kind: function | name: erroneous39 40// RUN: not %clang -fsyntax-only %s -include %t.h 2>&1 | FileCheck -check-prefix=PCH-ERR %s41// PCH-ERR: error: PCH file '{{.*}}' contains compiler errors42 43// RUN: not c-index-test -write-pch %t.pch foobar.c 2>&1 | FileCheck -check-prefix=NONEXISTENT %s44// NONEXISTENT: Unable to load translation unit45 46// RUN: %clang -x c-header %s -o %t-clang.h.pch -Xclang -detailed-preprocessing-record -Xclang -fallow-pch-with-compiler-errors47// RUN: c-index-test -index-file %s -include %t-clang.h -Xclang -detailed-preprocessing-record | FileCheck -check-prefix=CHECK-INDEX %s48