blob: f7d00e1aef458f0f2bf7f0d86ea84d979a5ca484 [file] [log] [blame]
Axel Naumann04331162011-01-27 10:55:51 +00001// Test reading of PCH without original input files.
2
3// Generate the PCH, removing the original file:
4// RUN: echo 'struct S{char c; int i; }; void foo() {}' > %t.h
5// RUN: echo 'template <typename T> void tf() { T::foo(); }' >> %t.h
6// RUN: echo '#define RETURN return &i' >> %t.h
7// RUN: %clang_cc1 -x c++ -emit-pch -o %t.h.pch %t.h
8// RUN: rm %t.h
9
10// Check diagnostic with location in original source:
11// RUN: %clang_cc1 -include-pch %t.h.pch -Wpadded -emit-obj %s 2> %t.stderr
12// RUN: grep 'bytes to align' %t.stderr
13
14// Check diagnostic with 2nd location in original source:
15// RUN: not %clang_cc1 -DREDECL -include-pch %t.h.pch -emit-obj %s 2> %t.stderr
16// RUN: grep 'previous definition is here' %t.stderr
17
18// Check diagnostic with instantiation location in original source:
19// RUN: not %clang_cc1 -DINSTANTIATION -include-pch %t.h.pch -emit-obj %s 2> %t.stderr
20// RUN: grep 'cannot be used prior to' %t.stderr
21
22void qq(S*) {}
23
24#ifdef REDECL
25float foo() {return 0f;}
26#endif
27
28#ifdef INSTANTIATION
29void f() {
30 tf<int>();
31}
32#endif