Skip to content
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.111.0+](https://dlang.org/changelog/2.111.0.html). (#4877, #4910)
- Frontend, druntime and Phobos are at version [2.111.0+](https://dlang.org/changelog/2.111.0.html). (#4877, #4910, #4918)
- Keep frame pointers by default with `-O` for some targets, notably AArch64 (except Windows), x86_64 (except Windows and glibc Linux), Windows x86, and Android. This fixes druntime backtraces with optimized code (incl. prebuilt druntime/Phobos). (#4889)
- The prebuilt (non-musl) Linux packages are now generated on Ubuntu 22.04; the minimum glibc version has accordingly been raised from v2.31 to v2.35. (#4893)
- ldc2.conf: Arrays can now be appended to via the `~=` operator. (#4848, #4856)
Expand Down
1 change: 1 addition & 0 deletions dmd/arraytypes.d
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ alias Strings = Array!(const(char)*);
alias Identifiers = Array!(Identifier);
alias TemplateParameters = Array!(TemplateParameter);
alias Expressions = Array!(Expression);
alias ArgumentLabels = Array!(ArgumentLabel);
alias Statements = Array!(Statement);
alias BaseClasses = Array!(BaseClass*);
alias ClassDeclarations = Array!(ClassDeclaration);
Expand Down
2 changes: 2 additions & 0 deletions dmd/arraytypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ typedef Array<class TemplateParameter *> TemplateParameters;

typedef Array<class Expression *> Expressions;

typedef Array<struct ArgumentLabel> ArgumentLabels;

typedef Array<class Statement *> Statements;

typedef Array<struct BaseClass *> BaseClasses;
Expand Down
17 changes: 15 additions & 2 deletions dmd/cparse.d
Original file line number Diff line number Diff line change
Expand Up @@ -1870,7 +1870,7 @@ final class CParser(AST) : Parser!AST
{
Identifier id;
AST.StringExp asmName;
auto dt = cparseDeclarator(DTR.xdirect, tspec, id, specifier);
auto dt = cparseDeclarator(DTR.xdirect_fd, tspec, id, specifier);
if (!dt)
{
panic();
Expand Down Expand Up @@ -2842,6 +2842,18 @@ final class CParser(AST) : Parser!AST
//printf("cparseDeclarator(%d, %s)\n", declarator, tbase.toChars());
AST.Types constTypes; // all the Types that will need `const` applied to them

// this.symbols can get changed to the symbol table for the
// parameter-type-list if we parse a function type.
// Callers are only ready to handle this if they pass DTR.xdirect_fd,
// so remember to restore this.symbols.
bool restore_symbols = true;
if (declarator == DTR.xdirect_fd)
{
declarator = DTR.xdirect;
restore_symbols = false;
}


/* Insert tx -> t into
* ts -> ... -> t
* so that
Expand Down Expand Up @@ -3033,7 +3045,7 @@ final class CParser(AST) : Parser!AST
//tf = tf.addSTC(storageClass); // TODO
insertTx(ts, tf, t); // ts -> ... -> tf -> t

if (ts != tf)
if (ts != tf || restore_symbols)
this.symbols = symbolsSave;
break;
}
Expand Down Expand Up @@ -5107,6 +5119,7 @@ final class CParser(AST) : Parser!AST
/// Types of declarator to parse
enum DTR
{
xdirect_fd = 0, /// C11 6.7.6 direct-declarator, allow to start function definition
xdirect = 1, /// C11 6.7.6 direct-declarator
xabstract = 2, /// C11 6.7.7 abstract-declarator
xparameter = 3, /// parameter declarator may be either direct or abstract
Expand Down
4 changes: 2 additions & 2 deletions dmd/cxxfrontend.d
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ Expression getDefaultValue(EnumDeclaration ed, Loc loc)
/***********************************************************
* expression.d
*/
void expandTuples(Expressions* exps, Identifiers* names = null)
void expandTuples(Expressions* exps, ArgumentLabels* names = null)
{
return dmd.expression.expandTuples(exps, names);
}
Expand Down Expand Up @@ -306,7 +306,7 @@ bool functionSemantic3(FuncDeclaration fd)
return dmd.funcsem.functionSemantic3(fd);
}

MATCH leastAsSpecialized(FuncDeclaration fd, FuncDeclaration g, Identifiers* names)
MATCH leastAsSpecialized(FuncDeclaration fd, FuncDeclaration g, ArgumentLabels* names)
{
import dmd.funcsem;
return dmd.funcsem.leastAsSpecialized(fd, g, names);
Expand Down
2 changes: 1 addition & 1 deletion dmd/declaration.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace dmd
bool functionSemantic(FuncDeclaration* fd);
bool functionSemantic3(FuncDeclaration* fd);
bool checkClosure(FuncDeclaration* fd);
MATCH leastAsSpecialized(FuncDeclaration *f, FuncDeclaration *g, Identifiers *names);
MATCH leastAsSpecialized(FuncDeclaration *f, FuncDeclaration *g, ArgumentLabels *names);
PURE isPure(FuncDeclaration *f);
FuncDeclaration *genCfunc(Parameters *args, Type *treturn, const char *name, StorageClass stc=0);
FuncDeclaration *genCfunc(Parameters *args, Type *treturn, Identifier *id, StorageClass stc=0);
Expand Down
4 changes: 2 additions & 2 deletions dmd/dtemplate.d
Original file line number Diff line number Diff line change
Expand Up @@ -3677,11 +3677,11 @@ extern (C++) class TemplateInstance : ScopeDsymbol
ScopeDsymbol argsym; // argument symbol table
size_t hash; // cached result of toHash()

/// For function template, these are the function names and arguments
/// For function template, these are the function fnames(name and loc of it) and arguments
/// Relevant because different resolutions of `auto ref` parameters
/// create different template instances even with the same template arguments
Expressions* fargs;
Identifiers* fnames;
ArgumentLabels* fnames;

TemplateInstances* deferred;

Expand Down
12 changes: 9 additions & 3 deletions dmd/enumsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,10 @@ void enumSemantic(Scope* sc, EnumDeclaration ed)
ed.semanticRun = PASS.initial;
return;
}
else
// Ensure that semantic is run to detect. e.g. invalid forward references
sym.dsymbolSemantic(sc);
// Ensure that semantic is run to detect. e.g. invalid forward references
sym.dsymbolSemantic(sc);
if (ed.errors)
ed.memtype = Type.terror; // avoid infinite recursion in toBaseType
}
if (ed.memtype.ty == Tvoid)
{
Expand All @@ -175,6 +176,8 @@ void enumSemantic(Scope* sc, EnumDeclaration ed)
ed.semanticRun = PASS.semanticdone;
return;
}
if (global.params.useTypeInfo && Type.dtypeinfo && !ed.inNonRoot())
semanticTypeInfo(sc, ed.memtype);
}

if (!ed.members) // enum ident : memtype;
Expand Down Expand Up @@ -341,6 +344,9 @@ void enumSemantic(Scope* sc, EnumDeclaration ed)
if (EnumMember em = s.isEnumMember())
em.dsymbolSemantic(em._scope);
});

if (global.params.useTypeInfo && Type.dtypeinfo && !ed.inNonRoot())
semanticTypeInfo(sc, ed.memtype);
//printf("ed.defaultval = %lld\n", ed.defaultval);

//if (ed.defaultval) printf("ed.defaultval: %s %s\n", ed.defaultval.toChars(), ed.defaultval.type.toChars());
Expand Down
28 changes: 18 additions & 10 deletions dmd/expression.d
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ inout(Expression) lastComma(inout Expression e)
* exps = array of Expressions
* names = optional array of names corresponding to Expressions
*/
void expandTuples(Expressions* exps, Identifiers* names = null)
void expandTuples(Expressions* exps, ArgumentLabels* names = null)
{
//printf("expandTuples()\n");
if (exps is null)
Expand Down Expand Up @@ -116,7 +116,7 @@ void expandTuples(Expressions* exps, Identifiers* names = null)
}
foreach (i; 1 .. length)
{
names.insert(index + i, cast(Identifier) null);
names.insert(index + i, ArgumentLabel(cast(Identifier) null, Loc.init));
}
}
}
Expand Down Expand Up @@ -2469,7 +2469,7 @@ extern (C++) final class NewExp : Expression
Expression thisexp; // if !=null, 'this' for class being allocated
Type newtype;
Expressions* arguments; // Array of Expression's
Identifiers* names; // Array of names corresponding to expressions
ArgumentLabels* names; // Array of names(name and location of name) corresponding to expressions
Expression placement; // if !=null, then PlacementExpression

