Files
TheRock/compiler/amd-llvm/clang/test/Modules/diag-pragma-nonaffecting.cpp
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

51 lines
1.6 KiB
C++

// Test that pragma diagnostic mappings from an explicit module are not
// corrupted by the presence of non-affecting module map files.
//
// When non-affecting module map files are pruned, NonAffectingRanges becomes
// non-empty. Ensure that getAdjustedOffset is not incorrectly applied to
// file-internal byte offsets in WritePragmaDiagnosticMappings, corrupting the
// serialized diagnostic state transition offsets.
// RUN: rm -rf %t
// RUN: split-file %s %t
// Build the module with a non-affecting module map present.
// RUN: %clang_cc1 -std=c++20 -fmodules \
// RUN: -fmodule-map-file=%t/nonaffecting/module.modulemap \
// RUN: -emit-module -fmodule-name=diag_pragma \
// RUN: -x c++ %t/module.modulemap -o %t/diag_pragma.pcm
// Use the module and verify the warning is suppressed.
// RUN: %clang_cc1 -std=c++20 -fmodules \
// RUN: -fmodule-file=%t/diag_pragma.pcm \
// RUN: -I %t -verify %t/main.cpp
//--- module.modulemap
module diag_pragma { header "header.h" }
//--- header.h
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wstring-plus-int"
template<typename T> const char *suppressed(T t) {
return "foo" + t;
}
#pragma clang diagnostic pop
template<typename T> const char *unsuppressed(T t) {
return "bar" + t;
}
//--- nonaffecting/module.modulemap
module nonaffecting {}
//--- main.cpp
#include "header.h"
void test() {
suppressed(0); // no warning expected - suppressed by pragma in module
// expected-warning@header.h:9 {{adding 'int' to a string}}
// expected-note@header.h:9 {{use array indexing}}
unsuppressed(0); // expected-note {{in instantiation of}}
}