Skip to content

Commit

Permalink
d: Merge upstream dmd, druntime f1a045928e
Browse files Browse the repository at this point in the history
D front-end changes:

    - Import dmd v2.106.1-rc.1.
    - Unrecognized pragmas are no longer an error by default.

D runtime changes:

    - Import druntime v2.106.1-rc.1.

gcc/d/ChangeLog:

	* dmd/MERGE: Merge upstream dmd f1a045928e.
	* dmd/VERSION: Bump version to v2.106.1-rc.1.
	* gdc.texi (fignore-unknown-pragmas): Update documentation.
	* d-builtins.cc (covariant_with_builtin_type_p): Update for new
	front-end interface.
	* d-lang.cc (d_parse_file): Likewise.
	* typeinfo.cc (make_frontend_typeinfo): Likewise.

libphobos/ChangeLog:

	* libdruntime/MERGE: Merge upstream druntime f1a045928e.
	* libdruntime/Makefile.am (DRUNTIME_DSOURCES): Add
	core/stdc/stdatomic.d.
	* libdruntime/Makefile.in: Regenerate.
  • Loading branch information
ibuclaw committed Feb 2, 2024
1 parent cfc6d9a commit 838e706
Show file tree
Hide file tree
Showing 65 changed files with 3,209 additions and 1,960 deletions.
2 changes: 1 addition & 1 deletion gcc/d/d-builtins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ static bool
covariant_with_builtin_type_p (Type *t1, Type *t2)
{
/* Check whether the declared function matches the built-in. */
if (same_type_p (t1, t2) || t1->covariant (t2) == Covariant::yes)
if (same_type_p (t1, t2) || covariant (t1, t2) == Covariant::yes)
return true;

/* May not be covariant because of D attributes applied on t1.
Expand Down
3 changes: 2 additions & 1 deletion gcc/d/d-lang.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ along with GCC; see the file COPYING3. If not see
#include "dmd/cond.h"
#include "dmd/declaration.h"
#include "dmd/doc.h"
#include "dmd/dsymbol.h"
#include "dmd/errors.h"
#include "dmd/expression.h"
#include "dmd/hdrgen.h"
Expand Down Expand Up @@ -1226,7 +1227,7 @@ d_parse_file (void)
if (global.params.v.verbose)
message ("importall %s", m->toChars ());

m->importAll (NULL);
importAll (m, NULL);
}

if (global.errors)
Expand Down
2 changes: 1 addition & 1 deletion gcc/d/dmd/MERGE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
2bbf64907cbbb483d003e0a8fcf8b502e4883799
f1a045928e03239b9477f9497f43f2cf0e61e959

The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository.
2 changes: 1 addition & 1 deletion gcc/d/dmd/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.106.0
v2.106.1-rc.1
166 changes: 1 addition & 165 deletions gcc/d/dmd/aliasthis.d
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,10 @@
module dmd.aliasthis;

import core.stdc.stdio;
import dmd.aggregate;
import dmd.dscope;

import dmd.dsymbol;
import dmd.expression;
import dmd.expressionsem;
import dmd.globals;
import dmd.identifier;
import dmd.location;
import dmd.mtype;
import dmd.tokens;
import dmd.visitor;

/***********************************************************
Expand Down Expand Up @@ -71,161 +65,3 @@ extern (C++) final class AliasThis : Dsymbol
return this.isDeprecated_;
}
}

/*************************************
* Find the `alias this` symbol of e's type.
* Params:
* sc = context
* e = expression forming the `this`
* gag = do not print errors, return `null` instead
* findOnly = don't do further processing like resolving properties,
* i.e. just return plain dotExp() result.
* Returns:
* Expression that is `e.aliasthis`
*/
Expression resolveAliasThis(Scope* sc, Expression e, bool gag = false, bool findOnly = false)
{
import dmd.typesem : dotExp;
for (AggregateDeclaration ad = isAggregate(e.type); ad;)
{
if (ad.aliasthis)
{
Loc loc = e.loc;
Type tthis = (e.op == EXP.type ? e.type : null);
const flags = cast(DotExpFlag) (DotExpFlag.noAliasThis | (gag * DotExpFlag.gag));
uint olderrors = gag ? global.startGagging() : 0;
e = dotExp(ad.type, sc, e, ad.aliasthis.ident, flags);
if (!e || findOnly)
return gag && global.endGagging(olderrors) ? null : e;

if (tthis && ad.aliasthis.sym.needThis())
{
if (auto ve = e.isVarExp())
{
if (auto fd = ve.var.isFuncDeclaration())
{
// https://issues.dlang.org/show_bug.cgi?id=13009
// Support better match for the overloaded alias this.
bool hasOverloads;
if (auto f = fd.overloadModMatch(loc, tthis, hasOverloads))
{
if (!hasOverloads)
fd = f; // use exact match
e = new VarExp(loc, fd, hasOverloads);
e.type = f.type;
e = new CallExp(loc, e);
goto L1;
}
}
}
/* non-@property function is not called inside typeof(),
* so resolve it ahead.
*/
{
int save = sc.intypeof;
sc.intypeof = 1; // bypass "need this" error check
e = resolveProperties(sc, e);
sc.intypeof = save;
}
L1:
e = new TypeExp(loc, new TypeTypeof(loc, e));
e = e.expressionSemantic(sc);
}
e = resolveProperties(sc, e);
if (!gag)
ad.aliasthis.checkDeprecatedAliasThis(loc, sc);
else if (global.endGagging(olderrors))
e = null;
}

import dmd.dclass : ClassDeclaration;
auto cd = ad.isClassDeclaration();
if ((!e || !ad.aliasthis) && cd && cd.baseClass && cd.baseClass != ClassDeclaration.object)
{
ad = cd.baseClass;
continue;
}
break;
}
return e;
}

/**
* Check if an `alias this` is deprecated
*
* Usually one would use `expression.checkDeprecated(scope, aliasthis)` to
* check if `expression` uses a deprecated `aliasthis`, but this calls
* `toPrettyChars` which lead to the following message:
* "Deprecation: alias this `fullyqualified.aggregate.__anonymous` is deprecated"
*
* Params:
* at = The `AliasThis` object to check
* loc = `Loc` of the expression triggering the access to `at`
* sc = `Scope` of the expression
* (deprecations do not trigger in deprecated scopes)
*
* Returns:
* Whether the alias this was reported as deprecated.
*/
bool checkDeprecatedAliasThis(AliasThis at, const ref Loc loc, Scope* sc)
{
import dmd.errors : deprecation, Classification;
import dmd.dsymbolsem : getMessage;

if (global.params.useDeprecated != DiagnosticReporting.off
&& at.isDeprecated() && !sc.isDeprecated())
{
const(char)* message = null;
for (Dsymbol p = at; p; p = p.parent)
{
message = p.depdecl ? p.depdecl.getMessage() : null;
if (message)
break;
}
if (message)
deprecation(loc, "`alias %s this` is deprecated - %s",
at.sym.toChars(), message);
else
deprecation(loc, "`alias %s this` is deprecated",
at.sym.toChars());

if (auto ti = sc.parent ? sc.parent.isInstantiated() : null)
ti.printInstantiationTrace(Classification.deprecation);

return true;
}
return false;
}

/**************************************
* Check and set 'att' if 't' is a recursive 'alias this' type
*
* The goal is to prevent endless loops when there is a cycle in the alias this chain.
* Since there is no multiple `alias this`, the chain either ends in a leaf,
* or it loops back on itself as some point.
*
* Example: S0 -> (S1 -> S2 -> S3 -> S1)
*
* `S0` is not a recursive alias this, so this returns `false`, and a rewrite to `S1` can be tried.
* `S1` is a recursive alias this type, but since `att` is initialized to `null`,
* this still returns `false`, but `att1` is set to `S1`.
* A rewrite to `S2` and `S3` can be tried, but when we want to try a rewrite to `S1` again,
* we notice `att == t`, so we're back at the start of the loop, and this returns `true`.
*
* Params:
* att = type reference used to detect recursion. Should be initialized to `null`.
* t = type of 'alias this' rewrite to attempt
*
* Returns:
* `false` if the rewrite is safe, `true` if it would loop back around
*/
bool isRecursiveAliasThis(ref Type att, Type t)
{
//printf("+isRecursiveAliasThis(att = %s, t = %s)\n", att ? att.toChars() : "null", t.toChars());
auto tb = t.toBasetype();
if (att && tb.equivalent(att))
return true;
else if (!att && tb.checkAliasThisRec())
att = tb;
return false;
}
2 changes: 1 addition & 1 deletion gcc/d/dmd/astcodegen.d
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ struct ASTCodegen
alias isExpression = dmd.dtemplate.isExpression;
alias isTuple = dmd.dtemplate.isTuple;

alias IgnoreErrors = dmd.dsymbol.IgnoreErrors;
alias SearchOpt = dmd.dsymbol.SearchOpt;
alias PASS = dmd.dsymbol.PASS;
}
103 changes: 0 additions & 103 deletions gcc/d/dmd/attrib.d
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,6 @@ extern (C++) abstract class AttribDeclaration : Dsymbol
return sc;
}

