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 & bump bundled reggae #4622

Merged
merged 4 commits into from
Apr 19, 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
Expand Up @@ -2,7 +2,7 @@

#### Big news
- Frontend, druntime and Phobos are at version [2.108.0+](https://dlang.org/changelog/2.108.0.html). (#4591, #4615, #4619)
- Support for [LLVM 18](https://releases.llvm.org/18.1.0/docs/ReleaseNotes.html). The prebuilt packages use v18.1.3 (except for Android and macOS arm64). (#4599, #4605, #4607, #4604)
- Support for [LLVM 18](https://releases.llvm.org/18.1.0/docs/ReleaseNotes.html). The prebuilt packages use v18.1.3 (except for Android and macOS arm64). (#4599, #4605, #4607, #4604, #4622)

#### Platform support
- Supports LLVM 11 - 18.
Expand Down
55 changes: 42 additions & 13 deletions dmd/cparse.d
Original file line number Diff line number Diff line change
Expand Up @@ -5873,27 +5873,38 @@ final class CParser(AST) : Parser!AST

const(char)* endp = &slice[length - 7];

AST.Dsymbols newSymbols;

size_t[void*] defineTab; // hash table of #define's turned into Symbol's
// indexed by Identifier, returns index into symbols[]
// indexed by Identifier, returns index into newSymbols[]
// The memory for this is leaked

void addVar(AST.Dsymbol s)
void addSym(AST.Dsymbol s)
{
//printf("addVar() %s\n", s.toChars());
//printf("addSym() %s\n", s.toChars());
if (auto v = s.isVarDeclaration())
v.isCmacro(true); // mark it as coming from a C #define
/* If it's already defined, replace the earlier
* definition
*/
if (size_t* pd = cast(void*)s.ident in defineTab)
{
//printf("replacing %s\n", v.toChars());
(*symbols)[*pd] = s;
//printf("replacing %s\n", s.toChars());
newSymbols[*pd] = s;
return;
}
assert(symbols, "symbols is null");
defineTab[cast(void*)s.ident] = symbols.length;
symbols.push(s);
defineTab[cast(void*)s.ident] = newSymbols.length;
newSymbols.push(s);
}

void removeSym(Identifier ident)
{
//printf("removeSym() %s\n", ident.toChars());
if (size_t* pd = cast(void*)ident in defineTab)
{
//printf("removing %s\n", ident.toChars());
newSymbols[*pd] = null;
}
}

while (p < endp)
Expand Down Expand Up @@ -5937,7 +5948,7 @@ final class CParser(AST) : Parser!AST
*/
AST.Expression e = new AST.IntegerExp(scanloc, intvalue, t);
auto v = new AST.VarDeclaration(scanloc, t, id, new AST.ExpInitializer(scanloc, e), STC.manifest);
addVar(v);
addSym(v);
++p;
continue;
}
Expand All @@ -5960,7 +5971,7 @@ final class CParser(AST) : Parser!AST
*/
AST.Expression e = new AST.RealExp(scanloc, floatvalue, t);
auto v = new AST.VarDeclaration(scanloc, t, id, new AST.ExpInitializer(scanloc, e), STC.manifest);
addVar(v);
addSym(v);
++p;
continue;
}
Expand All @@ -5978,7 +5989,7 @@ final class CParser(AST) : Parser!AST
*/
AST.Expression e = new AST.StringExp(scanloc, str[0 .. len], len, 1, postfix);
auto v = new AST.VarDeclaration(scanloc, null, id, new AST.ExpInitializer(scanloc, e), STC.manifest);
addVar(v);
addSym(v);
++p;
continue;
}
Expand Down Expand Up @@ -6014,7 +6025,7 @@ final class CParser(AST) : Parser!AST
AST.TemplateParameters* tpl = new AST.TemplateParameters();
AST.Expression constraint = null;
auto tempdecl = new AST.TemplateDeclaration(exp.loc, id, tpl, constraint, decldefs, false);
addVar(tempdecl);
addSym(tempdecl);
++p;
continue;
}
Expand Down Expand Up @@ -6105,7 +6116,7 @@ final class CParser(AST) : Parser!AST
AST.Dsymbols* decldefs = new AST.Dsymbols();
decldefs.push(fd);
auto tempdecl = new AST.TemplateDeclaration(exp.loc, id, tpl, null, decldefs, false);
addVar(tempdecl);
addSym(tempdecl);

++p;
continue;
Expand All @@ -6116,13 +6127,31 @@ final class CParser(AST) : Parser!AST
}
}
}
else if (p[0 .. 6] == "#undef")
{
p += 6;
nextToken();
//printf("undef %s\n", token.toChars());
if (token.value == TOK.identifier)
removeSym(token.ident);
}
// scan to end of line
while (*p)
++p;
++p; // advance to start of next line
scanloc.linnum = scanloc.linnum + 1;
}

if (newSymbols.length)
{
assert(symbols, "symbols is null");
symbols.reserve(newSymbols.length);

foreach (sym; newSymbols)
if (sym) // undefined entries are null
symbols.push(sym);
}

scanloc = scanlocSave;
eSink = save;
defines = buf;
Expand Down
2 changes: 1 addition & 1 deletion dmd/traits.d
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,7 @@ Expression semanticTraits(TraitsExp e, Scope* sc)
// @@@DEPRECATION 2.100.2
if (auto td = s.isTemplateDeclaration())
{
if (td.overnext || td.overroot)
if (td.overnext)
{
deprecation(e.loc, "`__traits(getAttributes)` may only be used for individual functions, not the overload set `%s`", td.ident.toChars());
deprecationSupplemental(e.loc, "the result of `__traits(getOverloads)` may be used to select the desired function to extract attributes from");
Expand Down
2 changes: 1 addition & 1 deletion packaging/reggae_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5260790492c465eedde921080952ea34bb14c524
9a67d1a1f863c676f30b06ac606b34a792abebdd
35 changes: 35 additions & 0 deletions tests/dmd/compilable/test24479.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// https://issues.dlang.org/show_bug.cgi?id=24479

/*
TEST_OUTPUT:
---
1
2
---
*/

struct S
{
@1
S opBinary(string op: "-")(S rhs) const pure nothrow @nogc
{
return rhs;
}
@2
S opBinary(string op: "*")(S dur) const pure nothrow @nogc
{
return dur;
}
}

private enum hasExternalUDA(alias A) = is(A == External) || is(typeof(A) == External);

void foo()
{
static foreach (t; __traits(getOverloads, S, "opBinary", true))
static foreach(attr; __traits(getAttributes, t))
pragma(msg, attr);

static assert(__traits(getOverloads, S, "opBinary", true).length == 2);
alias A = __traits(getAttributes, __traits(getOverloads, S, "opBinary", true)[1]);
}
15 changes: 15 additions & 0 deletions tests/dmd/compilable/test24505.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// https://issues.dlang.org/show_bug.cgi?id=24505

// PERMUTE_ARGS:

struct stat { int x; };

void __stat(int x, int y);
#define stat(x, y) __stat(x, y)

// reversed order:
#define stat2(x, y) __stat(x, y)
struct stat2 { int x; };

#undef stat
#undef stat2
Loading