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