|
| 1 | +// RUN: rm -rf %t |
| 2 | +// RUN: not %clang_cc1 -x c++ -Rmodule-build -DMISSING_HEADER -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/auto-import-unavailable %s 2>&1 | FileCheck %s --check-prefix=MISSING-HEADER |
| 3 | +// RUN: %clang_cc1 -x c++ -Rmodule-build -DNONREQUIRED_MISSING_HEADER -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/auto-import-unavailable %s 2>&1 | FileCheck %s --check-prefix=NONREQUIRED-MISSING-HEADER |
| 4 | +// RUN: not %clang_cc1 -x c++ -Rmodule-build -DMISSING_REQUIREMENT -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/auto-import-unavailable %s 2>&1 | FileCheck %s --check-prefix=MISSING-REQUIREMENT |
| 5 | + |
| 6 | +#ifdef MISSING_HEADER |
| 7 | + |
| 8 | +// Even if the header we ask for is not missing, if the top-level module |
| 9 | +// containing it has a missing header, then the whole top-level is |
| 10 | +// unavailable and we issue an error. |
| 11 | + |
| 12 | +// MISSING-HEADER: module.modulemap:2:27: error: header 'missing_header/missing.h' not found |
| 13 | +// MISSING-HEADER-DAG: auto-import-unavailable.cpp:[[@LINE+1]]:10: note: submodule of top-level module 'missing_header' implicitly imported here |
| 14 | +#include "missing_header/not_missing.h" |
| 15 | + |
| 16 | +// We should not attempt to build the module. |
| 17 | +// MISSING-HEADER-NOT: remark: building module |
| 18 | + |
| 19 | +#endif // #ifdef MISSING_HEADER |
| 20 | + |
| 21 | + |
| 22 | +#ifdef NONREQUIRED_MISSING_HEADER |
| 23 | + |
| 24 | +// However, if the missing header is dominated by an unsatisfied |
| 25 | +// `requires`, then that is acceptable. |
| 26 | +// This also tests that an unsatisfied `requires` elsewhere in the |
| 27 | +// top-level module doesn't affect an available module. |
| 28 | + |
| 29 | +// NONREQUIRED-MISSING-HEADER: auto-import-unavailable.cpp:[[@LINE+2]]:10: remark: building module 'nonrequired_missing_header' |
| 30 | +// NONREQUIRED-MISSING-HEADER: auto-import-unavailable.cpp:[[@LINE+1]]:10: remark: finished building module 'nonrequired_missing_header' |
| 31 | +#include "nonrequired_missing_header/not_missing.h" |
| 32 | + |
| 33 | +#endif // #ifdef NONREQUIRED_MISSING_HEADER |
| 34 | + |
| 35 | + |
| 36 | +#ifdef MISSING_REQUIREMENT |
| 37 | + |
| 38 | +// If the header is unavailable due to a missing requirement, an error |
| 39 | +// should be emitted if a user tries to include it. |
| 40 | + |
| 41 | +// MISSING-REQUIREMENT:module.modulemap:16:8: error: module 'missing_requirement' requires feature 'nonexistent_feature' |
| 42 | +// MISSING-REQUIREMENT: auto-import-unavailable.cpp:[[@LINE+1]]:10: note: submodule of top-level module 'missing_requirement' implicitly imported here |
| 43 | +#include "missing_requirement.h" |
| 44 | + |
| 45 | +// MISSING-REQUIREMENT-NOT: remark: building module |
| 46 | + |
| 47 | +#endif // #ifdef MISSING_REQUIREMENT |
0 commit comments