From 09bc471e872fb5e726c086a61b676e40d80c5a1a Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Mon, 1 Apr 2019 10:53:54 -0700 Subject: [PATCH] test: add a test for `ll` suffixed types being promoted to ULL This addresses the follow up test case discussed in PR23651. Windows will not promote a macro literal suffixed with `ll` or `i64` to an unsigned long long even upon an overflow. This tests that the corner case behaviour for importing a long long literal matches the platform expectations. --- test/ClangImporter/long-long-promotion.swift | 16 ++++++++++++++++ .../clang-importer-sdk/usr/include/macros.h | 2 ++ 2 files changed, 18 insertions(+) create mode 100644 test/ClangImporter/long-long-promotion.swift diff --git a/test/ClangImporter/long-long-promotion.swift b/test/ClangImporter/long-long-promotion.swift new file mode 100644 index 00000000000..d700855b024 --- /dev/null +++ b/test/ClangImporter/long-long-promotion.swift @@ -0,0 +1,16 @@ +// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -verify %s + +import macros + +func verifyIsSigned(_: Int64) { } +func verifyIsUnsigned(_: UInt64) { } + +// Windows will not convert a long long value that overflows into an unsigned +// long long if it has the `ll` suffix of `i64` suffix. Ensure that the type is +// imported appropriately. +#if os(Windows) +verifyIsSigned(LL_TO_ULL) +#else +verifyIsUnsigned(LL_TO_ULL) +#endif + diff --git a/test/Inputs/clang-importer-sdk/usr/include/macros.h b/test/Inputs/clang-importer-sdk/usr/include/macros.h index 537c83288a4..60865eccc69 100644 --- a/test/Inputs/clang-importer-sdk/usr/include/macros.h +++ b/test/Inputs/clang-importer-sdk/usr/include/macros.h @@ -25,6 +25,8 @@ #define TRUE 1 #define FALSE 0 +#define LL_TO_ULL 0x8000000000000000LL + #define A_PI M_PI #define VERSION_STRING "Swift 1.0"