mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 21:21:48 +03:00
Merge branch 'stable' into merge-stable
This commit is contained in:
commit
5375db4f76
12 changed files with 99 additions and 25 deletions
|
@ -704,6 +704,12 @@ MATCH implicitConvTo(Expression e, Type t)
|
|||
if (!tn.isConst() && !tn.isImmutable())
|
||||
return MATCH.nomatch;
|
||||
m = MATCH.constant;
|
||||
|
||||
// After converting e.g. ubyte[] to const(ubyte)[], don't change
|
||||
// to MATCH.convert, return MATCH.constant
|
||||
// https://github.com/dlang/dmd/issues/20635
|
||||
if (e.type.ty == t.ty && e.type.nextOf().ty == tn.ty)
|
||||
return m;
|
||||
}
|
||||
if (e.type != t && e.hexString && tn.isIntegral && (tn.size == e.sz || (!e.committed && (e.len % tn.size) == 0)))
|
||||
{
|
||||
|
|
|
@ -4184,7 +4184,8 @@ private extern(C++) class AddMemberVisitor : Visitor
|
|||
}
|
||||
|
||||
// If using C tag/prototype/forward declaration rules
|
||||
if (sc.inCfile && !dsym.isImport())
|
||||
if (sc && sc.inCfile && !dsym.isImport())
|
||||
// When merging master, replace with: if (sc && sc.inCfile && !dsym.isImport())
|
||||
{
|
||||
if (handleTagSymbols(*sc, dsym, s2, sds))
|
||||
return;
|
||||
|
|
|
@ -1453,11 +1453,6 @@ private Expression resolveUFCSProperties(Scope* sc, Expression e1, Expression e2
|
|||
auto arguments = new Expressions(1);
|
||||
(*arguments)[0] = eleft;
|
||||
e = new CallExp(loc, e, arguments);
|
||||
|
||||
// https://issues.dlang.org/show_bug.cgi?id=24017
|
||||
if (sc.debug_)
|
||||
e.isCallExp().inDebugStatement = true;
|
||||
|
||||
e = e.expressionSemantic(sc);
|
||||
return e;
|
||||
}
|
||||
|
@ -13077,6 +13072,11 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
|
|||
error(exp.loc, "compare not defined for complex operands");
|
||||
return setError();
|
||||
}
|
||||
else if (t1.isTypeFunction() || t2.isTypeFunction())
|
||||
{
|
||||
error(exp.loc, "comparison is not defined for function types");
|
||||
return setError();
|
||||
}
|
||||
else if (t1.ty == Taarray || t2.ty == Taarray)
|
||||
{
|
||||
error(exp.loc, "`%s` is not defined for associative arrays", EXPtoString(exp.op).ptr);
|
||||
|
@ -13382,6 +13382,12 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
|
|||
return;
|
||||
}
|
||||
|
||||
if (t1.isTypeFunction() || t2.isTypeFunction())
|
||||
{
|
||||
error(exp.loc, "operator `==` is not defined for function types");
|
||||
return setError();
|
||||
}
|
||||
|
||||
if (auto tv = t1.isTypeVector())
|
||||
exp.type = tv.toBooleanVector();
|
||||
|
||||
|
@ -13438,6 +13444,12 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
|
|||
if (exp.e2.op == EXP.call)
|
||||
exp.e2 = (cast(CallExp)exp.e2).addDtorHook(sc);
|
||||
|
||||
if (exp.e1.type.isTypeFunction() || exp.e2.type.isTypeFunction())
|
||||
{
|
||||
error(exp.loc, "operator `is` is not defined for function types");
|
||||
return setError();
|
||||
}
|
||||
|
||||
if (exp.e1.type.toBasetype().ty == Tsarray ||
|
||||
exp.e2.type.toBasetype().ty == Tsarray)
|
||||
deprecation(exp.loc, "identity comparison of static arrays "
|
||||
|
|
|
@ -567,7 +567,7 @@ private bool pragmaMsgSemantic(Loc loc, Scope* sc, Expressions* args)
|
|||
return false;
|
||||
|
||||
buf.writestring("\n");
|
||||
fprintf(stderr, buf.extractChars);
|
||||
fprintf(stderr, "%s", buf.extractChars);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -135,7 +135,16 @@ private Expression checkAssignmentAsCondition(Expression e, Scope* sc)
|
|||
return e;
|
||||
}
|
||||
|
||||
// Performs semantic analysis in Statement AST nodes
|
||||
/**
|
||||
* Performs semantic analysis in Statement AST nodes
|
||||
*
|
||||
* Params:
|
||||
* s = statement to perform semantic analysis on
|
||||
* sc = scope in which statement resides
|
||||
*
|
||||
* Returns: statement `s` after semantic analysis.
|
||||
* Can be `null`, for example with `pragma(msg, "")`
|
||||
*/
|
||||
Statement statementSemantic(Statement s, Scope* sc)
|
||||
{
|
||||
import dmd.compiler;
|
||||
|
@ -3488,6 +3497,7 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
|
|||
sc = sc.push();
|
||||
sc.debug_ = true;
|
||||
ds.statement = ds.statement.statementSemantic(sc);
|
||||
debugThrowWalker(ds.statement);
|
||||
sc.pop();
|
||||
}
|
||||
result = ds.statement;
|
||||
|
@ -4760,7 +4770,6 @@ private Statements* flatten(Statement statement, Scope* sc)
|
|||
if (dc)
|
||||
{
|
||||
s = new DebugStatement(cs.loc, cs.ifbody);
|
||||
debugThrowWalker(cs.ifbody);
|
||||
}
|
||||
else
|
||||
s = cs.ifbody;
|
||||
|
@ -4932,7 +4941,8 @@ Params:
|
|||
*/
|
||||
private void debugThrowWalker(Statement s)
|
||||
{
|
||||
|
||||
if (!s)
|
||||
return;
|
||||
extern(C++) final class DebugWalker : SemanticTimeTransitiveVisitor
|
||||
{
|
||||
alias visit = SemanticTimeTransitiveVisitor.visit;
|
||||
|
|
|
@ -13,6 +13,7 @@ print dstring
|
|||
foo_str
|
||||
foo_wstr
|
||||
foo_dstr
|
||||
X%nY
|
||||
---
|
||||
*/
|
||||
|
||||
|
@ -33,4 +34,7 @@ void main()
|
|||
pragma(msg, a);
|
||||
pragma(msg, b);
|
||||
pragma(msg, c);
|
||||
|
||||
// https://github.com/dlang/dmd/issues/20894
|
||||
pragma(msg, "X%nY");
|
||||
}
|
||||
|
|
|
@ -85,3 +85,17 @@ void test6() nothrow
|
|||
() {throw new Exception("");}();
|
||||
}
|
||||
}
|
||||
|
||||
void writeln() {}
|
||||
void writeln(string) {}
|
||||
|
||||
void test7() nothrow
|
||||
{
|
||||
debug writeln("Hello"); // https://issues.dlang.org/show_bug.cgi?id=24017
|
||||
debug "Hello".writeln;
|
||||
debug writeln = "Hello"; // https://github.com/dlang/dmd/issues/20719
|
||||
debug writeln;
|
||||
|
||||
// https://github.com/dlang/dmd/pull/20720#issuecomment-2596892489
|
||||
debug pragma(msg, ""); // Came up as segfault, pragma statement became null after semantic
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
// https://issues.dlang.org/show_bug.cgi?id=24017
|
||||
|
||||
// REQUIRED_ARGS: -debug
|
||||
|
||||
void writeln(string) {}
|
||||
|
||||
void main() nothrow
|
||||
{
|
||||
debug writeln("Hello");
|
||||
debug "Hello".writeln;
|
||||
}
|
|
@ -2,10 +2,13 @@
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail22151.d(14): Error: function `test` is not an lvalue and cannot be modified
|
||||
fail_compilation/fail22151.d(15): Error: function `test2` is not an lvalue and cannot be modified
|
||||
fail_compilation/fail22151.d(18): Error: function pointed to by `fp` is not an lvalue and cannot be modified
|
||||
fail_compilation/fail22151.d(21): Error: function pointed to by `ff` is not an lvalue and cannot be modified
|
||||
fail_compilation/fail22151.d(17): Error: function `test` is not an lvalue and cannot be modified
|
||||
fail_compilation/fail22151.d(18): Error: function `test2` is not an lvalue and cannot be modified
|
||||
fail_compilation/fail22151.d(21): Error: function pointed to by `fp` is not an lvalue and cannot be modified
|
||||
fail_compilation/fail22151.d(24): Error: function pointed to by `ff` is not an lvalue and cannot be modified
|
||||
fail_compilation/fail22151.d(27): Error: operator `==` is not defined for function types
|
||||
fail_compilation/fail22151.d(28): Error: operator `is` is not defined for function types
|
||||
fail_compilation/fail22151.d(29): Error: comparison is not defined for function types
|
||||
---
|
||||
*/
|
||||
|
||||
|
@ -19,6 +22,11 @@ void test()
|
|||
|
||||
auto ff = &test2;
|
||||
*ff = *&test2;
|
||||
|
||||
// https://github.com/dlang/dmd/issues/18281
|
||||
const c = *fp == *fp;
|
||||
const d = *fp is *fp;
|
||||
const e = *fp < *fp;
|
||||
}
|
||||
|
||||
void test2();
|
||||
|
|
11
compiler/test/fail_compilation/test20859.d
Normal file
11
compiler/test/fail_compilation/test20859.d
Normal file
|
@ -0,0 +1,11 @@
|
|||
/**
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/test20859.d(8): Error: variable `test20859.ICE.__vtbl` conflicts with variable `test20859.ICE.__vtbl` at fail_compilation/test20859.d(10)
|
||||
---
|
||||
*/
|
||||
|
||||
class ICE
|
||||
{
|
||||
void **__vtbl;
|
||||
}
|
|
@ -277,8 +277,16 @@ void testHexstring()
|
|||
static immutable ulong[] z0 = cast(immutable ulong[]) x"1111 1111 1111 1111 0000 000F 0000 0000";
|
||||
static immutable ulong[] z1 = [0x1111_1111_1111_1111, 0x0000_000E_0000_0000];
|
||||
static assert(z0 !is z1);
|
||||
|
||||
// https://github.com/dlang/dmd/issues/20635
|
||||
f20635(cast(ubyte[]) x"00");
|
||||
f20635(cast(const ubyte[]) x"00");
|
||||
f20635(cast(immutable ubyte[]) x"00");
|
||||
}
|
||||
|
||||
void f20635(const ubyte[] value){}
|
||||
void f20635(const string value){}
|
||||
|
||||
/***************************************************/
|
||||
|
||||
int main()
|
||||
|
|
|
@ -240,6 +240,16 @@ void test8()
|
|||
|
||||
/*********************************************************/
|
||||
|
||||
// https://github.com/dlang/dmd/issues/20907
|
||||
struct Bar { enum bar = 1; }
|
||||
void foo(A)(A[], A[1 << A.bar]) {}
|
||||
void test20907()
|
||||
{
|
||||
foo((Bar[]).init, (Bar[2]).init);
|
||||
}
|
||||
|
||||
/*********************************************************/
|
||||
|
||||
int main()
|
||||
{
|
||||
test1();
|
||||
|
@ -250,6 +260,7 @@ int main()
|
|||
test6();
|
||||
test7();
|
||||
test8();
|
||||
test20907();
|
||||
|
||||
printf("Success\n");
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue