Skip to content

Commit 9e7ac1c

Browse files
committed
Merge upstream stable (dlang/dmd@3dd97695a3)
1 parent c5e4501 commit 9e7ac1c

16 files changed

+109
-108
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.099.0+](https://dlang.org/changelog/2.099.0.html). (#3917, #3893, #3937)
4+
- Frontend, druntime and Phobos are at version [2.099.1](https://dlang.org/changelog/2.099.0.html). (#3917, #3893, #3937, #3953)
55
- Support for LLVM 13 and 14. The prebuilt packages use v13.0.1. (#3842, #3951)
66
- On Linux, LDC doesn't default to the `ld.gold` linker anymore. The combination of LLVM 13+ and older gold linkers can apparently cause problems. We recommend using LLD, e.g., via `-linker=lld` or by setting your default `/usr/bin/ld` symlink; it's significantly faster too.
77
- `-linkonce-templates` is less aggressive by default now and IMHO production-ready. (#3924)

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ set(LDC_VERSION "1.29.0") # May be overridden by git hash tag
112112
set(DMDFE_MAJOR_VERSION 2)
113113
set(DMDFE_MINOR_VERSION 0)
114114
set(DMDFE_PATCH_VERSION 99)
115-
set(DMDFE_FIX_LEVEL 0)
115+
set(DMDFE_FIX_LEVEL 1)
116116

117117
set(DMD_VERSION ${DMDFE_MAJOR_VERSION}.${DMDFE_MINOR_VERSION}${DMDFE_PATCH_VERSION})
118118
if(DEFINED DMDFE_FIX_LEVEL)

dmd/cli.d

+3-3
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ dmd -cov -unittest myprog.d
823823
Feature("field", "vfield",
824824
"list all non-mutable fields which occupy an object instance"),
825825
Feature("complex", "vcomplex",
826-
"give deprecation messages about all usages of complex or imaginary types", false, true),
826+
"give deprecation messages about all usages of complex or imaginary types", true, true),
827827
Feature("tls", "vtls",
828828
"list all variables going into thread local storage"),
829829
Feature("vmarkdown", "vmarkdown",
@@ -937,8 +937,6 @@ version (IN_LLVM) {} else
937937
"Enables all available " ~ description)] ~ features;
938938
foreach (t; allTransitions)
939939
{
940-
if (t.deprecated_)
941-
continue;
942940
if (!t.documented)
943941
continue;
944942
buf ~= " =";
@@ -948,6 +946,8 @@ version (IN_LLVM) {} else
948946
foreach (i; lineLength .. maxFlagLength)
949947
buf ~= " ";
950948
buf ~= t.helpText;
949+
if (t.deprecated_)
950+
buf ~= " [DEPRECATED]";
951951
buf ~= "\n";
952952
}
953953
return buf;

dmd/dscope.d

+25
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,31 @@ version (IN_LLVM)
713713
return null;
714714
}
715715

716+
/********************************************
717+
* Find the lexically enclosing function (if any).
718+
*
719+
* This function skips through generated FuncDeclarations,
720+
* e.g. rewritten foreach bodies.
721+
*
722+
* Returns: the function or null
723+
*/
724+
inout(FuncDeclaration) getEnclosingFunction() inout
725+
{
726+
if (!this.func)
727+
return null;
728+
729+
auto fd = cast(FuncDeclaration) this.func;
730+
731+
// Look through foreach bodies rewritten as delegates
732+
while (fd.fes)
733+
{
734+
assert(fd.fes.func);
735+
fd = fd.fes.func;
736+
}
737+
738+
return cast(inout(FuncDeclaration)) fd;
739+
}
740+
716741
/*******************************************
717742
* For TemplateDeclarations, we need to remember the Scope
718743
* where it was declared. So mark the Scope as not

dmd/dsymbol.d

+16-7
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,22 @@ version (IN_LLVM)
844844
if (isAliasDeclaration() && !_scope)
845845
setScope(sc);
846846
Dsymbol s2 = sds.symtabLookup(this,ident);
847+
/* https://issues.dlang.org/show_bug.cgi?id=17434
848+
*
849+
* If we are trying to add an import to the symbol table
850+
* that has already been introduced, then keep the one with
851+
* larger visibility. This is fine for imports because if
852+
* we have multiple imports of the same file, if a single one
853+
* is public then the symbol is reachable.
854+
*/
855+
if (auto i1 = isImport())
856+
{
857+
if (auto i2 = s2.isImport())
858+
{
859+
if (sc.explicitVisibility && sc.visibility > i2.visibility)
860+
sds.symtab.update(this);
861+
}
862+
}
847863

848864
// If using C tag/prototype/forward declaration rules
849865
if (sc.flags & SCOPE.Cfile)
@@ -977,14 +993,7 @@ version (IN_LLVM)
977993
TemplateInstance ti = st.isTemplateInstance();
978994
sm = s.search(loc, ti.name);
979995
if (!sm)
980-
{
981-
sm = s.search_correct(ti.name);
982-
if (sm)
983-
.error(loc, "template identifier `%s` is not a member of %s `%s`, did you mean %s `%s`?", ti.name.toChars(), s.kind(), s.toPrettyChars(), sm.kind(), sm.toChars());
984-
else
985-
.error(loc, "template identifier `%s` is not a member of %s `%s`", ti.name.toChars(), s.kind(), s.toPrettyChars());
986996
return null;
987-
}
988997
sm = sm.toAlias();
989998
TemplateDeclaration td = sm.isTemplateDeclaration();
990999
if (!td)

dmd/dsymbolsem.d

+5-5
Original file line numberDiff line numberDiff line change
@@ -6526,10 +6526,10 @@ void aliasSemantic(AliasDeclaration ds, Scope* sc)
65266526

65276527
// Ungag errors when not instantiated DeclDefs scope alias
65286528
auto ungag = Ungag(global.gag);
6529-
//printf("%s parent = %s, gag = %d, instantiated = %d\n", toChars(), parent, global.gag, isInstantiated());
6530-
if (ds.parent && global.gag && !ds.isInstantiated() && !ds.toParent2().isFuncDeclaration())
6529+
//printf("%s parent = %s, gag = %d, instantiated = %d\n", ds.toChars(), ds.parent.toChars(), global.gag, ds.isInstantiated() !is null);
6530+
if (ds.parent && global.gag && !ds.isInstantiated() && !ds.toParent2().isFuncDeclaration() && (sc.minst || sc.tinst))
65316531
{
6532-
//printf("%s type = %s\n", toPrettyChars(), type.toChars());
6532+
//printf("%s type = %s\n", ds.toPrettyChars(), ds.type.toChars());
65336533
global.gag = 0;
65346534
}
65356535

@@ -6603,13 +6603,13 @@ void aliasSemantic(AliasDeclaration ds, Scope* sc)
66036603
}
66046604
if (s) // it's a symbolic alias
66056605
{
6606-
//printf("alias %s resolved to %s %s\n", toChars(), s.kind(), s.toChars());
6606+
//printf("alias %s resolved to %s %s\n", ds.toChars(), s.kind(), s.toChars());
66076607
ds.type = null;
66086608
ds.aliassym = s;
66096609
}
66106610
else // it's a type alias
66116611
{
6612-
//printf("alias %s resolved to type %s\n", toChars(), type.toChars());
6612+
//printf("alias %s resolved to type %s\n", ds.toChars(), ds.type.toChars());
66136613
ds.type = ds.type.typeSemantic(ds.loc, sc);
66146614
ds.aliassym = null;
66156615
}

