Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge upstream stable #4008

Merged
merged 4 commits into from
Jul 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# LDC master

#### Big news
- Frontend, druntime and Phobos are at version [2.100.0](https://dlang.org/changelog/2.100.0.html). (#3970)
- Frontend, druntime and Phobos are at version [2.100.0+](https://dlang.org/changelog/2.100.0.html). (#3970, #4008)
- LLVM for prebuilt packages bumped to v14.0.3. (#3952, #3979)
- All LLVM targets are enabled now (=> more targets for cross-compilation).
- For the Mac package, the minimum supported macOS version has been raised to v10.12.
Expand Down
14 changes: 11 additions & 3 deletions dmd/dcast.d
Original file line number Diff line number Diff line change
Expand Up @@ -1107,9 +1107,14 @@ MATCH implicitConvTo(Expression e, Type t)

MATCH visitCond(CondExp e)
{
auto result = visit(e);
if (result != MATCH.nomatch)
return result;
e.econd = e.econd.optimize(WANTvalue);
const opt = e.econd.toBool();
if (opt.isPresent())
{
auto result = visit(e);
if (result != MATCH.nomatch)
return result;
}

MATCH m1 = e.e1.implicitConvTo(t);
MATCH m2 = e.e2.implicitConvTo(t);
Expand Down Expand Up @@ -2954,6 +2959,9 @@ Lagain:

t1 = Type.basic[ty1];
t2 = Type.basic[ty2];

if (!(t1 && t2))
return null;
e1 = e1.castTo(sc, t1);
e2 = e2.castTo(sc, t2);
return Lret(Type.basic[ty]);
Expand Down
3 changes: 3 additions & 0 deletions dmd/dsymbolsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -4487,7 +4487,10 @@ version (IN_LLVM)
invd.semanticRun < PASS.semantic &&
!ad.isUnionDeclaration() // users are on their own with union fields
)
{
invd.fixupInvariantIdent(ad.invs.length);
ad.invs.push(invd);
}
if (!invd.type)
invd.type = new TypeFunction(ParameterList(), Type.tvoid, LINK.d, invd.storage_class);

Expand Down
13 changes: 8 additions & 5 deletions dmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -2048,7 +2048,8 @@ private bool functionParameters(const ref Loc loc, Scope* sc,
if (global.params.useDIP1000 == FeatureState.enabled)
err |= checkParamArgumentEscape(sc, fd, p, arg, false, false);
}
else if (!(pStc & STC.return_))
else if (!(pStc & STC.return_) &&
((global.params.useDIP1000 == FeatureState.enabled) || !(p.storageClass & STC.scopeinferred)))
{
/* Argument value cannot escape from the called function.
*/
Expand All @@ -2058,10 +2059,10 @@ private bool functionParameters(const ref Loc loc, Scope* sc,

ArrayLiteralExp ale;
if (p.type.toBasetype().ty == Tarray &&
(ale = a.isArrayLiteralExp()) !is null)
(ale = a.isArrayLiteralExp()) !is null && ale.elements && ale.elements.length > 0)
{
// allocate the array literal as temporary static array on the stack
ale.type = ale.type.nextOf().sarrayOf(ale.elements ? ale.elements.length : 0);
ale.type = ale.type.nextOf().sarrayOf(ale.elements.length);
auto tmp = copyToTemp(0, "__arrayliteral_on_stack", ale);
auto declareTmp = new DeclarationExp(ale.loc, tmp);
auto castToSlice = new CastExp(ale.loc, new VarExp(ale.loc, tmp),
Expand Down Expand Up @@ -9941,9 +9942,11 @@ version (IN_LLVM)
ae.e2.type.nextOf &&
ae.e1.type.nextOf.mutableOf.equals(ae.e2.type.nextOf.mutableOf);

/* Unlike isArrayCtor above, lower all Rvalues. If the RHS is a literal,
* then we do want to make a temporary for it and call its destructor.
*/
const isArraySetCtor =
(ae.e1.isSliceExp || ae.e1.type.ty == Tsarray) &&
ae.e2.isLvalue &&
(ae.e2.type.ty == Tstruct || ae.e2.type.ty == Tsarray) &&
ae.e1.type.nextOf &&
ae.e1.type.nextOf.equivalent(ae.e2.type);
Expand Down Expand Up @@ -12550,7 +12553,7 @@ Expression semanticY(DotIdExp exp, Scope* sc, int flag)
e = new CommaExp(exp.loc, eleft, e);
e.type = Type.tvoid; // ambiguous type?
}
return e;
return e.expressionSemantic(sc);
}
if (auto o = s.isOverloadSet())
{
Expand Down
10 changes: 10 additions & 0 deletions dmd/func.d
Original file line number Diff line number Diff line change
Expand Up @@ -4199,6 +4199,7 @@ extern (C++) final class InvariantDeclaration : FuncDeclaration
{
extern (D) this(const ref Loc loc, const ref Loc endloc, StorageClass stc, Identifier id, Statement fbody)
{
// Make a unique invariant for now; we'll fix it up as we add it to the aggregate invariant list.
super(loc, endloc, id ? id : Identifier.generateId("__invariant"), stc, null);
this.fbody = fbody;
}
Expand Down Expand Up @@ -4235,6 +4236,15 @@ extern (C++) final class InvariantDeclaration : FuncDeclaration
{
v.visit(this);
}

extern (D) void fixupInvariantIdent(size_t offset)
{
OutBuffer idBuf;
idBuf.writestring("__invariant");
idBuf.print(offset);

ident = Identifier.idPool(idBuf[]);
}
}


Expand Down
55 changes: 55 additions & 0 deletions dmd/impcnvtab.d
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,57 @@ enum ImpCnvTab impCnvTab = generateImpCnvTab();

ImpCnvTab generateImpCnvTab()
{
TY[TMAX] typeTYs =
[
Tarray,
Tsarray,
Taarray,
Tpointer,
Treference,
Tfunction,
Tident,
Tclass,
Tstruct,
Tenum,
Tdelegate,
Tnone,
Tvoid,
Tint8,
Tuns8,
Tint16,
Tuns16,
Tint32,
Tuns32,
Tint64,
Tuns64,
Tfloat32,
Tfloat64,
Tfloat80,
Timaginary32,
Timaginary64,
Timaginary80,
Tcomplex32,
Tcomplex64,
Tcomplex80,
Tbool,
Tchar,
Twchar,
Tdchar,
Terror,
Tinstance,
Ttypeof,
Ttuple,
Tslice,
Treturn,
Tnull,
Tvector,
Tint128,
Tuns128,
Ttraits,
Tmixin,
Tnoreturn,
Ttag,
];
ImpCnvTab impCnvTab;

// Set conversion tables
Expand Down Expand Up @@ -375,5 +426,9 @@ ImpCnvTab generateImpCnvTab()

X(Tcomplex80,Tcomplex80, Tcomplex80,Tcomplex80, Tcomplex80);

// "No type is implicitly convertible to noreturn, but noreturn is implicitly convertible to every other type"
foreach(convertToTy; typeTYs)
X(Tnoreturn, convertToTy, convertToTy, convertToTy, convertToTy);

return impCnvTab;
}
5 changes: 4 additions & 1 deletion dmd/inline.d
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import dmd.init;
import dmd.initsem;
import dmd.mtype;
import dmd.opover;
import dmd.printast;
import dmd.statement;
import dmd.tokens;
import dmd.visitor;
Expand Down Expand Up @@ -236,7 +237,7 @@ public:
auto e1 = doInlineAs!Expression(ifs.ifbody, ids);
assert(ids.foundReturn);
auto e2 = doInlineAs!Expression(s3, ids);

assert(e2);
Expression e = new CondExp(econd.loc, econd, e1, e2);
e.type = e1.type;
if (e.type.ty == Ttuple)
Expand All @@ -249,6 +250,7 @@ public:
}
else
{
ids.foundReturn = false;
auto e = doInlineAs!Expression(sx, ids);
result = Expression.combine(result, e);
}
Expand Down Expand Up @@ -374,6 +376,7 @@ public:

override void visit(ImportStatement s)
{
//printf("ImportStatement.doInlineAs!%s()\n", Result.stringof.ptr);
}

override void visit(ForStatement s)
Expand Down
1 change: 1 addition & 0 deletions dmd/root/longdouble.d
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ nothrow @nogc pure:
static if (op == "+") return longdouble_soft(rhs).ld_add(this);
else static if (op == "-") return longdouble_soft(rhs).ld_sub(this);
else static if (op == "*") return longdouble_soft(rhs).ld_mul(this);
else static if (op == "/") return longdouble_soft(rhs).ld_div(this);
else static if (op == "%") return longdouble_soft(rhs).ld_mod(this);
else static assert(false, "Operator `"~op~"` is not implemented");
}
Expand Down
5 changes: 5 additions & 0 deletions gen/llvmhelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,11 @@ void DtoAssign(const Loc &loc, DValue *lhs, DValue *rhs, EXP op,
Type *t = lhs->type->toBasetype();
assert(t->ty != TY::Tvoid && "Cannot assign values of type void.");

if (t->ty == TY::Tnoreturn) {
// nothing to assign
return;
}

if (t->ty == TY::Tbool) {
DtoStoreZextI8(DtoRVal(rhs), DtoLVal(lhs));
} else if (t->ty == TY::Tstruct) {
Expand Down
2 changes: 1 addition & 1 deletion runtime/druntime
Submodule druntime updated 0 files
2 changes: 1 addition & 1 deletion runtime/phobos