Richard Smith | 96fdab6 | 2014-10-28 16:24:08 +0000 | [diff] [blame] | 1 | // RUN: rm -rf %t |
| 2 | // RUN: mkdir %t |
| 3 | // RUN: echo 'module tmp { header "tmp.h" }' > %t/map |
| 4 | // RUN: touch %t/tmp.h |
| 5 | // RUN: %clang_cc1 -fmodules -DFOO=1 -x c++ -fmodule-name=tmp %t/map -emit-module -o %t/tmp.pcm |
| 6 | |
| 7 | // Can use the module. |
| 8 | // RUN: %clang_cc1 -fmodules -DFOO=1 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s |
| 9 | |
Richard Smith | a1ddf5e | 2016-04-07 20:47:37 +0000 | [diff] [blame] | 10 | // Can use the module if an input file is newer. (This happens on remote file systems.) |
Richard Smith | 96fdab6 | 2014-10-28 16:24:08 +0000 | [diff] [blame] | 11 | // RUN: sleep 1 |
| 12 | // RUN: touch %t/tmp.h |
| 13 | // RUN: %clang_cc1 -fmodules -DFOO=1 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s |
| 14 | |
| 15 | // Can use the module if -D flags change. |
Richard Smith | 96261dd | 2014-10-28 16:30:57 +0000 | [diff] [blame] | 16 | // RUN: %clang_cc1 -fmodules -DFOO=2 -DBAR=1 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s |
| 17 | // RUN: %clang_cc1 -fmodules -DBAR=2 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s |
Richard Smith | 96fdab6 | 2014-10-28 16:24:08 +0000 | [diff] [blame] | 18 | |
| 19 | // Can use the module if -W flags change. |
Richard Smith | 96261dd | 2014-10-28 16:30:57 +0000 | [diff] [blame] | 20 | // RUN: %clang_cc1 -fmodules -DBAR=2 -Wextra -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s |
Richard Smith | 96fdab6 | 2014-10-28 16:24:08 +0000 | [diff] [blame] | 21 | |
| 22 | // Can use the module if -I flags change. |
Richard Smith | 96261dd | 2014-10-28 16:30:57 +0000 | [diff] [blame] | 23 | // RUN: %clang_cc1 -fmodules -DBAR=2 -I. -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s |
Richard Smith | 96fdab6 | 2014-10-28 16:24:08 +0000 | [diff] [blame] | 24 | |
Richard Smith | a1ddf5e | 2016-04-07 20:47:37 +0000 | [diff] [blame] | 25 | // Can use the module if -fPIC/-fPIE flags change. |
| 26 | // RUN: %clang_cc1 -fmodules -DBAR=2 -pic-level 2 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s |
| 27 | // RUN: %clang_cc1 -fmodules -DBAR=2 -pie-level 1 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s |
| 28 | |
| 29 | // Can use the module if -static flag changes. |
| 30 | // RUN: %clang_cc1 -fmodules -DBAR=2 -static-define -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s |
| 31 | |
| 32 | // Can use the module if -fsanitize= flags change. |
| 33 | // RUN: %clang_cc1 -fmodules -DBAR=2 -fsanitize=address -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s |
| 34 | // |
| 35 | // RUN: %clang_cc1 -fmodules -DFOO=1 -fsanitize=address -x c++ -fmodule-name=tmp %t/map -emit-module -o %t/tmp-san.pcm |
| 36 | // RUN: %clang_cc1 -fmodules -DBAR=2 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp-san.pcm -verify -I%t %s |
| 37 | |
Richard Smith | 351241c | 2016-04-07 21:46:12 +0000 | [diff] [blame] | 38 | // -fno-assume-sane-operator-new is implied by the driver -fsanitize=address flag. |
| 39 | // RUN: %clang_cc1 -fmodules -DBAR=2 -fno-assume-sane-operator-new -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s |
| 40 | |
Richard Smith | 1e2cf0d | 2014-10-31 02:28:58 +0000 | [diff] [blame] | 41 | // Can use the module if -O flags change. |
| 42 | // RUN: %clang_cc1 -fmodules -DBAR=2 -Os -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s |
| 43 | // |
| 44 | // RUN: %clang_cc1 -fmodules -DFOO=1 -O2 -x c++ -fmodule-name=tmp %t/map -emit-module -o %t/tmp-O2.pcm |
| 45 | // RUN: %clang_cc1 -fmodules -DBAR=2 -O0 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp-O2.pcm -verify -I%t %s |
| 46 | // RUN: %clang_cc1 -fmodules -DBAR=2 -Os -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp-O2.pcm -verify -I%t %s |
| 47 | |
Richard Smith | 96fdab6 | 2014-10-28 16:24:08 +0000 | [diff] [blame] | 48 | #include "tmp.h" // expected-no-diagnostics |
Richard Smith | 96261dd | 2014-10-28 16:30:57 +0000 | [diff] [blame] | 49 | |
| 50 | #ifndef BAR |
| 51 | #if FOO != 1 |
| 52 | #error bad FOO from command line and module |
| 53 | #endif |
| 54 | #elif BAR == 1 |
| 55 | #if FOO != 2 |
| 56 | #error bad FOO from command line overriding module |
| 57 | #endif |
| 58 | #elif BAR == 2 |
| 59 | #ifdef FOO |
| 60 | #error FOO leaked from module |
| 61 | #endif |
| 62 | #else |
| 63 | #error bad BAR |
| 64 | #endif |