Skip to content

Commit 65b882d

Browse files
authored
Merge pull request #4768 from kinke/merge_stable
Merge upstream stable
2 parents 495578b + aab2713 commit 65b882d

File tree

18 files changed

+163
-12
lines changed

18 files changed

+163
-12
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# LDC master
22

33
#### Big news
4-
- Frontend, druntime and Phobos are at version [2.110.0](https://dlang.org/changelog/2.110.0.html). (#4707, #4737, #4749)
4+
- Frontend, druntime and Phobos are at version [2.110.0](https://dlang.org/changelog/2.110.0.html). (#4707, #4737, #4749, #4768)
55
- LLVM for prebuilt packages bumped to v18.1.8 (incl. macOS arm64). (#4712)
66
- Android: NDK for prebuilt package bumped from r26d to r27. (#4711)
77
- ldc2.conf: %%ldcconfigpath%% placeholder added - specifies the directory where current configuration file is located. (#4717)

dmd/dcast.d

+1-1
Original file line numberDiff line numberDiff line change
@@ -2336,7 +2336,7 @@ Expression castTo(Expression e, Scope* sc, Type t, Type att = null)
23362336
Type tb = t.toBasetype();
23372337
Type typeb = e.type.toBasetype();
23382338

2339-
if (e.hexString && !e.committed)
2339+
if (e.hexString && !e.committed && tb.nextOf().isintegral)
23402340
{
23412341
const szx = cast(ubyte) tb.nextOf().size();
23422342
if (szx != se.sz && (e.len % szx) == 0)

dmd/dinterpret.d

+1-1
Original file line numberDiff line numberDiff line change
@@ -6136,7 +6136,7 @@ public:
61366136
{
61376137
auto se = e1.isStringExp();
61386138
// Allow casting a hex string literal to short[], int[] or long[]
6139-
if (se && se.hexString && se.postfix == StringExp.NoPostfix)
6139+
if (se && se.hexString && se.postfix == StringExp.NoPostfix && e.to.nextOf().isintegral)
61406140
{
61416141
const sz = cast(size_t) e.to.nextOf().size;
61426142
if ((se.len % sz) != 0)

dmd/enumsem.d

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ void enumSemantic(Scope* sc, EnumDeclaration ed)
186186

187187
if (ed.members.length == 0)
188188
{
189-
.error(ed.loc, "%s `%s enum `%s` must have at least one member", ed.kind, ed.toPrettyChars, ed.toChars());
189+
.error(ed.loc, "%s `%s` enum `%s` must have at least one member", ed.kind, ed.toPrettyChars, ed.toChars());
190190
ed.errors = true;
191191
ed.semanticRun = PASS.semanticdone;
192192
return;

dmd/hdrgen.d

+4-4
Original file line numberDiff line numberDiff line change
@@ -1726,10 +1726,10 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
17261726
//printf("FuncDeclaration::toCBuffer() '%s'\n", f.toChars());
17271727
if (stcToBuffer(buf, f.storage_class))
17281728
buf.writeByte(' ');
1729+
typeToBuffer(f.type, f.ident, buf, hgs);
17291730
auto tf = f.type.isTypeFunction();
1730-
typeToBuffer(tf, f.ident, buf, hgs);
17311731

1732-
if (hgs.hdrgen)
1732+
if (hgs.hdrgen && tf)
17331733
{
17341734
// if the return type is missing (e.g. ref functions or auto)
17351735
// https://issues.dlang.org/show_bug.cgi?id=20090
@@ -1864,9 +1864,9 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
18641864
if (stcToBuffer(buf, d.storage_class))
18651865
buf.writeByte(' ');
18661866
buf.writestring("invariant");
1867-
if(auto es = d.fbody.isExpStatement())
1867+
auto es = d.fbody.isExpStatement();
1868+
if (es && es.exp && es.exp.op == EXP.assert_)
18681869
{
1869-
assert(es.exp && es.exp.op == EXP.assert_);
18701870
buf.writestring(" (");
18711871
(cast(AssertExp)es.exp).e1.expressionToBuffer(buf, hgs);
18721872
buf.writestring(");");

dmd/parse.d

+1
Original file line numberDiff line numberDiff line change
@@ -9749,6 +9749,7 @@ immutable PREC[EXP.max + 1] precedence =
97499749
EXP.assign : PREC.assign,
97509750
EXP.construct : PREC.assign,
97519751
EXP.blit : PREC.assign,
9752+
EXP.loweredAssignExp : PREC.assign,
97529753
EXP.addAssign : PREC.assign,
97539754
EXP.minAssign : PREC.assign,
97549755
EXP.concatenateAssign : PREC.assign,

dmd/typesem.d

+3-1
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,9 @@ extern (D) MATCH callMatch(TypeFunction tf, Type tthis, ArgumentList argumentLis
835835
L1:
836836
if (parameterList.varargs == VarArg.typesafe && u + 1 == nparams) // if last varargs param
837837
{
838-
auto trailingArgs = args[u .. $];
838+
Expression[] trailingArgs;
839+
if (args.length >= u)
840+
trailingArgs = args[u .. $];
839841
if (auto vmatch = matchTypeSafeVarArgs(tf, p, trailingArgs, pMessage))
840842
return vmatch < match ? vmatch : match;
841843
// Error message was already generated in `matchTypeSafeVarArgs`

runtime/druntime/src/importc.h

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#define __alignof _Alignof
4242
#define __vector_size__ vector_size
4343
#define __typeof typeof
44+
#define __typeof__ typeof
4445

4546
/********************
4647
* Clang nullability extension used by macOS headers.

tests/dmd/compilable/extra-files/vcg-ast.d.cg

+21-1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ void main()
100100
values();
101101
return 0;
102102
}
103+
import imports.vcg_ast_import;
104+
template imported()
105+
{
106+
import imported = imports.vcg_ast_import;
107+
}
108+
alias myImport = vcg_ast_import;
103109
R!int
104110
{
105111
struct _R
@@ -137,6 +143,21 @@ mixin _d_cmain!();
137143
}
138144
}
139145
}
146+
imported!()
147+
{
148+
import object;
149+
struct O
150+
{
151+
invariant
152+
{
153+
}
154+
invariant
155+
{
156+
__invariant0();
157+
}
158+
}
159+
160+
}
140161
RTInfo!(C)
141162
{
142163
enum immutable(void)* RTInfo = null;
@@ -161,4 +182,3 @@ RTInfo!(_R)
161182
enum immutable(void)* RTInfo = null;
162183

163184
}
164-
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
struct O
2+
{
3+
invariant() {}
4+
}

tests/dmd/compilable/test24760.d

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// https://issues.dlang.org/show_bug.cgi?id=24760
2+
3+
long f(int e = 0, uint[] optional...) => optional.length;
4+
long f0() => f(); // compiler segfaults

tests/dmd/compilable/vcg-ast-arraylength.d

+5
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@ void main()
2323

2424
static assert(is(typeof(a.length = 0) == size_t));
2525
static assert(is(typeof(a.length = f.length = 0) == size_t));
26+
27+
// https://issues.dlang.org/show_bug.cgi?id=24790
28+
struct S { int[] payload; }
29+
S s;
30+
s.payload.length += 3;
2631
}

tests/dmd/compilable/vcg-ast.d

+12
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ REQUIRED_ARGS: -vcg-ast -o-
33
PERMUTE_ARGS:
44
OUTPUT_FILES: compilable/vcg-ast.d.cg
55
TRANSFORM_OUTPUT: remove_lines(LDC_profile_instr)
6+
EXTRA_FILES: imports/vcg_ast_import.d
67
TEST_OUTPUT_FILE: extra-files/vcg-ast.d.cg
78
*/
89

@@ -64,3 +65,14 @@ void main()
6465
{
6566
values!wchar_t;
6667
}
68+
69+
// https://issues.dlang.org/show_bug.cgi?id=24764
70+
71+
import imports.vcg_ast_import;
72+
73+
template imported()
74+
{
75+
import imported = imports.vcg_ast_import;
76+
}
77+
78+
alias myImport = imported!();
+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
REQUIRED_ARGS: -vcg-ast -o-
3+
OUTPUT_FILES: compilable/vcg_ast_compilable.d.cg
4+
TEST_OUTPUT:
5+
---
6+
=== compilable/vcg_ast_compilable.d.cg
7+
import object;
8+
auto binaryFun(E)(E b)
9+
{
10+
return 'a' == b;
11+
}
12+
void find(Element)(Element needle) if (is(typeof(binaryFun(needle))))
13+
{
14+
}
15+
void find()(string needle)
16+
{
17+
}
18+
void splitter()
19+
{
20+
find(3);
21+
find("");
22+
}
23+
binaryFun!int
24+
{
25+
auto pure nothrow @nogc @safe bool binaryFun(int b)
26+
{
27+
return 97 == b;
28+
}
29+
30+
}
31+
find!int
32+
{
33+
pure nothrow @nogc @safe void find(int needle)
34+
{
35+
}
36+
37+
}
38+
binaryFun!string
39+
{
40+
auto _error_ binaryFun
41+
{
42+
__error__
43+
}
44+
45+
}
46+
find!()
47+
{
48+
pure nothrow @nogc @safe void find(string needle)
49+
{
50+
}
51+
52+
}
53+
---
54+
*/
55+
56+
// https://issues.dlang.org/show_bug.cgi?id=24431
57+
auto binaryFun(E)(E b)
58+
{
59+
return 'a' == b;
60+
}
61+
62+
void find(Element)(Element needle) if (is(typeof(binaryFun(needle)))) { }
63+
void find()(string needle) { }
64+
65+
void splitter()
66+
{
67+
find!int(3);
68+
find!()("");
69+
}
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
TEST_OUTPUT:
3+
---
4+
fail_compilation/diag24812.d(7): Error: enum `diag24812.Foo` enum `Foo` must have at least one member
5+
---
6+
*/
7+
enum Foo {}

tests/dmd/fail_compilation/hexstring.d

+9-1
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ fail_compilation/hexstring.d(39): perhaps remove postfix `c` from hex str
1414
fail_compilation/hexstring.d(40): Error: hex string with `dstring` type needs to be multiple of 4 bytes, not 5
1515
fail_compilation/hexstring.d(41): Error: cannot implicitly convert expression `x"11223344"d` of type `dstring` to `immutable(float[])`
1616
fail_compilation/hexstring.d(42): Error: cannot implicitly convert expression `x"1122"w` of type `wstring` to `immutable(ubyte[])`
17+
fail_compilation/hexstring.d(50): Error: array cast from `string` to `S[]` is not supported at compile time
1718
fail_compilation/hexstring.d(28): Error: cannot implicitly convert expression `x"123F"` of type `string` to `ubyte[]`
1819
---
1920
*/
2021
immutable ubyte[] s0 = x"123F";
2122
static assert(s0[0] == 0x12);
2223
static assert(s0[1] == 0x3F);
2324
immutable byte[] s1 = x"123F";
24-
2525
enum E(X) = cast(X[]) x"AABBCCDD";
2626
static assert(E!int[0] == 0xAABBCCDD);
2727

@@ -40,3 +40,11 @@ immutable uint[] f11 = cast(immutable uint[]) x"AABBCCDD"c;
4040
immutable uint[] f12 = x"1122334455"d;
4141
immutable float[] f13 = x"11223344"d;
4242
immutable ubyte[] f14 = x"1122"w;
43+
44+
// https://issues.dlang.org/show_bug.cgi?id=24832
45+
struct S
46+
{
47+
ushort l0, l1, l2, l3, l4, l5;
48+
}
49+
50+
immutable S[] returnValues = cast(S[]) x"FFFFFFFFFFFFFFFFFFFFFFFF";

tests/dmd/runnable/test24819.d

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import core.stdc.stdio;
2+
3+
pragma(inline, true)
4+
double sqrt(double x)
5+
{
6+
static import core.math;
7+
return core.math.sqrt(x);
8+
}
9+
10+
int main()
11+
{
12+
double q = -5.0;
13+
double r = q + 1.0;
14+
double result = sqrt(-r);
15+
//printf("%f\n", result);
16+
assert(result == 2);
17+
return 0;
18+
}

0 commit comments

Comments
 (0)