mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00
Allow casting hexstring to int array (#16079)
This commit is contained in:
parent
e93b26e259
commit
ba5402e7ac
11 changed files with 201 additions and 38 deletions
|
@ -241,6 +241,23 @@ void test12950()
|
|||
assert(0b00_00_00_01UL.op12950() == 12951);
|
||||
}
|
||||
|
||||
void testHexstring()
|
||||
{
|
||||
static immutable uint[] x = cast(immutable uint[]) x"FFAADDEE";
|
||||
static assert(x[0] == 0xFFAADDEE);
|
||||
assert(x[0] == 0xFFAADDEE);
|
||||
|
||||
static immutable ulong[] y = cast(immutable ulong[]) x"1122334455667788AABBCCDDEEFF0099";
|
||||
static assert(y[0] == 0x1122334455667788);
|
||||
static assert(y[1] == 0xAABBCCDDEEFF0099);
|
||||
assert(y[0] == 0x1122334455667788);
|
||||
assert(y[1] == 0xAABBCCDDEEFF0099);
|
||||
|
||||
// Test that mangling of StringExp with size 8 is the same as array literal mangling:
|
||||
void f(immutable ulong[] a)() {}
|
||||
static assert(f!y.mangleof == f!([0x1122334455667788, 0xAABBCCDDEEFF0099]).mangleof);
|
||||
}
|
||||
|
||||
/***************************************************/
|
||||
|
||||
int main()
|
||||
|
@ -249,6 +266,7 @@ int main()
|
|||
test2();
|
||||
test13907();
|
||||
test12950();
|
||||
testHexstring();
|
||||
|
||||
printf("Success\n");
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue