blob: bb5c4169765a5d1088c1f08a2b684a5b227a2ba2 [file] [log] [blame]
Richard Smith96fdab62014-10-28 16:24:08 +00001// 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.
Richard Smith96261dd2014-10-28 16:30:57 +000019// 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
Richard Smith96fdab62014-10-28 16:24:08 +000021
22// Can use the module if -W flags change.
Richard Smith96261dd2014-10-28 16:30:57 +000023// RUN: %clang_cc1 -fmodules -DBAR=2 -Wextra -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s
Richard Smith96fdab62014-10-28 16:24:08 +000024
25// Can use the module if -I flags change.
Richard Smith96261dd2014-10-28 16:30:57 +000026// RUN: %clang_cc1 -fmodules -DBAR=2 -I. -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s
Richard Smith96fdab62014-10-28 16:24:08 +000027
28#include "tmp.h" // expected-no-diagnostics
Richard Smith96261dd2014-10-28 16:30:57 +000029
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