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