xref: /aosp_15_r20/external/clang/test/PCH/missing-file.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // Test reading of PCH without original input files.
2*67e74705SXin Li 
3*67e74705SXin Li // Generate the PCH, removing the original file:
4*67e74705SXin Li // RUN: echo 'struct S{char c; int i; }; void foo() {}' > %t.h
5*67e74705SXin Li // RUN: echo 'template <typename T> void tf() { T::foo(); }' >> %t.h
6*67e74705SXin Li // RUN: %clang_cc1 -x c++ -emit-pch -o %t.h.pch %t.h
7*67e74705SXin Li // RUN: rm %t.h
8*67e74705SXin Li 
9*67e74705SXin Li // Check diagnostic with location in original source:
10*67e74705SXin Li // RUN: not %clang_cc1 -include-pch %t.h.pch -emit-obj -o %t.o %s 2> %t.stderr
11*67e74705SXin Li // RUN: grep 'could not find file' %t.stderr
12*67e74705SXin Li 
13*67e74705SXin Li // Oftentimes on Windows there are open handles, and deletion will fail.
14*67e74705SXin Li // REQUIRES: can-remove-opened-file
15*67e74705SXin Li 
qq(S *)16*67e74705SXin Li void qq(S*) {}
17*67e74705SXin Li 
18*67e74705SXin Li #ifdef REDECL
foo()19*67e74705SXin Li float foo() {return 0f;}
20*67e74705SXin Li #endif
21*67e74705SXin Li 
22*67e74705SXin Li #ifdef INSTANTIATION
f()23*67e74705SXin Li void f() {
24*67e74705SXin Li   tf<int>();
25*67e74705SXin Li }
26*67e74705SXin Li #endif
27