| 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 |
|
| 10 |
// Can use the module if an input file is newer. (This happens on remote file systems.) |
| 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. |
| 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 |
| 18 |
|
| 19 |
// Can use the module if -W flags change. |
| 20 |
// RUN: %clang_cc1 -fmodules -DBAR=2 -Wextra -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s |
| 21 |
|
| 22 |
// Can use the module if -I flags change. |
| 23 |
// RUN: %clang_cc1 -fmodules -DBAR=2 -I. -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s |
| 24 |
|
| 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 -pic-level 1 -pic-is-pie -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 |
|
| 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 |
|
| 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 |
|
| 48 |
#include "tmp.h" // expected-no-diagnostics |
| 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 |