From 0e177f67d4b4f9e17209484920c38786ad699396 Mon Sep 17 00:00:00 2001 From: Jonah Jeleniewski Date: Thu, 27 Mar 2025 14:48:19 +1100 Subject: [PATCH] Define the `WEAK_NATIVEINT` conditional on Delphi 12+ --- CHANGELOG.md | 4 ++++ .../integradev/delphi/compiler/PredefinedConditionals.java | 4 ++++ .../delphi/compiler/PredefinedConditionalsTest.java | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce597f09f..c0586b574 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Support for the `WEAK_NATIVEINT` symbol, which is defined from Delphi 12 onward. + ### Changed - Exclude types annotated with attributes in `UnusedType`. diff --git a/delphi-frontend/src/main/java/au/com/integradev/delphi/compiler/PredefinedConditionals.java b/delphi-frontend/src/main/java/au/com/integradev/delphi/compiler/PredefinedConditionals.java index 77bd803e8..80f768c8b 100644 --- a/delphi-frontend/src/main/java/au/com/integradev/delphi/compiler/PredefinedConditionals.java +++ b/delphi-frontend/src/main/java/au/com/integradev/delphi/compiler/PredefinedConditionals.java @@ -226,6 +226,10 @@ private Set getAvailabilityConditionalDefines() { result.add("WEAKINTFREF"); } + if (compilerVersion.compareTo(VERSION_ATHENS) >= 0) { + result.add("WEAK_NATIVEINT"); + } + if (checkToolchain(Toolchain.DCCIOSSIMARM64)) { result.add("IOSSIMULATOR"); } diff --git a/delphi-frontend/src/test/java/au/com/integradev/delphi/compiler/PredefinedConditionalsTest.java b/delphi-frontend/src/test/java/au/com/integradev/delphi/compiler/PredefinedConditionalsTest.java index 4d6efe902..b57d26f9e 100644 --- a/delphi-frontend/src/test/java/au/com/integradev/delphi/compiler/PredefinedConditionalsTest.java +++ b/delphi-frontend/src/test/java/au/com/integradev/delphi/compiler/PredefinedConditionalsTest.java @@ -406,4 +406,11 @@ void testToolchainsBeforeDelphiAthensShouldNotDefineLLVM(Toolchain toolchain) { assertThat(PredefinedConditionals.getConditionalDefines(toolchain, VERSION_ALEXANDRIA)) .doesNotContain("LLVM"); } + + @ParameterizedTest + @EnumSource(value = Toolchain.class) + void testAllToolchainsAfterDelphiAlexandriaShouldDefineWeakNativeInt(Toolchain toolchain) { + assertThat(PredefinedConditionals.getConditionalDefines(toolchain, VERSION_ATHENS)) + .contains("WEAK_NATIVEINT"); + } }