dmd/expressionsem.d

+9-9
Original file line numberDiff line numberDiff line change
@@ -1445,13 +1445,6 @@ private Type arrayExpressionToCommonType(Scope* sc, ref Expressions exps)
14451445
Expression ex = condexp.expressionSemantic(sc);
14461446
if (ex.op == EXP.error)
14471447
e = ex;
1448-
else if (e.op == EXP.function_ || e.op == EXP.delegate_)
1449-
{
1450-
// https://issues.dlang.org/show_bug.cgi?id=21285
1451-
// Functions and delegates don't convert correctly with castTo below
1452-
exps[i] = condexp.e1;
1453-
e = condexp.e2;
1454-
}
14551448
else
14561449
{
14571450
// Convert to common type
@@ -3779,7 +3772,11 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
37793772
}
37803773
}
37813774

3782-
if (sd.hasRegularCtor() && nargs)
3775+
// https://issues.dlang.org/show_bug.cgi?id=22639
3776+
// If the new expression has arguments, we either should call a
3777+
// regular constructor of a copy constructor if the first argument
3778+
// is the same type as the struct
3779+
if (nargs && (sd.hasRegularCtor() || (sd.ctor && (*exp.arguments)[0].type.mutableOf() == sd.type.mutableOf())))
37833780
{
37843781
FuncDeclaration f = resolveFuncCall(exp.loc, sc, sd.ctor, null, tb, exp.arguments, FuncResolveFlag.standard);
37853782
if (!f || f.errors)
@@ -4540,7 +4537,10 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
45404537
If all constructors are copy constructors, then
45414538
try default construction.
45424539
*/
4543-
if (!sd.hasRegularCtor)
4540+
if (!sd.hasRegularCtor &&
4541+
// https://issues.dlang.org/show_bug.cgi?id=22639
4542+
// we might still have a copy constructor that could be called
4543+
(*exp.arguments)[0].type.mutableOf != sd.type.mutableOf())
45444544
goto Lx;
45454545

45464546
auto sle = new StructLiteralExp(exp.loc, sd, null, exp.e1.type);

dmd/hdrgen.d

+6
Original file line numberDiff line numberDiff line change
@@ -2798,9 +2798,15 @@ bool stcToBuffer(OutBuffer* buf, StorageClass stc)
27982798
bool result = false;
27992799

28002800
if (stc & STC.scopeinferred)
2801+
{
2802+
//buf.writestring("scope-inferred ");
28012803
stc &= ~(STC.scope_ | STC.scopeinferred);
2804+
}
28022805
if (stc & STC.returninferred)
2806+
{
2807+
//buf.writestring("return-inferred ");
28032808
stc &= ~(STC.return_ | STC.returninferred);
2809+
}
28042810

28052811
/* Put scope ref return into a standard order
28062812
*/

dmd/mars.d

+3-11
Original file line numberDiff line numberDiff line change
@@ -690,20 +690,12 @@ version (IN_LLVM)
690690

691691
if (params.addMain && !global.hasMainFunction)
692692
{
693-
version (IN_LLVM)
694-
{
695693
auto mainModule = moduleWithEmptyMain();
696694
modules.push(mainModule);
697-
698-
if (!params.oneobj)
695+
if (IN_LLVM && params.oneobj && modules.length == 1)
696+
params.objfiles.insert(0, mainModule.objfile.toChars()); // must be *first* objfile for LDC's oneobj
697+
else if (!params.oneobj || modules.length == 1)
699698
params.objfiles.push(mainModule.objfile.toChars());
700-
else if (modules.length == 1)
701-
params.objfiles.insert(0, mainModule.objfile.toChars());
702-
}
703-
else
704-
{
705-
modules.push(moduleWithEmptyMain());
706-
}
707699
}
708700

709701
version (IN_LLVM)

dmd/mtype.d

+11-3
Original file line numberDiff line numberDiff line change
@@ -6411,9 +6411,6 @@ extern (C++) final class TypeClass : Type
64116411

64126412
override MOD deduceWild(Type t, bool isRef)
64136413
{
6414-
// If sym is forward referenced:
6415-
if (sym.semanticRun < PASS.semanticdone && !sym.isBaseInfoComplete())
6416-
sym.dsymbolSemantic(null);
64176414
ClassDeclaration cd = t.isClassHandle();
64186415
if (cd && (sym == cd || cd.isBaseOf(sym, null)))
64196416
return Type.deduceWild(t, isRef);
@@ -7169,6 +7166,17 @@ extern (C++) final class Parameter : ASTNode
71697166

71707167
extern (D) private static bool isCovariantScope(bool returnByRef, StorageClass from, StorageClass to) pure nothrow @nogc @safe
71717168
{
7169+
// Workaround for failing covariance when finding a common type of delegates,
7170+
// some of which have parameters with inferred scope
7171+
// https://issues.dlang.org/show_bug.cgi?id=21285
7172+
// The root cause is that scopeinferred is not part of the mangle, and mangle
7173+
// is used for type equality checks
7174+
if (to & STC.returninferred)
7175+
to &= ~STC.return_;
7176+
// note: f(return int* x) currently 'infers' scope without inferring `return`, in that case keep STC.scope
7177+
if (to & STC.scopeinferred && !(to & STC.return_))
7178+
to &= ~STC.scope_;
7179+
71727180
if (from == to)
71737181
return true;
71747182

dmd/parse.d

+1-3
Original file line numberDiff line numberDiff line change
@@ -3658,7 +3658,7 @@ class Parser(AST) : Lexer
36583658

36593659
case TOK.traits:
36603660
if (AST.TraitsExp te = cast(AST.TraitsExp) parsePrimaryExp())
3661-
if (te.ident && te.args)
3661+
if (te.ident)
36623662
{
36633663
t = new AST.TypeTraits(token.loc, te);
36643664
break;
@@ -9611,5 +9611,3 @@ private bool writeMixin(const(char)[] s, ref Loc loc)
96119611

96129612
return true;
96139613
}
9614-
9615-

dmd/traits.d

+23-58
Original file line numberDiff line numberDiff line change
@@ -1740,69 +1740,33 @@ else
17401740
bool err = false;
17411741

17421742
auto t = isType(o);
1743-
while (t)
1743+
auto ex = isExpression(o);
1744+
if (t)
17441745
{
1745-
if (auto tm = t.isTypeMixin())
1746+
Dsymbol s;
1747+
t.resolve(e.loc, sc2, ex, t, s);
1748+
if (t)
17461749
{
1747-
/* The mixin string could be a type or an expression.
1748-
* Have to try compiling it to see.
1749-
*/
1750-
OutBuffer buf;
1751-
if (expressionsToString(buf, sc, tm.exps))
1752-
{
1753-
err = true;
1754-
break;
1755-
}
1756-
const olderrors = global.errors;
1757-
const len = buf.length;
1758-
buf.writeByte(0);
1759-
const str = buf.extractSlice()[0 .. len];
1760-
scope p = new Parser!ASTCodegen(e.loc, sc._module, str, false);
1761-
p.nextToken();
1762-
//printf("p.loc.linnum = %d\n", p.loc.linnum);
1763-
1764-
o = p.parseTypeOrAssignExp(TOK.endOfFile);
1765-
if (olderrors != global.errors || p.token.value != TOK.endOfFile)
1766-
{
1750+
t.typeSemantic(e.loc, sc2);
1751+
if (t.ty == Terror)
17671752
err = true;
1768-
break;
1769-
}
1770-
t = o.isType();
17711753
}
1772-
else
1773-
break;
1754+
else if (s && s.errors)
1755+
err = true;
17741756
}
1775-
1776-
if (!err)
1757+
if (ex)
17771758
{
1778-
auto ex = t ? t.typeToExpression() : isExpression(o);
1779-
if (!ex && t)
1759+
ex = ex.expressionSemantic(sc2);
1760+
ex = resolvePropertiesOnly(sc2, ex);
1761+
ex = ex.optimize(WANTvalue);
1762+
if (sc2.func && sc2.func.type.ty == Tfunction)
17801763
{
1781-
Dsymbol s;
1782-
t.resolve(e.loc, sc2, ex, t, s);
1783-
if (t)
1784-
{
1785-
t.typeSemantic(e.loc, sc2);
1786-
if (t.ty == Terror)
1787-
err = true;
1788-
}
1789-
else if (s && s.errors)
1790-
err = true;
1791-
}
1792-
if (ex)
1793-
{
1794-
ex = ex.expressionSemantic(sc2);
1795-
ex = resolvePropertiesOnly(sc2, ex);
1796-
ex = ex.optimize(WANTvalue);
1797-
if (sc2.func && sc2.func.type.ty == Tfunction)
1798-
{
1799-
const tf = cast(TypeFunction)sc2.func.type;
1800-
err |= tf.isnothrow && canThrow(ex, sc2.func, false);
1801-
}
1802-
ex = checkGC(sc2, ex);
1803-
if (ex.op == EXP.error)
1804-
err = true;
1764+
const tf = cast(TypeFunction)sc2.func.type;
1765+
err |= tf.isnothrow && canThrow(ex, sc2.func, false);
18051766
}
1767+
ex = checkGC(sc2, ex);
1768+
if (ex.op == EXP.error)
1769+
err = true;
18061770
}
18071771

18081772
// Carefully detach the scope from the parent and throw it away as
@@ -2119,13 +2083,14 @@ version (IN_LLVM)
21192083
return ErrorExp.get();
21202084
}
21212085

2122-
if (sc.func is null)
2086+
auto fd = sc.getEnclosingFunction();
2087+
if (!fd)
21232088
{
21242089
e.error("`__traits(parameters)` may only be used inside a function");
21252090
return ErrorExp.get();
21262091
}
2127-
assert(sc.func && sc.parent.isFuncDeclaration());
2128-
auto tf = sc.parent.isFuncDeclaration.type.isTypeFunction();
2092+
2093+
auto tf = fd.type.isTypeFunction();
21292094
assert(tf);
21302095
auto exps = new Expressions(0);
21312096
int addParameterDG(size_t idx, Parameter x)

dmd/typesem.d

+2-4
Original file line numberDiff line numberDiff line change
@@ -1800,6 +1800,7 @@ extern(C++) Type typeSemantic(Type type, const ref Loc loc, Scope* sc)
18001800
mtype.exp.ident != Id.derivedMembers &&
18011801
mtype.exp.ident != Id.getMember &&
18021802
mtype.exp.ident != Id.parent &&
1803+
mtype.exp.ident != Id.parameters &&
18031804
mtype.exp.ident != Id.child &&
18041805
mtype.exp.ident != Id.toType &&
18051806
mtype.exp.ident != Id.getOverloads &&
@@ -2287,10 +2288,7 @@ RootObject compileTypeMixin(TypeMixin tm, Loc loc, Scope* sc)
22872288
return null;
22882289
}
22892290

2290-
Type t = o.isType();
2291-
Expression e = t ? t.typeToExpression() : o.isExpression();
2292-
2293-
return (!e && t) ? t : e;
2291+
return o;
22942292
}
22952293

22962294

0 commit comments

Comments
 (0)