1 // REQUIRES: shell
2 
3 // RUN: rm -rf %t
4 // RUN: mkdir %t
5 // RUN: echo 'module tmp { header "tmp.h" }' > %t/map
6 // RUN: touch %t/tmp.h
7 // RUN: %clang_cc1 -fmodules -DFOO=1 -x c++ -fmodule-name=tmp %t/map -emit-module -o %t/tmp.pcm
8 
9 // Can use the module.
10 // RUN: %clang_cc1 -fmodules -DFOO=1 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s
11 
12 // Can use the module if an input file is newer. (This happens on
13 // remote file systems.)
14 // RUN: sleep 1
15 // RUN: touch %t/tmp.h
16 // RUN: %clang_cc1 -fmodules -DFOO=1 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s
17 
18 // Can use the module if -D flags change.
19 // RUN: %clang_cc1 -fmodules -DFOO=2 -DBAR=1 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s
20 // RUN: %clang_cc1 -fmodules -DBAR=2 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s
21 
22 // Can use the module if -W flags change.
23 // RUN: %clang_cc1 -fmodules -DBAR=2 -Wextra -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s
24 
25 // Can use the module if -I flags change.
26 // RUN: %clang_cc1 -fmodules -DBAR=2 -I. -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s
27 
28 #include "tmp.h" // expected-no-diagnostics
29 
30 #ifndef BAR
31 #if FOO != 1
32 #error bad FOO from command line and module
33 #endif
34 #elif BAR == 1
35 #if FOO != 2
36 #error bad FOO from command line overriding module
37 #endif
38 #elif BAR == 2
39 #ifdef FOO
40 #error FOO leaked from module
41 #endif
42 #else
43 #error bad BAR
44 #endif
45