Skip to content

Commit 09bc471

Browse files
committed
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.
1 parent f85ca6c commit 09bc471

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -verify %s
2+
3+
import macros
4+
5+
func verifyIsSigned(_: Int64) { }
6+
func verifyIsUnsigned(_: UInt64) { }
7+
8+
// Windows will not convert a long long value that overflows into an unsigned
9+
// long long if it has the `ll` suffix of `i64` suffix. Ensure that the type is
10+
// imported appropriately.
11+
#if os(Windows)
12+
verifyIsSigned(LL_TO_ULL)
13+
#else
14+
verifyIsUnsigned(LL_TO_ULL)
15+
#endif
16+

test/Inputs/clang-importer-sdk/usr/include/macros.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#define TRUE 1
2626
#define FALSE 0
2727

28+
#define LL_TO_ULL 0x8000000000000000LL
29+
2830
#define A_PI M_PI
2931

3032
#define VERSION_STRING "Swift 1.0"

0 commit comments

Comments
 (0)