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 (dlang/dmd@69f0a91fc4) #3538

Merged
merged 1 commit into from
Aug 13, 2020
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 CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ set(LDC_VERSION "1.23.0") # May be overridden by git hash tag
set(DMDFE_MAJOR_VERSION 2)
set(DMDFE_MINOR_VERSION 0)
set(DMDFE_PATCH_VERSION 93)
set(DMDFE_FIX_LEVEL 0)
set(DMDFE_FIX_LEVEL 1)

set(DMD_VERSION ${DMDFE_MAJOR_VERSION}.${DMDFE_MINOR_VERSION}${DMDFE_PATCH_VERSION})
if(DEFINED DMDFE_FIX_LEVEL)
Expand Down
2 changes: 1 addition & 1 deletion dmd/attrib.d
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ extern (C++) final class UserAttributeDeclaration : AttribDeclaration
arrayExpressionSemantic(atts, sc);
}
auto exps = new Expressions();
if (userAttribDecl)
if (userAttribDecl && userAttribDecl !is this)
exps.push(new TupleExp(Loc.initial, userAttribDecl.getAttributes()));
if (atts && atts.dim)
exps.push(new TupleExp(Loc.initial, atts));
Expand Down
10 changes: 9 additions & 1 deletion dmd/dinterpret.d
Original file line number Diff line number Diff line change
Expand Up @@ -2131,7 +2131,15 @@ public:
return;
}

if (goal == ctfeNeedLvalue)
// Note: This is a workaround for
// https://issues.dlang.org/show_bug.cgi?id=17351
// The aforementioned bug triggers when passing manifest constant by `ref`.
// If there was not a previous reference to them, they are
// not cached and trigger a "cannot be read at compile time".
// This fix is a crude solution to get it to work. A more proper
// approach would be to resolve the forward reference, but that is
// much more involved.
if (goal == ctfeNeedLvalue && e.var.type.isMutable())
{
VarDeclaration v = e.var.isVarDeclaration();
if (v && !v.isDataseg() && !v.isCTFE() && !istate)
Expand Down
4 changes: 4 additions & 0 deletions dmd/dsymbolsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -2532,6 +2532,10 @@ version (IN_LLVM)
em.userAttribDecl = em.ed.userAttribDecl;
}

// Eval UDA in this same scope. Issues 19344, 20835, 21122
if (em.userAttribDecl)
em.userAttribDecl.setScope(sc);

// The first enum member is special
bool first = (em == (*em.ed.members)[0]);

Expand Down
3 changes: 3 additions & 0 deletions dmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -4747,6 +4747,9 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor

exp.e1 = new DotVarExp(exp.e1.loc, exp.e1, exp.f, false);
exp.e1 = exp.e1.expressionSemantic(sc);
// https://issues.dlang.org/show_bug.cgi?id=21095
if (exp.e1.op == TOK.error)
return setError();
t1 = exp.e1.type;

// BUG: this should really be done by checking the static
Expand Down
2 changes: 1 addition & 1 deletion dmd/hdrgen.d
Original file line number Diff line number Diff line change
Expand Up @@ -2281,7 +2281,7 @@ public:

// not a CommaExp introduced for temporaries, go on
// the old path
if (!ve || !ve.var.storage_class & STC.temp)
if (!ve || !(ve.var.storage_class & STC.temp))
{
visit(cast(BinExp)e);
return;
Expand Down
20 changes: 15 additions & 5 deletions dmd/parse.d
Original file line number Diff line number Diff line change
Expand Up @@ -3222,20 +3222,24 @@ final class Parser(AST) : Lexer
error("if type, there must be an initializer");
}

AST.UserAttributeDeclaration uad;
if (udas)
uad = new AST.UserAttributeDeclaration(udas, null);

AST.DeprecatedDeclaration dd;
if (deprecationMessage)
{
dd = new AST.DeprecatedDeclaration(deprecationMessage, null);
stc |= STC.deprecated_;
}

auto em = new AST.EnumMember(loc, ident, value, type, stc, uad, dd);
auto em = new AST.EnumMember(loc, ident, value, type, stc, null, dd);
e.members.push(em);

if (udas)
{
auto s = new AST.Dsymbols();
s.push(em);
auto uad = new AST.UserAttributeDeclaration(udas, s);
em.userAttribDecl = uad;
}

