blob: 7d5cd111101c743a69adbd3c1707f31c83e5eea8 [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
Axel Naumann04331162011-01-27 10:55:51 +00006// RUN: %clang_cc1 -x c++ -emit-pch -o %t.h.pch %t.h
7// RUN: rm %t.h
8
9// Check diagnostic with location in original source:
Matt Beaumont-Gaydaef9cc2011-02-01 22:44:06 +000010// RUN: %clang_cc1 -include-pch %t.h.pch -Wpadded -emit-obj -o %t.o %s 2> %t.stderr
Axel Naumann04331162011-01-27 10:55:51 +000011// RUN: grep 'bytes to align' %t.stderr
12
13// Check diagnostic with 2nd location in original source:
Matt Beaumont-Gaydaef9cc2011-02-01 22:44:06 +000014// RUN: not %clang_cc1 -DREDECL -include-pch %t.h.pch -emit-obj -o %t.o %s 2> %t.stderr
Axel Naumann04331162011-01-27 10:55:51 +000015// RUN: grep 'previous definition is here' %t.stderr
16
17// Check diagnostic with instantiation location in original source:
Matt Beaumont-Gaydaef9cc2011-02-01 22:44:06 +000018// RUN: not %clang_cc1 -DINSTANTIATION -include-pch %t.h.pch -emit-obj -o %t.o %s 2> %t.stderr
Axel Naumann04331162011-01-27 10:55:51 +000019// RUN: grep 'cannot be used prior to' %t.stderr
20
21void qq(S*) {}
22
23#ifdef REDECL
24float foo() {return 0f;}
25#endif
26
27#ifdef INSTANTIATION
28void f() {
29 tf<int>();
30}
31#endif