xref: /aosp_15_r20/external/clang/test/Modules/ignored_macros.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// First trial: pass -DIGNORED=1 to both. This should obviously work.
2*67e74705SXin Li// RUN: rm -rf %t.modules
3*67e74705SXin Li// RUN: %clang_cc1 -fmodules-cache-path=%t.modules -DIGNORED=1 -fmodules -fimplicit-module-maps -I %S/Inputs -emit-pch -o %t.pch -x objective-c-header %s -verify
4*67e74705SXin Li// RUN: %clang_cc1 -fmodules-cache-path=%t.modules -DIGNORED=1 -fmodules -fimplicit-module-maps -I %S/Inputs -include-pch %t.pch %s -verify
5*67e74705SXin Li
6*67e74705SXin Li// Second trial: pass -DIGNORED=1 only to the second invocation. We
7*67e74705SXin Li// should detect the failure.
8*67e74705SXin Li//
9*67e74705SXin Li// RUN: rm -rf %t.modules
10*67e74705SXin Li// RUN: %clang_cc1 -fmodules-cache-path=%t.modules -fmodules -fimplicit-module-maps -I %S/Inputs -emit-pch -o %t.pch -x objective-c-header %s -verify
11*67e74705SXin Li// RUN: not %clang_cc1 -fmodules-cache-path=%t.modules -DIGNORED=1 -fmodules -fimplicit-module-maps -I %S/Inputs -include-pch %t.pch %s > %t.err 2>&1
12*67e74705SXin Li// RUN: FileCheck -check-prefix=CHECK-CONFLICT %s < %t.err
13*67e74705SXin Li// CHECK-CONFLICT: PCH was compiled with module cache path
14*67e74705SXin Li
15*67e74705SXin Li// Third trial: pass -DIGNORED=1 only to the second invocation, but
16*67e74705SXin Li// make it ignored. There should be no failure, IGNORED is defined in
17*67e74705SXin Li// the translation unit but not the module.
18*67e74705SXin Li// RUN: rm -rf %t.modules
19*67e74705SXin Li// RUN: %clang_cc1 -fmodules-cache-path=%t.modules -fmodules -fimplicit-module-maps -I %S/Inputs -emit-pch -o %t.pch -x objective-c-header %s -verify
20*67e74705SXin Li// RUN: %clang_cc1 -fmodules-cache-path=%t.modules -DIGNORED=1 -fmodules -fimplicit-module-maps -I %S/Inputs -include-pch %t.pch -fmodules-ignore-macro=IGNORED %s -verify
21*67e74705SXin Li
22*67e74705SXin Li// Fourth trial: pass -DIGNORED=1 and -fmodules-ignore-macro=IGNORED
23*67e74705SXin Li// to both invocations, so modules will be built without the IGNORED
24*67e74705SXin Li// macro.
25*67e74705SXin Li// RUN: rm -rf %t.modules
26*67e74705SXin Li// RUN: %clang_cc1 -fmodules-cache-path=%t.modules -DIGNORED=1 -fmodules-ignore-macro=IGNORED -fmodules -fimplicit-module-maps -I %S/Inputs -emit-pch -o %t.pch -x objective-c-header %s -verify
27*67e74705SXin Li// RUN: %clang_cc1 -fmodules-cache-path=%t.modules -DIGNORED=1 -fmodules -fimplicit-module-maps -I %S/Inputs -include-pch %t.pch -fmodules-ignore-macro=IGNORED -DNO_IGNORED_ANYWHERE -fmodules-ignore-macro=NO_IGNORED_ANYWHERE %s -verify
28*67e74705SXin Li
29*67e74705SXin Li// Fifth trial: pass -DIGNORED=1 and -fmodules-ignore-macro=IGNORED=1
30*67e74705SXin Li// to both invocations, so modules will be built without the IGNORED
31*67e74705SXin Li// macro.
32*67e74705SXin Li// RUN: rm -rf %t.modules
33*67e74705SXin Li// RUN: %clang_cc1 -fmodules-cache-path=%t.modules -DIGNORED=1 -fmodules-ignore-macro=IGNORED=1 -fmodules -fimplicit-module-maps -I %S/Inputs -emit-pch -o %t.pch -x objective-c-header %s -verify
34*67e74705SXin Li// RUN: %clang_cc1 -fmodules-cache-path=%t.modules -DIGNORED=1 -fmodules -fimplicit-module-maps -I %S/Inputs -include-pch %t.pch -fmodules-ignore-macro=IGNORED=1 -DNO_IGNORED_ANYWHERE -fmodules-ignore-macro=NO_IGNORED_ANYWHERE %s -verify
35*67e74705SXin Li
36*67e74705SXin Li// expected-no-diagnostics
37*67e74705SXin Li
38*67e74705SXin Li#ifndef HEADER
39*67e74705SXin Li#define HEADER
40*67e74705SXin Li@import ignored_macros;
41*67e74705SXin Li#endif
42*67e74705SXin Li
43*67e74705SXin Li@import ignored_macros;
44*67e74705SXin Li
45*67e74705SXin Listruct Point p;
46*67e74705SXin Li
47*67e74705SXin Li#ifdef NO_IGNORED_ANYWHERE
48*67e74705SXin Livoid *has_ignored(int, int, int);
49*67e74705SXin Li#endif
50