override void importAll(Scope* sc)
{
Dsymbols* d = include(sc);
//printf("\tAttribDeclaration::importAll '%s', d = %p\n", toChars(), d);
if (d)
{
Scope* sc2 = newScope(sc);
d.foreachDsymbol( s => s.importAll(sc2) );
if (sc2 != sc)
sc2.pop();
}
}

override void addComment(const(char)* comment)
{
//printf("AttribDeclaration::addComment %s\n", comment);
Expand All @@ -156,11 +143,6 @@ extern (C++) abstract class AttribDeclaration : Dsymbol
return Dsymbol.oneMembers(d, ps, ident);
}

override void setFieldOffset(AggregateDeclaration ad, ref FieldState fieldState, bool isunion)
{
include(null).foreachDsymbol( s => s.setFieldOffset(ad, fieldState, isunion) );
}

override final bool hasPointers()
{
return include(null).foreachDsymbol( (s) { return s.hasPointers(); } ) != 0;
Expand Down Expand Up @@ -675,81 +657,6 @@ extern (C++) final class AnonDeclaration : AttribDeclaration
return new AnonDeclaration(loc, isunion, Dsymbol.arraySyntaxCopy(decl));
}

override void setFieldOffset(AggregateDeclaration ad, ref FieldState fieldState, bool isunion)
{
//printf("\tAnonDeclaration::setFieldOffset %s %p\n", isunion ? "union" : "struct", this);
if (decl)
{
/* This works by treating an AnonDeclaration as an aggregate 'member',
* so in order to place that member we need to compute the member's
* size and alignment.
*/
size_t fieldstart = ad.fields.length;

/* Hackishly hijack ad's structsize and alignsize fields
* for use in our fake anon aggregate member.
*/
uint savestructsize = ad.structsize;
uint savealignsize = ad.alignsize;
ad.structsize = 0;
ad.alignsize = 0;

FieldState fs;
decl.foreachDsymbol( (s)
{
s.setFieldOffset(ad, fs, this.isunion);
if (this.isunion)
fs.offset = 0;
});

/* https://issues.dlang.org/show_bug.cgi?id=13613
* If the fields in this.members had been already
* added in ad.fields, just update *poffset for the subsequent
* field offset calculation.
*/
if (fieldstart == ad.fields.length)
{
ad.structsize = savestructsize;
ad.alignsize = savealignsize;
fieldState.offset = ad.structsize;
return;
}

anonstructsize = ad.structsize;
anonalignsize = ad.alignsize;
ad.structsize = savestructsize;
ad.alignsize = savealignsize;

// 0 sized structs are set to 1 byte
if (anonstructsize == 0)
{
anonstructsize = 1;
anonalignsize = 1;
}

assert(_scope);
auto alignment = _scope.alignment();

/* Given the anon 'member's size and alignment,
* go ahead and place it.
*/
anonoffset = placeField(
fieldState.offset,
anonstructsize, anonalignsize, alignment,
ad.structsize, ad.alignsize,
isunion);

// Add to the anon fields the base offset of this anonymous aggregate
//printf("anon fields, anonoffset = %d\n", anonoffset);
foreach (const i; fieldstart .. ad.fields.length)
{
VarDeclaration v = ad.fields[i];
//printf("\t[%d] %s %d\n", i, v.toChars(), v.offset);
v.offset += anonoffset;
}
}
}

