xref: /aosp_15_r20/external/clang/test/Modules/config_macros.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li@import config;
2*67e74705SXin Li
3*67e74705SXin Liint *test_foo() {
4*67e74705SXin Li  return foo();
5*67e74705SXin Li}
6*67e74705SXin Li
7*67e74705SXin Lichar *test_bar() {
8*67e74705SXin Li  return bar(); // expected-warning{{implicit declaration of function 'bar' is invalid in C99}} \
9*67e74705SXin Li                // expected-warning{{incompatible integer to pointer conversion}}
10*67e74705SXin Li}
11*67e74705SXin Li
12*67e74705SXin Li#undef WANT_FOO // expected-note{{macro was #undef'd here}}
13*67e74705SXin Li@import config; // expected-warning{{#undef of configuration macro 'WANT_FOO' has no effect on the import of 'config'; pass '-UWANT_FOO' on the command line to configure the module}}
14*67e74705SXin Li
15*67e74705SXin Li#define WANT_FOO 2 // expected-note{{macro was defined here}}
16*67e74705SXin Li@import config; // expected-warning{{definition of configuration macro 'WANT_FOO' has no effect on the import of 'config'; pass '-DWANT_FOO=...' on the command line to configure the module}}
17*67e74705SXin Li
18*67e74705SXin Li#undef WANT_FOO
19*67e74705SXin Li#define WANT_FOO 1
20*67e74705SXin Li@import config; // okay
21*67e74705SXin Li
22*67e74705SXin Li#define WANT_BAR 1 // expected-note{{macro was defined here}}
23*67e74705SXin Li@import config; // expected-warning{{definition of configuration macro 'WANT_BAR' has no effect on the import of 'config'; pass '-DWANT_BAR=...' on the command line to configure the module}}
24*67e74705SXin Li
25*67e74705SXin Li// RUN: rm -rf %t
26*67e74705SXin Li// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -x objective-c -fmodules-cache-path=%t -DWANT_FOO=1 -emit-module -fmodule-name=config %S/Inputs/module.map
27*67e74705SXin Li// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs -DWANT_FOO=1 %s -verify
28*67e74705SXin Li
29