xref: /minix3/external/bsd/llvm/dist/clang/test/PCH/missing-file.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // Test reading of PCH without original input files.
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc // Generate the PCH, removing the original file:
4*f4a2713aSLionel Sambuc // RUN: echo 'struct S{char c; int i; }; void foo() {}' > %t.h
5*f4a2713aSLionel Sambuc // RUN: echo 'template <typename T> void tf() { T::foo(); }' >> %t.h
6*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -x c++ -emit-pch -o %t.h.pch %t.h
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc // %t.h might be touched by scanners as a hot file on Windows,
9*f4a2713aSLionel Sambuc // to fail to remove %.h with single run.
10*f4a2713aSLionel Sambuc // FIXME: Do we really want to work around bugs in virus checkers here?
11*f4a2713aSLionel Sambuc // RUN: rm %t.h || rm %t.h || rm %t.h
12*f4a2713aSLionel Sambuc 
13*f4a2713aSLionel Sambuc // Check diagnostic with location in original source:
14*f4a2713aSLionel Sambuc // RUN: not %clang_cc1 -include-pch %t.h.pch -emit-obj -o %t.o %s 2> %t.stderr
15*f4a2713aSLionel Sambuc // RUN: grep 'could not find file' %t.stderr
16*f4a2713aSLionel Sambuc 
qq(S *)17*f4a2713aSLionel Sambuc void qq(S*) {}
18*f4a2713aSLionel Sambuc 
19*f4a2713aSLionel Sambuc #ifdef REDECL
foo()20*f4a2713aSLionel Sambuc float foo() {return 0f;}
21*f4a2713aSLionel Sambuc #endif
22*f4a2713aSLionel Sambuc 
23*f4a2713aSLionel Sambuc #ifdef INSTANTIATION
f()24*f4a2713aSLionel Sambuc void f() {
25*f4a2713aSLionel Sambuc   tf<int>();
26*f4a2713aSLionel Sambuc }
27*f4a2713aSLionel Sambuc #endif
28