Skip to content

Commit ef844b7

Browse files
authored
Merge pull request #4918 from kinke/merge_stable
Merge upstream stable
2 parents 20d22b1 + aa6637b commit ef844b7

28 files changed

+256
-83
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
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.111.0+](https://dlang.org/changelog/2.111.0.html). (#4877, #4910)
4+
- Frontend, druntime and Phobos are at version [2.111.0+](https://dlang.org/changelog/2.111.0.html). (#4877, #4910, #4918)
55
- 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)
66
- 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)
77
- ldc2.conf: Arrays can now be appended to via the `~=` operator. (#4848, #4856)

dmd/arraytypes.d

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ alias Strings = Array!(const(char)*);
2929
alias Identifiers = Array!(Identifier);
3030
alias TemplateParameters = Array!(TemplateParameter);
3131
alias Expressions = Array!(Expression);
32+
alias ArgumentLabels = Array!(ArgumentLabel);
3233
alias Statements = Array!(Statement);
3334
alias BaseClasses = Array!(BaseClass*);
3435
alias ClassDeclarations = Array!(ClassDeclaration);

dmd/arraytypes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ typedef Array<class TemplateParameter *> TemplateParameters;
1717

1818
typedef Array<class Expression *> Expressions;
1919

20+
typedef Array<struct ArgumentLabel> ArgumentLabels;
21+
2022
typedef Array<class Statement *> Statements;
2123

2224
typedef Array<struct BaseClass *> BaseClasses;

dmd/cparse.d

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1870,7 +1870,7 @@ final class CParser(AST) : Parser!AST
18701870
{
18711871
Identifier id;
18721872
AST.StringExp asmName;
1873-
auto dt = cparseDeclarator(DTR.xdirect, tspec, id, specifier);
1873+
auto dt = cparseDeclarator(DTR.xdirect_fd, tspec, id, specifier);
18741874
if (!dt)
18751875
{
18761876
panic();
@@ -2842,6 +2842,18 @@ final class CParser(AST) : Parser!AST
28422842
//printf("cparseDeclarator(%d, %s)\n", declarator, tbase.toChars());
28432843
AST.Types constTypes; // all the Types that will need `const` applied to them
28442844

2845+
// this.symbols can get changed to the symbol table for the
2846+
// parameter-type-list if we parse a function type.
2847+
// Callers are only ready to handle this if they pass DTR.xdirect_fd,
2848+
// so remember to restore this.symbols.
2849+
bool restore_symbols = true;
2850+
if (declarator == DTR.xdirect_fd)
2851+
{
2852+
declarator = DTR.xdirect;
2853+
restore_symbols = false;
2854+
}
2855+
2856+
28452857
/* Insert tx -> t into
28462858
* ts -> ... -> t
28472859
* so that
@@ -3033,7 +3045,7 @@ final class CParser(AST) : Parser!AST
30333045
//tf = tf.addSTC(storageClass); // TODO
30343046
insertTx(ts, tf, t); // ts -> ... -> tf -> t
30353047

3036-
if (ts != tf)
3048+
if (ts != tf || restore_symbols)
30373049
this.symbols = symbolsSave;
30383050
break;
30393051
}
@@ -5107,6 +5119,7 @@ final class CParser(AST) : Parser!AST
51075119
/// Types of declarator to parse
51085120
enum DTR
51095121
{
5122+
xdirect_fd = 0, /// C11 6.7.6 direct-declarator, allow to start function definition
51105123
xdirect = 1, /// C11 6.7.6 direct-declarator
51115124
xabstract = 2, /// C11 6.7.7 abstract-declarator
51125125
xparameter = 3, /// parameter declarator may be either direct or abstract

dmd/cxxfrontend.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ Expression getDefaultValue(EnumDeclaration ed, Loc loc)
257257
/***********************************************************
258258
* expression.d
259259
*/
260-
void expandTuples(Expressions* exps, Identifiers* names = null)
260+
void expandTuples(Expressions* exps, ArgumentLabels* names = null)
261261
{
262262
return dmd.expression.expandTuples(exps, names);
263263
}
@@ -306,7 +306,7 @@ bool functionSemantic3(FuncDeclaration fd)
306306
return dmd.funcsem.functionSemantic3(fd);
307307
}
308308

309-
MATCH leastAsSpecialized(FuncDeclaration fd, FuncDeclaration g, Identifiers* names)
309+
MATCH leastAsSpecialized(FuncDeclaration fd, FuncDeclaration g, ArgumentLabels* names)
310310
{
311311
import dmd.funcsem;
312312
return dmd.funcsem.leastAsSpecialized(fd, g, names);

dmd/declaration.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ namespace dmd
3535
bool functionSemantic(FuncDeclaration* fd);
3636
bool functionSemantic3(FuncDeclaration* fd);
3737
bool checkClosure(FuncDeclaration* fd);
38-
MATCH leastAsSpecialized(FuncDeclaration *f, FuncDeclaration *g, Identifiers *names);
38+
MATCH leastAsSpecialized(FuncDeclaration *f, FuncDeclaration *g, ArgumentLabels *names);
3939
PURE isPure(FuncDeclaration *f);
4040
FuncDeclaration *genCfunc(Parameters *args, Type *treturn, const char *name, StorageClass stc=0);
4141
FuncDeclaration *genCfunc(Parameters *args, Type *treturn, Identifier *id, StorageClass stc=0);

dmd/dtemplate.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3677,11 +3677,11 @@ extern (C++) class TemplateInstance : ScopeDsymbol
36773677
ScopeDsymbol argsym; // argument symbol table
36783678
size_t hash; // cached result of toHash()
36793679

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

36863686
TemplateInstances* deferred;
36873687

dmd/enumsem.d

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,10 @@ void enumSemantic(Scope* sc, EnumDeclaration ed)
158158
ed.semanticRun = PASS.initial;
159159
return;
160160
}
161-
else
162-
// Ensure that semantic is run to detect. e.g. invalid forward references
163-
sym.dsymbolSemantic(sc);
161+
// Ensure that semantic is run to detect. e.g. invalid forward references
162+
sym.dsymbolSemantic(sc);
163+
if (ed.errors)
164+
ed.memtype = Type.terror; // avoid infinite recursion in toBaseType
164165
}
165166
if (ed.memtype.ty == Tvoid)
166167
{
@@ -175,6 +176,8 @@ void enumSemantic(Scope* sc, EnumDeclaration ed)
175176
ed.semanticRun = PASS.semanticdone;
176177
return;
177178
}
179+
if (global.params.useTypeInfo && Type.dtypeinfo && !ed.inNonRoot())
180+
semanticTypeInfo(sc, ed.memtype);
178181
}
179182

