Skip to content

Commit 3a0ae9a

Browse files
committed
Merge remote-tracking branch 'origin/dmd-rewrite-stable' into merge_stable
2 parents aa80b6f + 4609289 commit 3a0ae9a

File tree

11 files changed

+88
-25
lines changed

11 files changed

+88
-25
lines changed

dmd/dcast.d

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,12 @@ MATCH implicitConvTo(Expression e, Type t)
703703
if (!tn.isConst() && !tn.isImmutable())
704704
return MATCH.nomatch;
705705
m = MATCH.constant;
706+
707+
// After converting e.g. ubyte[] to const(ubyte)[], don't change
708+
// to MATCH.convert, return MATCH.constant
709+
// https://github.com/dlang/dmd/issues/20635
710+
if (e.type.ty == t.ty && e.type.nextOf().ty == tn.ty)
711+
return m;
706712
}
707713
if (e.type != t && e.hexString && tn.isintegral && (tn.size == e.sz || (!e.committed && (e.len % tn.size) == 0)))
708714
{

dmd/dsymbolsem.d

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4169,7 +4169,8 @@ private extern(C++) class AddMemberVisitor : Visitor
41694169
}
41704170

41714171
// If using C tag/prototype/forward declaration rules
4172-
if (sc.flags & SCOPE.Cfile && !dsym.isImport())
4172+
if (sc && sc.flags & SCOPE.Cfile && !dsym.isImport())
4173+
// When merging master, replace with: if (sc && sc.inCfile && !dsym.isImport())
41734174
{
41744175
if (handleTagSymbols(*sc, dsym, s2, sds))
41754176
return;

dmd/expressionsem.d

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,11 +1363,6 @@ private Expression resolveUFCSProperties(Scope* sc, Expression e1, Expression e2
13631363
auto arguments = new Expressions(1);
13641364
(*arguments)[0] = eleft;
13651365
e = new CallExp(loc, e, arguments);
1366-
1367-
// https://issues.dlang.org/show_bug.cgi?id=24017
1368-
if (sc.flags & SCOPE.debug_)
1369-
e.isCallExp().inDebugStatement = true;
1370-
13711366
e = e.expressionSemantic(sc);
13721367
return e;
13731368
}
@@ -13364,6 +13359,11 @@ version (IN_LLVM)
1336413359
error(exp.loc, "compare not defined for complex operands");
1336513360
return setError();
1336613361
}
13362+
else if (t1.isTypeFunction() || t2.isTypeFunction())
13363+
{
13364+
error(exp.loc, "comparison is not defined for function types");
13365+
return setError();
13366+
}
1336713367
else if (t1.ty == Taarray || t2.ty == Taarray)
1336813368
{
1336913369
error(exp.loc, "`%s` is not defined for associative arrays", EXPtoString(exp.op).ptr);
@@ -13684,6 +13684,12 @@ version (IN_LLVM)
1368413684
return;
1368513685
}
1368613686

13687+
if (t1.isTypeFunction() || t2.isTypeFunction())
13688+
{
13689+
error(exp.loc, "operator `==` is not defined for function types");
13690+
return setError();
13691+
}
13692+
1368713693
if (auto tv = t1.isTypeVector())
1368813694
exp.type = tv.toBooleanVector();
1368913695

@@ -13745,6 +13751,12 @@ version (IN_LLVM)
1374513751
if (exp.e2.op == EXP.call)
1374613752
exp.e2 = (cast(CallExp)exp.e2).addDtorHook(sc);
1374713753

13754+
if (exp.e1.type.isTypeFunction() || exp.e2.type.isTypeFunction())
13755+
{
13756+
error(exp.loc, "operator `is` is not defined for function types");
13757+
return setError();
13758+
}
13759+
1374813760
if (exp.e1.type.toBasetype().ty == Tsarray ||
1374913761
exp.e2.type.toBasetype().ty == Tsarray)
1375013762
deprecation(exp.loc, "identity comparison of static arrays "

dmd/pragmasem.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ private bool pragmaMsgSemantic(Loc loc, Scope* sc, Expressions* args)
639639
else
640640
{
641641
buf.writestring("\n");
642-
fprintf(stderr, buf.extractChars);
642+
fprintf(stderr, "%s", buf.extractChars);
643643
}
644644
return true;
645645
}

dmd/statementsem.d

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,16 @@ private Expression checkAssignmentAsCondition(Expression e, Scope* sc)
134134
return e;
135135
}
136136

