From e4a6190fd49a4f0f89663d56021659d37d5a2a96 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Mon, 9 Jun 2025 14:40:24 -0700 Subject: [PATCH] tests: add a new test for the ClangImporter Add a test case for shadowing definitions that are often used for retraoctive aliasing and forward compatibility. --- .../ClangImporter/Inputs/custom-modules/module.modulemap | 4 ++++ test/ClangImporter/Inputs/custom-modules/versioning.h | 9 +++++++++ test/ClangImporter/versioning.swift | 7 +++++++ 3 files changed, 20 insertions(+) create mode 100644 test/ClangImporter/Inputs/custom-modules/versioning.h create mode 100644 test/ClangImporter/versioning.swift diff --git a/test/ClangImporter/Inputs/custom-modules/module.modulemap b/test/ClangImporter/Inputs/custom-modules/module.modulemap index 2bd2627191949..89ccced682ba0 100644 --- a/test/ClangImporter/Inputs/custom-modules/module.modulemap +++ b/test/ClangImporter/Inputs/custom-modules/module.modulemap @@ -279,3 +279,7 @@ module "Weird C Module" { module Aliases { header "Aliases.h" } + +module RetroactiveVersioning { + header "versioning.h" +} diff --git a/test/ClangImporter/Inputs/custom-modules/versioning.h b/test/ClangImporter/Inputs/custom-modules/versioning.h new file mode 100644 index 0000000000000..dcc6bb0840ee7 --- /dev/null +++ b/test/ClangImporter/Inputs/custom-modules/versioning.h @@ -0,0 +1,9 @@ +#pragma once +extern const int kVersion; +extern const int kVersion1; +extern const int kVersion2; +#if OLD_DEPLOYMENT_TARGET +#define kVersion kVersion1 +#else +#define kVersion kVersion2 +#endif diff --git a/test/ClangImporter/versioning.swift b/test/ClangImporter/versioning.swift new file mode 100644 index 0000000000000..a5077b92ecd1f --- /dev/null +++ b/test/ClangImporter/versioning.swift @@ -0,0 +1,7 @@ +// RUN: %target-typecheck-verify-swift %s -I %S/Inputs/custom-modules +// XFAIL: * + +// expected-no-diagnostics + +import RetroactiveVersioning +let _ = kVersion