if (token.value == TOK.rightCurly)
{
}
Expand Down Expand Up @@ -3981,6 +3985,12 @@ final class Parser(AST) : Lexer
//printf("it's type[expression]\n");
inBrackets++;
AST.Expression e = parseAssignExp(); // [ expression ]
if (!e)
{
inBrackets--;
check(TOK.rightBracket);
continue;
}
if (token.value == TOK.slice)
{
nextToken();
Expand Down
44 changes: 26 additions & 18 deletions dmd/traits.d
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,6 @@ Expression semanticTraits(TraitsExp e, Scope* sc)
auto po = isParameter(o);
auto s = getDsymbolWithoutExpCtx(o);
UserAttributeDeclaration udad = null;
Scope* sc2 = sc;
if (po)
{
udad = po.userAttribDecl;
Expand All @@ -1198,12 +1197,6 @@ Expression semanticTraits(TraitsExp e, Scope* sc)
}
//printf("getAttributes %s, attrs = %p, scope = %p\n", s.toChars(), s.userAttribDecl, s.scope);
udad = s.userAttribDecl;

// Use the symbol scope when possible
if (s._scope)
sc2 = s._scope;
else if (auto m = s.getModule()) // needed for some top level symbols
sc2 = m._scope;
}
else
{
Expand All @@ -1222,7 +1215,7 @@ Expression semanticTraits(TraitsExp e, Scope* sc)

auto exps = udad ? udad.getAttributes() : new Expressions();
auto tup = new TupleExp(e.loc, exps);
return tup.expressionSemantic(sc2);
return tup.expressionSemantic(sc);
}
if (e.ident == Id.getFunctionAttributes)
{
Expand Down Expand Up @@ -1434,19 +1427,34 @@ Expression semanticTraits(TraitsExp e, Scope* sc)
e.error("argument to `__traits(getLinkage, %s)` is not a declaration", o.toChars());
return new ErrorExp();
}

if (d !is null)
link = d.linkage;
else final switch (agg.classKind)
else
{
case ClassKind.d:
link = LINK.d;
break;
case ClassKind.cpp:
link = LINK.cpp;
break;
case ClassKind.objc:
link = LINK.objc;
break;
// Resolves forward references
if (agg.sizeok != Sizeok.done)
{
agg.size(e.loc);
if (agg.sizeok != Sizeok.done)
{
e.error("%s `%s` is forward referenced", agg.kind(), agg.toChars());
return new ErrorExp();
}
}

final switch (agg.classKind)
{
case ClassKind.d:
link = LINK.d;
break;
case ClassKind.cpp:
link = LINK.cpp;
break;
case ClassKind.objc:
link = LINK.objc;
break;
}
}
}
auto linkage = linkageToChars(link);
Expand Down
12 changes: 8 additions & 4 deletions dmd/typesem.d
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ private Type stripDefaultArgs(Type t)

/******************************************
* We've mistakenly parsed `t` as a type.
* Redo `t` as an Expression.
* Redo `t` as an Expression only if there are no type modifiers.
* Params:
* t = mistaken type
* Returns:
Expand Down Expand Up @@ -572,6 +572,8 @@ Expression typeToExpression(Type t)
return new TypeExp(t.loc, t);
}

if (t.mod)
return null;
switch (t.ty)
{
case Tsarray: return visitSArray(cast(TypeSArray) t);
Expand Down Expand Up @@ -1912,13 +1914,13 @@ extern(C++) Type typeSemantic(Type t, const ref Loc loc, Scope* sc)
auto o = mtype.compileTypeMixin(loc, sc);
if (auto t = o.isType())
{
return t.typeSemantic(loc, sc);
return t.typeSemantic(loc, sc).addMod(mtype.mod);
}
else if (auto e = o.isExpression())
{
e = e.expressionSemantic(sc);
if (auto et = e.isTypeExp())
return et.type;
return et.type.addMod(mtype.mod);
else
{
if (!global.errors)
Expand Down Expand Up @@ -3050,12 +3052,14 @@ void resolve(Type mt, const ref Loc loc, Scope* sc, Expression* pe, Type* pt, Ds
if (auto t = o.isType())
{
resolve(t, loc, sc, pe, pt, ps, intypeid);
if (*pt)
(*pt) = (*pt).addMod(mt.mod);
}
else if (auto e = o.isExpression())
{
e = e.expressionSemantic(sc);
if (auto et = e.isTypeExp())
return returnType(et.type);
return returnType(et.type.addMod(mt.mod));
else
returnExp(e);
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/druntime
2 changes: 1 addition & 1 deletion runtime/phobos
Submodule phobos updated 0 files