blob: c7849dc6357e3023469444675a0e59e057d2e99b [file] [log] [blame]
Argyrios Kyrtzidis8e3df4d2011-02-15 17:54:22 +00001// Test reading of PCH with changed location of original input files,
2// i.e. invoking header search.
3
4// Generate the original files:
5// RUN: mkdir -p %t_orig/sub %t_orig/sub2
6// RUN: echo 'struct orig_sub{char c; int i; };' > %t_orig/sub/orig_sub.h
7// RUN: echo 'void orig_sub2_1();' > %t_orig/sub2/orig_sub2_1.h
8// RUN: echo '#include "orig_sub2_1.h"' > %t_orig/sub2/orig_sub2.h
9// RUN: echo 'template <typename T> void tf() { orig_sub2_1(); T::foo(); }' >> %t_orig/sub2/orig_sub2.h
10// RUN: echo 'void foo() {}' > %t_orig/tmp2.h
11// RUN: echo '#include "tmp2.h"' > %t_orig/all.h
12// RUN: echo '#include "sub/orig_sub.h"' >> %t_orig/all.h
13// RUN: echo '#include "orig_sub2.h"' >> %t_orig/all.h
14// RUN: echo 'int all();' >> %t_orig/all.h
15
16// Generate the PCH:
17// RUN: cd %t_orig && %clang_cc1 -x c++ -emit-pch -o all.h.pch -Isub2 all.h
18// RUN: rm -rf %t_moved
19// RUN: mv %t_orig %t_moved
20
21// Check diagnostic with location in original source:
22// RUN: %clang_cc1 -include-pch all.h.pch -I%t_moved -I%t_moved/sub2 -Wpadded -emit-obj -o %t.o %s 2> %t.stderr
23// RUN: grep 'struct orig_sub' %t.stderr
24
25// Check diagnostic with 2nd location in original source:
26// RUN: not %clang_cc1 -DREDECL -include-pch all.h.pch -I%t_moved -I%t_moved/sub2 -emit-obj -o %t.o %s 2> %t.stderr
27// RUN: grep 'void foo' %t.stderr
28
29// Check diagnostic with instantiation location in original source:
30// RUN: not %clang_cc1 -DINSTANTIATION -include-pch all.h.pch -I%t_moved -I%t_moved/sub2 -emit-obj -o %t.o %s 2> %t.stderr
31// RUN: grep 'orig_sub2_1' %t.stderr
32
33void qq(orig_sub*) {all();}
34
35#ifdef REDECL
36float foo() {return 0;}
37#endif
38
39#ifdef INSTANTIATION
40void f() {
41 tf<int>();
42}
43#endif