137-
// Performs semantic analysis in Statement AST nodes
137+
/**
138+
* Performs semantic analysis in Statement AST nodes
139+
*
140+
* Params:
141+
* s = statement to perform semantic analysis on
142+
* sc = scope in which statement resides
143+
*
144+
* Returns: statement `s` after semantic analysis.
145+
* Can be `null`, for example with `pragma(msg, "")`
146+
*/
138147
Statement statementSemantic(Statement s, Scope* sc)
139148
{
140149
import dmd.compiler;
@@ -3497,6 +3506,7 @@ version (IN_LLVM)
34973506
sc = sc.push();
34983507
sc.flags |= SCOPE.debug_;
34993508
ds.statement = ds.statement.statementSemantic(sc);
3509+
debugThrowWalker(ds.statement);
35003510
sc.pop();
35013511
}
35023512
result = ds.statement;
@@ -4804,7 +4814,6 @@ private Statements* flatten(Statement statement, Scope* sc)
48044814
if (dc)
48054815
{
48064816
s = new DebugStatement(cs.loc, cs.ifbody);
4807-
debugThrowWalker(cs.ifbody);
48084817
}
48094818
else
48104819
s = cs.ifbody;
@@ -4976,7 +4985,8 @@ Params:
49764985
*/
49774986
private void debugThrowWalker(Statement s)
49784987
{
4979-
4988+
if (!s)
4989+
return;
49804990
extern(C++) final class DebugWalker : SemanticTimeTransitiveVisitor
49814991
{
49824992
alias visit = SemanticTimeTransitiveVisitor.visit;

tests/dmd/compilable/bug11735.d

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ print dstring
1313
foo_str
1414
foo_wstr
1515
foo_dstr
16+
X%nY
1617
---
1718
*/
1819

@@ -33,4 +34,7 @@ void main()
3334
pragma(msg, a);
3435
pragma(msg, b);
3536
pragma(msg, c);
37+
38+
// https://github.com/dlang/dmd/issues/20894
39+
pragma(msg, "X%nY");
3640
}

tests/dmd/compilable/test16492.d renamed to tests/dmd/compilable/debug_statement_attributes.d

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,17 @@ void test6() nothrow
8585
() {throw new Exception("");}();
8686
}
8787
}
88+
89+
void writeln() {}
90+
void writeln(string) {}
91+
92+
void test7() nothrow
93+
{
94+
debug writeln("Hello"); // https://issues.dlang.org/show_bug.cgi?id=24017
95+
debug "Hello".writeln;
96+
debug writeln = "Hello"; // https://github.com/dlang/dmd/issues/20719
97+
debug writeln;
98+
99+
// https://github.com/dlang/dmd/pull/20720#issuecomment-2596892489
100+
debug pragma(msg, ""); // Came up as segfault, pragma statement became null after semantic
101+
}

tests/dmd/compilable/test24017.d

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/dmd/fail_compilation/fail22151.d

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
/*
33
TEST_OUTPUT:
44
---
5-
fail_compilation/fail22151.d(14): Error: function `test` is not an lvalue and cannot be modified
6-
fail_compilation/fail22151.d(15): Error: function `test2` is not an lvalue and cannot be modified
7-
fail_compilation/fail22151.d(18): Error: function pointed to by `fp` is not an lvalue and cannot be modified
8-
fail_compilation/fail22151.d(21): Error: function pointed to by `ff` is not an lvalue and cannot be modified
5+
fail_compilation/fail22151.d(17): Error: function `test` is not an lvalue and cannot be modified
6+
fail_compilation/fail22151.d(18): Error: function `test2` is not an lvalue and cannot be modified
7+
fail_compilation/fail22151.d(21): Error: function pointed to by `fp` is not an lvalue and cannot be modified
8+
fail_compilation/fail22151.d(24): Error: function pointed to by `ff` is not an lvalue and cannot be modified
9+
fail_compilation/fail22151.d(27): Error: operator `==` is not defined for function types
10+
fail_compilation/fail22151.d(28): Error: operator `is` is not defined for function types
11+
fail_compilation/fail22151.d(29): Error: comparison is not defined for function types
912
---
1013
*/
1114

@@ -19,6 +22,11 @@ void test()
1922

2023
auto ff = &test2;
2124
*ff = *&test2;
25+
26+
// https://github.com/dlang/dmd/issues/18281
27+
const c = *fp == *fp;
28+
const d = *fp is *fp;
29+
const e = *fp < *fp;
2230
}
2331

2432
void test2();
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
TEST_OUTPUT:
3+
---
4+
fail_compilation/test20859.d(8): Error: variable `test20859.ICE.__vtbl` conflicts with variable `test20859.ICE.__vtbl` at fail_compilation/test20859.d(10)
5+
---
6+
*/
7+
8+
class ICE
9+
{
10+
void **__vtbl;
11+
}

0 commit comments

Comments
 (0)