override const(char)* kind() const
{
return (isunion ? "anonymous union" : "anonymous struct");
Expand Down Expand Up @@ -943,11 +850,6 @@ extern (C++) final class StaticIfDeclaration : ConditionalDeclaration
}
}

override void importAll(Scope* sc)
{
// do not evaluate condition before semantic pass
}

override const(char)* kind() const
{
return "static if";
Expand Down Expand Up @@ -1057,11 +959,6 @@ extern (C++) final class StaticForeachDeclaration : AttribDeclaration
// change this to give semantics to documentation comments on static foreach declarations
}

override void importAll(Scope* sc)
{
// do not evaluate aggregate before semantic pass
}

override const(char)* kind() const
{
return "static foreach";
Expand Down
5 changes: 0 additions & 5 deletions gcc/d/dmd/attrib.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ class AttribDeclaration : public Dsymbol

virtual Dsymbols *include(Scope *sc);
virtual Scope *newScope(Scope *sc);
void importAll(Scope *sc) override;
void addComment(const utf8_t *comment) override;
const char *kind() const override;
bool oneMember(Dsymbol **ps, Identifier *ident) override;
void setFieldOffset(AggregateDeclaration *ad, FieldState& fieldState, bool isunion) override;
bool hasPointers() override final;
bool hasStaticCtorOrDtor() override final;
void checkCtorConstInit() override final;
Expand Down Expand Up @@ -132,7 +130,6 @@ class AnonDeclaration final : public AttribDeclaration
unsigned anonalignsize; // size of anonymous struct for alignment purposes

AnonDeclaration *syntaxCopy(Dsymbol *s) override;
void setFieldOffset(AggregateDeclaration *ad, FieldState& fieldState, bool isunion) override;
const char *kind() const override;
AnonDeclaration *isAnonDeclaration() override { return this; }
void accept(Visitor *v) override { v->visit(this); }
Expand Down Expand Up @@ -171,7 +168,6 @@ class StaticIfDeclaration final : public ConditionalDeclaration

StaticIfDeclaration *syntaxCopy(Dsymbol *s) override;
Dsymbols *include(Scope *sc) override;
void importAll(Scope *sc) override;
StaticIfDeclaration *isStaticIfDeclaration() override { return this; }
const char *kind() const override;
void accept(Visitor *v) override { v->visit(this); }
Expand All @@ -190,7 +186,6 @@ class StaticForeachDeclaration final : public AttribDeclaration
bool oneMember(Dsymbol **ps, Identifier *ident) override;
Dsymbols *include(Scope *sc) override;
void addComment(const utf8_t *comment) override;
void importAll(Scope *sc) override;
const char *kind() const override;
void accept(Visitor *v) override { v->visit(this); }
};
Expand Down
Loading

0 comments on commit 838e706

Please sign in to comment.