180183
if (!ed.members) // enum ident : memtype;
@@ -341,6 +344,9 @@ void enumSemantic(Scope* sc, EnumDeclaration ed)
341344
if (EnumMember em = s.isEnumMember())
342345
em.dsymbolSemantic(em._scope);
343346
});
347+
348+
if (global.params.useTypeInfo && Type.dtypeinfo && !ed.inNonRoot())
349+
semanticTypeInfo(sc, ed.memtype);
344350
//printf("ed.defaultval = %lld\n", ed.defaultval);
345351

346352
//if (ed.defaultval) printf("ed.defaultval: %s %s\n", ed.defaultval.toChars(), ed.defaultval.type.toChars());

dmd/expression.d

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ inout(Expression) lastComma(inout Expression e)
8686
* exps = array of Expressions
8787
* names = optional array of names corresponding to Expressions
8888
*/
89-
void expandTuples(Expressions* exps, Identifiers* names = null)
89+
void expandTuples(Expressions* exps, ArgumentLabels* names = null)
9090
{
9191
//printf("expandTuples()\n");
9292
if (exps is null)
@@ -116,7 +116,7 @@ void expandTuples(Expressions* exps, Identifiers* names = null)
116116
}
117117
foreach (i; 1 .. length)
118118
{
119-
names.insert(index + i, cast(Identifier) null);
119+
names.insert(index + i, ArgumentLabel(cast(Identifier) null, Loc.init));
120120
}
121121
}
122122
}
@@ -2469,7 +2469,7 @@ extern (C++) final class NewExp : Expression
24692469
Expression thisexp; // if !=null, 'this' for class being allocated
24702470
Type newtype;
24712471
Expressions* arguments; // Array of Expression's
2472-
Identifiers* names; // Array of names corresponding to expressions
2472+
ArgumentLabels* names; // Array of names(name and location of name) corresponding to expressions
24732473
Expression placement; // if !=null, then PlacementExpression
24742474

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

24822482
/// Puts the `arguments` and `names` into an `ArgumentList` for easily passing them around.
24832483
/// The fields are still separate for backwards compatibility
2484+
24842485
extern (D) ArgumentList argumentList() { return ArgumentList(arguments, names); }
24852486