Expression argprefix; // expression to be evaluated just before arguments[]
Expand All @@ -2481,9 +2481,10 @@ extern (C++) final class NewExp : Expression

/// Puts the `arguments` and `names` into an `ArgumentList` for easily passing them around.
/// The fields are still separate for backwards compatibility

extern (D) ArgumentList argumentList() { return ArgumentList(arguments, names); }

extern (D) this(Loc loc, Expression placement, Expression thisexp, Type newtype, Expressions* arguments, Identifiers* names = null) @safe
extern (D) this(Loc loc, Expression placement, Expression thisexp, Type newtype, Expressions* arguments, ArgumentLabels* names = null) @safe
{
super(loc, EXP.new_);
this.placement = placement;
Expand Down Expand Up @@ -3304,29 +3305,36 @@ extern (C++) final class DotTypeExp : UnaExp
struct ArgumentList
{
Expressions* arguments; // function arguments
Identifiers* names; // named argument identifiers
ArgumentLabels* names; // named argument labels

size_t length() const @nogc nothrow pure @safe { return arguments ? arguments.length : 0; }

/// Returns: whether this argument list contains any named arguments
bool hasNames() const @nogc nothrow pure @safe
bool hasArgNames() const @nogc nothrow pure @safe
{
if (names is null)
return false;
foreach (name; *names)
if (name !is null)
foreach (argLabel; *names)
if (argLabel.name !is null)
return true;

return false;
}
}

// Contains both `name` and `location of the name` for an expression.
struct ArgumentLabel
{
Identifier name; // name of the argument
Loc loc; // location of the name
}

/***********************************************************
*/
extern (C++) final class CallExp : UnaExp
{
Expressions* arguments; // function arguments
Identifiers* names; // named argument identifiers
ArgumentLabels *names; // named argument labels
FuncDeclaration f; // symbol to call
bool directcall; // true if a virtual call is devirtualized
bool inDebugStatement; /// true if this was in a debug statement
Expand All @@ -3338,7 +3346,7 @@ extern (C++) final class CallExp : UnaExp
/// The fields are still separate for backwards compatibility
extern (D) ArgumentList argumentList() { return ArgumentList(arguments, names); }

extern (D) this(Loc loc, Expression e, Expressions* exps, Identifiers* names = null) @safe
extern (D) this(Loc loc, Expression e, Expressions* exps, ArgumentLabels *names = null) @safe
{
super(loc, EXP.call, e);
this.arguments = exps;
Expand Down
25 changes: 20 additions & 5 deletions dmd/expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace dmd
// Entry point for CTFE.
// A compile-time result is required. Give an error if not possible
Expression *ctfeInterpret(Expression *e);
void expandTuples(Expressions *exps, Identifiers *names = nullptr);
void expandTuples(Expressions *exps, ArgumentLabels *names = nullptr);
Expression *optimize(Expression *exp, int result, bool keepLvalue = false);
}

Expand Down Expand Up @@ -540,7 +540,7 @@ class NewExp final : public Expression
Expression *thisexp; // if !NULL, 'this' for class being allocated
Type *newtype;
Expressions *arguments; // Array of Expression's
Identifiers *names; // Array of names corresponding to expressions
ArgumentLabels *names; // Array of argument Labels (name and location of name) corresponding to expressions
Expression *placement; // if !NULL, placement expression

Expression *argprefix; // expression to be evaluated just before arguments[]
Expand Down Expand Up @@ -817,23 +817,38 @@ class DotTypeExp final : public UnaExp
struct ArgumentList final
{
Expressions* arguments;
Identifiers* names;
ArgumentLabels* names;
ArgumentList() :
arguments(),
names()
{
}
ArgumentList(Expressions* arguments, Identifiers* names = nullptr) :
ArgumentList(Expressions* arguments, ArgumentLabels* names = nullptr) :
arguments(arguments),
names(names)
{}
};

struct ArgumentLabel final
{
Identifier* name;
Loc loc;
ArgumentLabel() :
name(),
loc()
{
}
ArgumentLabel(Identifier* name, Loc loc = Loc()) :
name(name),
loc(loc)
{}
};

class CallExp final : public UnaExp
{
public:
Expressions *arguments; // function arguments
Identifiers *names;
ArgumentLabels* names; // function argument Labels (name + location of name)
FuncDeclaration *f; // symbol to call
d_bool directcall; // true if a virtual call is devirtualized
d_bool inDebugStatement; // true if this was in a debug statement
Expand Down
Loading