Files
TheRock/compiler/amd-llvm/clang/test/Modules/pch-config-macros.c
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

94 lines
3.7 KiB
C

// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: cd %t
// This test builds two PCHs. bridging.h.pch depends on h1.h.pch.
// Then the test uses bridiging.h.pch in a source file that imports
// a module with config macros.
// The warnings should not fire if the config macros are specified when
// building the pch and the main TU.
// This is a normal use case and no warnings should be issued.
// RUN: %clang_cc1 -fmodules \
// RUN: -fmodule-map-file=%S/Inputs/pch-config-macros/include/module.modulemap \
// RUN: -fmodules-cache-path=%t/cache -I %S/Inputs/pch-config-macros/include \
// RUN: %t/h1.h -emit-pch -o %t/h1.h.pch -DCONFIG1 -DCONFIG2
// RUN: %clang_cc1 -fmodules \
// RUN: -fmodule-map-file=%S/Inputs/pch-config-macros/include/module.modulemap \
// RUN: -fmodules-cache-path=%t/cache -I %S/Inputs/pch-config-macros/include \
// RUN: -include-pch %t/h1.h.pch %t/bridging.h -emit-pch -o %t/bridging.h.pch \
// RUN: -DCONFIG1 -DCONFIG2
// RUN: %clang_cc1 -fmodules \
// RUN: -fmodule-map-file=%S/Inputs/pch-config-macros/include/module.modulemap \
// RUN: -fmodules-cache-path=%t/cache -I %S/Inputs/pch-config-macros/include \
// RUN: -emit-obj -o %t/main.o %t/main.c -include-pch %t/bridging.h.pch \
// RUN: -DCONFIG1 -DCONFIG2 -verify
// Checking that the warnings fire correctly when we compile with a chain of
// PCHs.
// RUN: %clang_cc1 -fmodules \
// RUN: -fmodule-map-file=%S/Inputs/pch-config-macros/include/module.modulemap \
// RUN: -fmodules-cache-path=%t/cache -I %S/Inputs/pch-config-macros/include \
// RUN: -emit-obj -o %t/compile_warning_1.o %t/compile_warning_1.c -include-pch \
// RUN: %t/bridging.h.pch -DCONFIG1 -DCONFIG2 -verify
// RUN: %clang_cc1 -fmodules \
// RUN: -fmodule-map-file=%S/Inputs/pch-config-macros/include/module.modulemap \
// RUN: -fmodules-cache-path=%t/cache -I %S/Inputs/pch-config-macros/include \
// RUN: -emit-obj -o %t/compile_warning_2.o %t/compile_warning_2.c -include-pch \
// RUN: %t/bridging.h.pch -DCONFIG1 -DCONFIG2 -verify
// RUN: %clang_cc1 -fmodules \
// RUN: -fmodule-map-file=%S/Inputs/pch-config-macros/include/module.modulemap \
// RUN: -fmodules-cache-path=%t/cache -I %S/Inputs/pch-config-macros/include \
// RUN: -emit-obj -o %t/compile_warning_3.o %t/compile_warning_3.c -include-pch \
// RUN: %t/bridging.h.pch -DCONFIG1 -DCONFIG2 -verify
//--- h1.h
#if CONFIG1
int bar1() { return 42; }
#else
int bar2() { return 43; }
#endif
//--- bridging.h
#if CONFIG1
int bar() { return bar1(); }
#else
int bar() { return bar2(); }
#endif
#if CONFIG2
int baz() { return 77; }
#endif
//--- main.c
#include "Mod1.h"
// expected-no-diagnostics
int main_func() {
return foo() + bar();
}
// Checks against expected warnings.
//--- compile_warning_1.c
#undef CONFIG1 // expected-note{{macro was #undef'd here}}
#include "Mod1.h" // expected-warning{{#undef of configuration macro 'CONFIG1' has no effect on the import of 'Mod1'; pass '-UCONFIG1' on the command line to configure the module}}
int main_func() {
return foo() + bar();
}
//--- compile_warning_2.c
#define CONFIG3 // expected-note{{macro was defined here}}
#include "Mod1.h" // expected-warning{{definition of configuration macro 'CONFIG3' has no effect on the import of 'Mod1'; pass '-DCONFIG3=...' on the command line to configure the module}}
int main_func() {
return foo() + bar();
}
//--- compile_warning_3.c
#define CONFIG1 2 // expected-warning{{'CONFIG1' macro redefined}} expected-note{{previous definition is here}} expected-note{{macro was defined here}}
#include "Mod1.h" // expected-warning{{definition of configuration macro 'CONFIG1' has no effect on the import of 'Mod1'; pass '-DCONFIG1=...' on the command line to configure the module}}
int main_func() {
return foo() + bar();
}