2486-
extern (D) this(Loc loc, Expression placement, Expression thisexp, Type newtype, Expressions* arguments, Identifiers* names = null) @safe
2487+
extern (D) this(Loc loc, Expression placement, Expression thisexp, Type newtype, Expressions* arguments, ArgumentLabels* names = null) @safe
24872488
{
24882489
super(loc, EXP.new_);
24892490
this.placement = placement;
@@ -3304,29 +3305,36 @@ extern (C++) final class DotTypeExp : UnaExp
33043305
struct ArgumentList
33053306
{
33063307
Expressions* arguments; // function arguments
3307-
Identifiers* names; // named argument identifiers
3308+
ArgumentLabels* names; // named argument labels
33083309

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

33113312
/// Returns: whether this argument list contains any named arguments
3312-
bool hasNames() const @nogc nothrow pure @safe
3313+
bool hasArgNames() const @nogc nothrow pure @safe
33133314
{
33143315
if (names is null)
33153316
return false;
3316-
foreach (name; *names)
3317-
if (name !is null)
3317+
foreach (argLabel; *names)
3318+
if (argLabel.name !is null)
33183319
return true;
33193320

33203321
return false;
33213322
}
33223323
}
33233324

3325+
// Contains both `name` and `location of the name` for an expression.
3326+
struct ArgumentLabel
3327+
{
3328+
Identifier name; // name of the argument
3329+
Loc loc; // location of the name
3330+
}
3331+
33243332
/***********************************************************
33253333
*/
33263334
extern (C++) final class CallExp : UnaExp
33273335
{
33283336
Expressions* arguments; // function arguments
3329-
Identifiers* names; // named argument identifiers
3337+
ArgumentLabels *names; // named argument labels
33303338
FuncDeclaration f; // symbol to call
33313339
bool directcall; // true if a virtual call is devirtualized
33323340
bool inDebugStatement; /// true if this was in a debug statement
@@ -3338,7 +3346,7 @@ extern (C++) final class CallExp : UnaExp
33383346
/// The fields are still separate for backwards compatibility
33393347
extern (D) ArgumentList argumentList() { return ArgumentList(arguments, names); }
33403348

3341-
extern (D) this(Loc loc, Expression e, Expressions* exps, Identifiers* names = null) @safe
3349+
extern (D) this(Loc loc, Expression e, Expressions* exps, ArgumentLabels *names = null) @safe
33423350
{
33433351
super(loc, EXP.call, e);
33443352
this.arguments = exps;

dmd/expression.h

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ namespace dmd
6060
// Entry point for CTFE.
6161
// A compile-time result is required. Give an error if not possible
6262
Expression *ctfeInterpret(Expression *e);
63-
void expandTuples(Expressions *exps, Identifiers *names = nullptr);
63+
void expandTuples(Expressions *exps, ArgumentLabels *names = nullptr);
6464
Expression *optimize(Expression *exp, int result, bool keepLvalue = false);
6565
}
6666

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

546546
Expression *argprefix; // expression to be evaluated just before arguments[]
@@ -817,23 +817,38 @@ class DotTypeExp final : public UnaExp
817817
struct ArgumentList final
818818
{
819819
Expressions* arguments;
820-
Identifiers* names;
820+
ArgumentLabels* names;
821821
ArgumentList() :
822822
arguments(),
823823
names()
824824
{
825825
}
826-
ArgumentList(Expressions* arguments, Identifiers* names = nullptr) :
826+
ArgumentList(Expressions* arguments, ArgumentLabels* names = nullptr) :
827827
arguments(arguments),
828828
names(names)
829829
{}
830830
};
831831

832+
struct ArgumentLabel final
833+
{
834+
Identifier* name;
835+
Loc loc;
836+
ArgumentLabel() :
837+
name(),
838+
loc()
839+
{
840+
}
841+
ArgumentLabel(Identifier* name, Loc loc = Loc()) :
842+
name(name),
843+
loc(loc)
844+
{}
845+
};
846+
832847
class CallExp final : public UnaExp
833848
{
834849
public:
835850
Expressions *arguments; // function arguments
836-
Identifiers *names;
851+
ArgumentLabels* names; // function argument Labels (name + location of name)
837852
FuncDeclaration *f; // symbol to call
838853
d_bool directcall; // true if a virtual call is devirtualized
839854
d_bool inDebugStatement; // true if this was in a debug statement

0 commit comments

Comments
 (0)