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 #3937

Merged
merged 2 commits into from
Mar 8, 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.099.0](https://dlang.org/changelog/2.099.0.html). (#3917, #3893)
- Frontend, druntime and Phobos are at version [2.099.0+](https://dlang.org/changelog/2.099.0.html). (#3917, #3893, #3937)
- Support for LLVM 13. The prebuilt packages use v13.0.1. (#3842)
- 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.
- `-linkonce-templates` is less aggressive by default now and IMHO production-ready. (#3924)
Expand Down
2 changes: 1 addition & 1 deletion dmd/aggregate.d
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
if (overflow) assert(0);

// Skip no-op for noreturn without custom aligment
if (memsize != 0 || !alignment.isDefault())
if (memalignsize != 0 || !alignment.isDefault())
alignmember(alignment, memalignsize, &ofs);

uint memoffset = ofs;
Expand Down
26 changes: 15 additions & 11 deletions dmd/dmodule.d
Original file line number Diff line number Diff line change
Expand Up @@ -736,24 +736,28 @@ else

//printf("Module::read('%s') file '%s'\n", toChars(), srcfile.toChars());

if (global.params.emitMakeDeps)
{
global.params.makeDeps.push(srcfile.toChars());
}


bool success;
if (auto readResult = FileManager.fileManager.lookup(srcfile))
{
srcBuffer = readResult;
return true;
success = true;
}

auto readResult = File.read(srcfile.toChars());
if (loadSourceBuffer(loc, readResult))
else
{
FileManager.fileManager.add(srcfile, srcBuffer);
return true;
auto readResult = File.read(srcfile.toChars());
if (loadSourceBuffer(loc, readResult))
{
FileManager.fileManager.add(srcfile, srcBuffer);
success = true;
}
}
return false;
if (success && global.params.emitMakeDeps)
{
global.params.makeDeps.push(srcfile.toChars());
}
return success;
}

/// syntactic parse
Expand Down
12 changes: 10 additions & 2 deletions dmd/lexer.d
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,17 @@ class Lexer
goto case_ident;

case 'r':
if (p[1] != '"')
if (Ccompile || p[1] != '"')
goto case_ident;
p++;
goto case '`';
case '`':
if (Ccompile)
goto default;
wysiwygStringConstant(t);
return;
case 'x':
if (p[1] != '"')
if (Ccompile || p[1] != '"')
goto case_ident;
p++;
auto start = p;
Expand All @@ -332,6 +334,8 @@ class Lexer
error("Built-in hex string literals are obsolete, use `std.conv.hexString!%s` instead.", hexString.extractChars());
return;
case 'q':
if (Ccompile)
goto case_ident;
if (p[1] == '"')
{
p++;
Expand Down Expand Up @@ -605,6 +609,7 @@ class Lexer
endOfLine();
continue;
case '+':
if (!Ccompile)
{
int nest;
startLoc = loc();
Expand Down Expand Up @@ -674,6 +679,7 @@ class Lexer
}
continue;
}
break;
default:
break;
}
Expand Down Expand Up @@ -2710,6 +2716,8 @@ class Lexer
case '2':
case '3':
case '4':
if (!linemarker)
goto Lerr;
flags = true; // linemarker flags seen
++p;
if ('0' <= *p && *p <= '9')
Expand Down
2 changes: 1 addition & 1 deletion dmd/mtype.d
Original file line number Diff line number Diff line change
Expand Up @@ -6397,7 +6397,7 @@ extern (C++) final class TypeClass : Type
/* Conversion derived to const(base)
*/
int offset = 0;
if (to.isBaseOf(this, &offset) && MODimplicitConv(mod, to.mod))
if (to.isBaseOf(this, &offset) && offset == 0 && MODimplicitConv(mod, to.mod))
{
// Disallow:
// derived to base
Expand Down
98 changes: 48 additions & 50 deletions dmd/statementsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -2553,68 +2553,66 @@ version (IN_LLVM)
Expression initialExp = cs.exp;

// The switch'ed value has errors and doesn't provide the actual type
// Don't touch the case to not replace it with an `ErrorExp` even if it is valid
// Omit the cast to enable further semantic (exluding the check for matching types)
if (sw.condition.type && !sw.condition.type.isTypeError())
{
cs.exp = cs.exp.implicitCastTo(sc, sw.condition.type);
cs.exp = cs.exp.optimize(WANTvalue | WANTexpand);
cs.exp = cs.exp.optimize(WANTvalue | WANTexpand);

Expression e = cs.exp;
// Remove all the casts the user and/or implicitCastTo may introduce
// otherwise we'd sometimes fail the check below.
while (e.op == EXP.cast_)
e = (cast(CastExp)e).e1;

/* This is where variables are allowed as case expressions.
*/
if (e.op == EXP.variable)
{
VarExp ve = cast(VarExp)e;
VarDeclaration v = ve.var.isVarDeclaration();
Type t = cs.exp.type.toBasetype();
if (v && (t.isintegral() || t.ty == Tclass))
{
/* Flag that we need to do special code generation
* for this, i.e. generate a sequence of if-then-else
*/
sw.hasVars = 1;

/* TODO check if v can be uninitialized at that point.
*/
if (!v.isConst() && !v.isImmutable())
{
cs.error("`case` variables have to be `const` or `immutable`");
}

Expression e = cs.exp;
// Remove all the casts the user and/or implicitCastTo may introduce
// otherwise we'd sometimes fail the check below.
while (e.op == EXP.cast_)
e = (cast(CastExp)e).e1;
if (sw.isFinal)
{
cs.error("`case` variables not allowed in `final switch` statements");
errors = true;
}

/* This is where variables are allowed as case expressions.
*/
if (e.op == EXP.variable)
{
VarExp ve = cast(VarExp)e;
VarDeclaration v = ve.var.isVarDeclaration();
Type t = cs.exp.type.toBasetype();
if (v && (t.isintegral() || t.ty == Tclass))
/* Find the outermost scope `scx` that set `sw`.
* Then search scope `scx` for a declaration of `v`.
*/
for (Scope* scx = sc; scx; scx = scx.enclosing)
{
/* Flag that we need to do special code generation
* for this, i.e. generate a sequence of if-then-else
*/
sw.hasVars = 1;

/* TODO check if v can be uninitialized at that point.
*/
if (!v.isConst() && !v.isImmutable())
{
cs.error("`case` variables have to be `const` or `immutable`");
}
if (scx.enclosing && scx.enclosing.sw == sw)
continue;
assert(scx.sw == sw);

if (sw.isFinal)
if (!scx.search(cs.exp.loc, v.ident, null))
{
cs.error("`case` variables not allowed in `final switch` statements");
cs.error("`case` variable `%s` declared at %s cannot be declared in `switch` body",
v.toChars(), v.loc.toChars());
errors = true;
}

/* Find the outermost scope `scx` that set `sw`.
* Then search scope `scx` for a declaration of `v`.
*/
for (Scope* scx = sc; scx; scx = scx.enclosing)
{
if (scx.enclosing && scx.enclosing.sw == sw)
continue;
assert(scx.sw == sw);

if (!scx.search(cs.exp.loc, v.ident, null))
{
cs.error("`case` variable `%s` declared at %s cannot be declared in `switch` body",
v.toChars(), v.loc.toChars());
errors = true;
}
break;
}
goto L1;
break;
}
goto L1;
}
else
cs.exp = cs.exp.ctfeInterpret();
}
else
cs.exp = cs.exp.ctfeInterpret();

if (StringExp se = cs.exp.toStringExp())
cs.exp = se;
Expand Down
2 changes: 1 addition & 1 deletion packaging/dlang-tools_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.099.0-beta.1
v2.099.0
2 changes: 1 addition & 1 deletion packaging/dub_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.28.0-beta.1
v1.28.0
2 changes: 1 addition & 1 deletion runtime/druntime