blob: 7296d1dc893b3b19562c44b2b217d1385ea58e0a [file] [log] [blame]
Douglas Gregore721f952009-04-28 18:58:38 +00001// Test with pch.
Daniel Dunbara5728872009-12-15 20:14:24 +00002// RUN: %clang_cc1 -emit-pch -DFOO -o %t %S/variables.h
3// RUN: %clang_cc1 -DBAR=int -include-pch %t -fsyntax-only -pedantic %s
Douglas Gregor4c0c7e82012-10-24 23:41:50 +00004// RUN: %clang_cc1 -DFOO -DBAR=int -include-pch %t %s
5// RUN: not %clang_cc1 -DFOO=blah -DBAR=int -include-pch %t %s 2> %t.err
6// RUN: FileCheck -check-prefix=CHECK-FOO %s < %t.err
7// RUN: not %clang_cc1 -UFOO -include-pch %t %s 2> %t.err
8// RUN: FileCheck -check-prefix=CHECK-NOFOO %s < %t.err
9
10// RUN: not %clang_cc1 -DFOO -undef -include-pch %t %s 2> %t.err
11// RUN: FileCheck -check-prefix=CHECK-UNDEF %s < %t.err
Douglas Gregore721f952009-04-28 18:58:38 +000012
13BAR bar = 17;
14
15#ifndef FOO
16# error FOO was not defined
17#endif
18
19#if FOO != 1
20# error FOO has the wrong definition
21#endif
22
23#ifndef BAR
24# error BAR was not defined
25#endif
Douglas Gregor4c0c7e82012-10-24 23:41:50 +000026
27// CHECK-FOO: definition of macro 'FOO' differs between the precompiled header ('1') and the command line ('blah')
28// CHECK-NOFOO: macro 'FOO' was defined in the precompiled header but undef'd on the command line
29
30// CHECK-UNDEF: command line contains '-undef' but precompiled header was not built with it
31