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 v2.107.1 #4587

Merged
merged 13 commits into from
Mar 2, 2024
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.107.0+](https://dlang.org/changelog/2.107.0.html). (#4563, #4577)
- Frontend, druntime and Phobos are at version [2.107.1](https://dlang.org/changelog/2.107.0.html). (#4563, #4577, #4587)

#### Platform support

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ include(GetLinuxDistribution)
set(LDC_VERSION "1.37.0") # May be overridden by git hash tag
set(DMDFE_MAJOR_VERSION 2)
set(DMDFE_MINOR_VERSION 107)
set(DMDFE_PATCH_VERSION 0)
set(DMDFE_PATCH_VERSION 1)

set(DMD_VERSION ${DMDFE_MAJOR_VERSION}.${DMDFE_MINOR_VERSION}.${DMDFE_PATCH_VERSION})

Expand Down
8 changes: 7 additions & 1 deletion dmd/cparse.d
Original file line number Diff line number Diff line change
Expand Up @@ -2135,7 +2135,7 @@ final class CParser(AST) : Parser!AST
error("function identifier-list cannot end with `...`");
ft.parameterList.varargs = AST.VarArg.KRvariadic; // but C11 allows extra arguments
auto plLength = pl.length;
if (symbols.length != plLength)
if (symbols && symbols.length != plLength)
error(token.loc, "%d identifiers does not match %d declarations", cast(int)plLength, cast(int)symbols.length);

/* Transfer the types and storage classes from symbols[] to pl[]
Expand All @@ -2156,6 +2156,12 @@ final class CParser(AST) : Parser!AST

if (p.type || !(p.storageClass & STC.parameter))
error("storage class and type are not allowed in identifier-list");
if (!symbols)
{
// Error already given in cparseDeclaration
p.type = AST.Type.terror;
continue;
}
foreach (s; (*symbols)[]) // yes, quadratic
{
auto ad = s.isAttribDeclaration();
Expand Down
2 changes: 1 addition & 1 deletion dmd/dinterpret.d
Original file line number Diff line number Diff line change
Expand Up @@ -3812,7 +3812,7 @@ public:
if (v is v2 || !v.isOverlappedWith(v2))
continue;
auto e = (*sle.elements)[i];
if (e.op != EXP.void_)
if (e !is null && e.op != EXP.void_)
(*sle.elements)[i] = voidInitLiteral(e.type, v).copy();
}
}
Expand Down
16 changes: 8 additions & 8 deletions dmd/dmodule.d
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,7 @@ private const(char)[] processSource (const(ubyte)[] src, Module mod)
{
enum SourceEncoding { utf16, utf32}
enum Endian { little, big}
immutable loc = mod.getLoc();

/*
* Convert a buffer from UTF32 to UTF8
Expand All @@ -1490,7 +1491,7 @@ private const(char)[] processSource (const(ubyte)[] src, Module mod)

if (buf.length & 3)
{
.error(mod.loc, "%s `%s` odd length of UTF-32 char source %llu",
.error(loc, "%s `%s` odd length of UTF-32 char source %llu",
mod.kind, mod.toPrettyChars, cast(ulong) buf.length);
return null;
}
Expand All @@ -1507,7 +1508,7 @@ private const(char)[] processSource (const(ubyte)[] src, Module mod)
{
if (u > 0x10FFFF)
{
.error(mod.loc, "%s `%s` UTF-32 value %08x greater than 0x10FFFF", mod.kind, mod.toPrettyChars, u);
.error(loc, "%s `%s` UTF-32 value %08x greater than 0x10FFFF", mod.kind, mod.toPrettyChars, u);
return null;
}
dbuf.writeUTF8(u);
Expand Down Expand Up @@ -1537,7 +1538,7 @@ private const(char)[] processSource (const(ubyte)[] src, Module mod)

if (buf.length & 1)
{
.error(mod.loc, "%s `%s` odd length of UTF-16 char source %llu", mod.kind, mod.toPrettyChars, cast(ulong) buf.length);
.error(loc, "%s `%s` odd length of UTF-16 char source %llu", mod.kind, mod.toPrettyChars, cast(ulong) buf.length);
return null;
}

Expand All @@ -1557,26 +1558,26 @@ private const(char)[] processSource (const(ubyte)[] src, Module mod)
i++;
if (i >= eBuf.length)
{
.error(mod.loc, "%s `%s` surrogate UTF-16 high value %04x at end of file", mod.kind, mod.toPrettyChars, u);
.error(loc, "%s `%s` surrogate UTF-16 high value %04x at end of file", mod.kind, mod.toPrettyChars, u);
return null;
}
const u2 = readNext(&eBuf[i]);
if (u2 < 0xDC00 || 0xE000 <= u2)
{
.error(mod.loc, "%s `%s` surrogate UTF-16 low value %04x out of range", mod.kind, mod.toPrettyChars, u2);
.error(loc, "%s `%s` surrogate UTF-16 low value %04x out of range", mod.kind, mod.toPrettyChars, u2);
return null;
}
u = (u - 0xD7C0) << 10;
u |= (u2 - 0xDC00);
}
else if (u >= 0xDC00 && u <= 0xDFFF)
{
.error(mod.loc, "%s `%s` unpaired surrogate UTF-16 value %04x", mod.kind, mod.toPrettyChars, u);
.error(loc, "%s `%s` unpaired surrogate UTF-16 value %04x", mod.kind, mod.toPrettyChars, u);
return null;
}
else if (u == 0xFFFE || u == 0xFFFF)
{
.error(mod.loc, "%s `%s` illegal UTF-16 value %04x", mod.kind, mod.toPrettyChars, u);
.error(loc, "%s `%s` illegal UTF-16 value %04x", mod.kind, mod.toPrettyChars, u);
return null;
}
dbuf.writeUTF8(u);
Expand Down Expand Up @@ -1635,7 +1636,6 @@ private const(char)[] processSource (const(ubyte)[] src, Module mod)
// It's UTF-8
if (buf[0] >= 0x80)
{
auto loc = mod.getLoc();
.error(loc, "%s `%s` source file must start with BOM or ASCII character, not \\x%02X", mod.kind, mod.toPrettyChars, buf[0]);
return null;
}
Expand Down
4 changes: 1 addition & 3 deletions dmd/expression.d
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ extern (C++) /* IN_LLVM abstract */ class Expression : ASTNode
Type type; // !=null means that semantic() has been run
Loc loc; // file location
const EXP op; // to minimize use of dynamic_cast
bool parens; // if this is a parenthesized expression

extern (D) this(const ref Loc loc, EXP op) scope @safe
{
Expand Down Expand Up @@ -1355,7 +1356,6 @@ extern (C++) final class ComplexExp : Expression
extern (C++) class IdentifierExp : Expression
{
Identifier ident;
bool parens; // if it appears as (identifier)

extern (D) this(const ref Loc loc, Identifier ident) scope @safe
{
Expand Down Expand Up @@ -2447,8 +2447,6 @@ extern (C++) final class CompoundLiteralExp : Expression
*/
extern (C++) final class TypeExp : Expression
{
bool parens; // if this is a parenthesized expression

extern (D) this(const ref Loc loc, Type type) @safe
{
super(loc, EXP.type);
Expand Down
2 changes: 1 addition & 1 deletion dmd/expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class Expression : public ASTNode
Type *type; // !=NULL means that semantic() has been run
Loc loc; // file location
EXP op; // to minimize use of dynamic_cast
d_bool parens; // if this is a parenthesized expression

size_t size() const;
static void _init();
Expand Down Expand Up @@ -311,7 +312,6 @@ class IdentifierExp : public Expression
{
public:
Identifier *ident;
d_bool parens;

static IdentifierExp *create(const Loc &loc, Identifier *ident);
bool isLvalue() override final;
Expand Down
14 changes: 11 additions & 3 deletions dmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -12212,8 +12212,16 @@ version (IN_LLVM)
return result;
}

void handleCatArgument(Expressions *arguments, Expression e)
void handleCatArgument(Expressions *arguments, Expression e, Type catType, bool isRightArg)
{
auto tb = e.type.toBasetype();

if ((isRightArg && e.parens) || (!isRightArg && !tb.equals(catType)))
{
arguments.push(e);
return;
}

if (auto ce = e.isCatExp())
{
Expression lowering = ce.lowering;
Expand Down Expand Up @@ -12243,8 +12251,8 @@ version (IN_LLVM)
arguments.push(new StringExp(exp.loc, funcname.toDString()));
}

handleCatArgument(arguments, exp.e1);
handleCatArgument(arguments, exp.e2);
handleCatArgument(arguments, exp.e1, exp.type.toBasetype(), false);
handleCatArgument(arguments, exp.e2, exp.type.toBasetype(), true);

Expression id = new IdentifierExp(exp.loc, Id.empty);
id = new DotIdExp(exp.loc, id, Id.object);
Expand Down
9 changes: 4 additions & 5 deletions dmd/frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -2127,6 +2127,7 @@ class Expression : public ASTNode
Type* type;
Loc loc;
const EXP op;
bool parens;
size_t size() const;
static void _init();
static void deinitialize();
Expand Down Expand Up @@ -2615,7 +2616,6 @@ class IdentifierExp : public Expression
{
public:
Identifier* ident;
bool parens;
static IdentifierExp* create(const Loc& loc, Identifier* ident);
bool isLvalue() final override;
void accept(Visitor* v) override;
Expand Down Expand Up @@ -3472,7 +3472,6 @@ class TupleExp final : public Expression
class TypeExp final : public Expression
{
public:
bool parens;
TypeExp* syntaxCopy() override;
bool checkType() override;
bool checkValue() override;
Expand Down Expand Up @@ -5451,9 +5450,9 @@ struct UnionExp final
private:
union _AnonStruct_u
{
char exp[29LLU];
char exp[30LLU];
char integerexp[40LLU];
char errorexp[29LLU];
char errorexp[30LLU];
char realexp[48LLU];
char complexexp[64LLU];
char symoffexp[64LLU];
Expand All @@ -5462,7 +5461,7 @@ struct UnionExp final
char assocarrayliteralexp[56LLU];
char structliteralexp[76LLU];
char compoundliteralexp[40LLU];
char nullexp[29LLU];
char nullexp[30LLU];
char dotvarexp[49LLU];
char addrexp[40LLU];
char indexexp[74LLU];
Expand Down
7 changes: 3 additions & 4 deletions dmd/importc.d
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +243,15 @@ Expression castCallAmbiguity(Expression e, Scope* sc)

case EXP.call:
auto ce = (*pe).isCallExp();
auto ie = ce.e1.isIdentifierExp();
if (ie && ie.parens)
if (ce.e1.parens)
{
ce.e1 = expressionSemantic(ie, sc);
ce.e1 = expressionSemantic(ce.e1, sc);
if (ce.e1.op == EXP.type)
{
const numArgs = ce.arguments ? ce.arguments.length : 0;
if (numArgs >= 1)
{
ie.parens = false;
ce.e1.parens = false;
Expression arg;
foreach (a; (*ce.arguments)[])
{
Expand Down
48 changes: 17 additions & 31 deletions dmd/parse.d
Original file line number Diff line number Diff line change
Expand Up @@ -7155,7 +7155,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer

private void checkParens(TOK value, AST.Expression e)
{
if (precedence[e.op] == PREC.rel)
if (precedence[e.op] == PREC.rel && !e.parens)
error(e.loc, "`%s` must be surrounded by parentheses when next to operator `%s`", e.toChars(), Token.toChars(value));
}

Expand Down Expand Up @@ -8576,6 +8576,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
// ( expression )
nextToken();
e = parseExpression();
e.parens = true;
check(loc, TOK.rightParenthesis);
break;
}
Expand Down Expand Up @@ -8899,9 +8900,9 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
nextToken();
return AST.ErrorExp.get();
}
auto te = new AST.TypeExp(loc, t);
te.parens = true;
e = parsePostExp(te);
e = new AST.TypeExp(loc, t);
e.parens = true;
e = parsePostExp(e);
}
else if (token.value == TOK.leftParenthesis ||
token.value == TOK.plusPlus || token.value == TOK.minusMinus)
Expand Down Expand Up @@ -9218,61 +9219,47 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
private AST.Expression parseAndExp()
{
Loc loc = token.loc;
bool parens = token.value == TOK.leftParenthesis;
auto e = parseCmpExp();
while (token.value == TOK.and)
{
if (!parens)
checkParens(TOK.and, e);
parens = nextToken() == TOK.leftParenthesis;
checkParens(TOK.and, e);
nextToken();
auto e2 = parseCmpExp();
if (!parens)
checkParens(TOK.and, e2);
checkParens(TOK.and, e2);
e = new AST.AndExp(loc, e, e2);
parens = true; // don't call checkParens() for And
loc = token.loc;
}
return e;
}

private AST.Expression parseXorExp()
{
Loc loc = token.loc;
const loc = token.loc;

bool parens = token.value == TOK.leftParenthesis;
auto e = parseAndExp();
while (token.value == TOK.xor)
{
if (!parens)
checkParens(TOK.xor, e);
parens = nextToken() == TOK.leftParenthesis;
checkParens(TOK.xor, e);
nextToken();
auto e2 = parseAndExp();
if (!parens)
checkParens(TOK.xor, e2);
checkParens(TOK.xor, e2);
e = new AST.XorExp(loc, e, e2);
parens = true;
loc = token.loc;
}
return e;
}

private AST.Expression parseOrExp()
{
Loc loc = token.loc;
const loc = token.loc;

bool parens = token.value == TOK.leftParenthesis;
auto e = parseXorExp();
while (token.value == TOK.or)
{
if (!parens)
checkParens(TOK.or, e);
parens = nextToken() == TOK.leftParenthesis;
checkParens(TOK.or, e);
nextToken();
auto e2 = parseXorExp();
if (!parens)
checkParens(TOK.or, e2);
checkParens(TOK.or, e2);
e = new AST.OrExp(loc, e, e2);
parens = true;
loc = token.loc;
}
return e;
}
Expand Down Expand Up @@ -9323,7 +9310,6 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer

AST.Expression parseAssignExp()
{
bool parens = token.value == TOK.leftParenthesis;
AST.Expression e;
e = parseCondExp();
if (e is null)
Expand All @@ -9332,7 +9318,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
// require parens for e.g. `t ? a = 1 : b = 2`
void checkRequiredParens()
{
if (e.op == EXP.question && !parens)
if (e.op == EXP.question && !e.parens)
eSink.error(e.loc, "`%s` must be surrounded by parentheses when next to operator `%s`",
e.toChars(), Token.toChars(token.value));
}
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.107.0
v2.107.1
2 changes: 1 addition & 1 deletion packaging/reggae_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8995c511f1484022ce2927964bdf65190e0c672b
dea9fd3233cc66f9e1ca8003fff96e2cbbeb5dcf
Loading
Loading