blob: 39fd8d1e41b8a8039daf09d0587e3bb0a90f5c62 [file] [log] [blame]
Richard Smith96fdab62014-10-28 16:24:08 +00001// 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 Smitha1ddf5e2016-04-07 20:47:37 +000010// Can use the module if an input file is newer. (This happens on remote file systems.)
Richard Smith96fdab62014-10-28 16:24:08 +000011// 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 Smith96261dd2014-10-28 16:30:57 +000016// 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 Smith96fdab62014-10-28 16:24:08 +000018
19// Can use the module if -W flags change.
Richard Smith96261dd2014-10-28 16:30:57 +000020// 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 +000021
22// Can use the module if -I flags change.
Richard Smith96261dd2014-10-28 16:30:57 +000023// 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 +000024
Richard Smitha1ddf5e2016-04-07 20:47:37 +000025// 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 Smith351241c2016-04-07 21:46:12 +000038// -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 Smith1e2cf0d2014-10-31 02:28:58 +000041// 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 Smith96fdab62014-10-28 16:24:08 +000048#include "tmp.h" // expected-no-diagnostics
Richard Smith96261dd2014-10-28 16:30:57 +000049
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