Skip to content

Commit dad00ad

Browse files
authored
Merge pull request #4622 from kinke/merge_stable
Merge upstream stable & bump bundled reggae
2 parents 908113d + 4f49de9 commit dad00ad

File tree

6 files changed

+95
-16
lines changed

6 files changed

+95
-16
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#### Big news
44
- Frontend, druntime and Phobos are at version [2.108.0+](https://dlang.org/changelog/2.108.0.html). (#4591, #4615, #4619)
5-
- 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)
5+
- 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)
66

77
#### Platform support
88
- Supports LLVM 11 - 18.

dmd/cparse.d

+42-13
Original file line numberDiff line numberDiff line change
@@ -5873,27 +5873,38 @@ final class CParser(AST) : Parser!AST
58735873

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

5876+
AST.Dsymbols newSymbols;
5877+
58765878
size_t[void*] defineTab; // hash table of #define's turned into Symbol's
5877-
// indexed by Identifier, returns index into symbols[]
5879+
// indexed by Identifier, returns index into newSymbols[]
58785880
// The memory for this is leaked
58795881

5880-
void addVar(AST.Dsymbol s)
5882+
void addSym(AST.Dsymbol s)
58815883
{
5882-
//printf("addVar() %s\n", s.toChars());
5884+
//printf("addSym() %s\n", s.toChars());
58835885
if (auto v = s.isVarDeclaration())
58845886
v.isCmacro(true); // mark it as coming from a C #define
58855887
/* If it's already defined, replace the earlier
58865888
* definition
58875889
*/
58885890
if (size_t* pd = cast(void*)s.ident in defineTab)
58895891
{
5890-
//printf("replacing %s\n", v.toChars());
5891-
(*symbols)[*pd] = s;
5892+
//printf("replacing %s\n", s.toChars());
5893+
newSymbols[*pd] = s;
58925894
return;
58935895
}
5894-
assert(symbols, "symbols is null");
5895-
defineTab[cast(void*)s.ident] = symbols.length;
5896-
symbols.push(s);
5896+
defineTab[cast(void*)s.ident] = newSymbols.length;
5897+
newSymbols.push(s);
5898+
}
5899+
5900+
void removeSym(Identifier ident)
5901+
{
5902+
//printf("removeSym() %s\n", ident.toChars());
5903+
if (size_t* pd = cast(void*)ident in defineTab)
5904+
{
5905+
//printf("removing %s\n", ident.toChars());
5906+
newSymbols[*pd] = null;
5907+
}
58975908
}
58985909

58995910
while (p < endp)
@@ -5937,7 +5948,7 @@ final class CParser(AST) : Parser!AST
59375948
*/
59385949
AST.Expression e = new AST.IntegerExp(scanloc, intvalue, t);
59395950
auto v = new AST.VarDeclaration(scanloc, t, id, new AST.ExpInitializer(scanloc, e), STC.manifest);
5940-
addVar(v);
5951+
addSym(v);
59415952
++p;
59425953
continue;
59435954
}
@@ -5960,7 +5971,7 @@ final class CParser(AST) : Parser!AST
59605971
*/
59615972
AST.Expression e = new AST.RealExp(scanloc, floatvalue, t);
59625973
auto v = new AST.VarDeclaration(scanloc, t, id, new AST.ExpInitializer(scanloc, e), STC.manifest);
5963-
addVar(v);
5974+
addSym(v);
59645975
++p;
59655976
continue;
59665977
}
@@ -5978,7 +5989,7 @@ final class CParser(AST) : Parser!AST
59785989
*/
59795990
AST.Expression e = new AST.StringExp(scanloc, str[0 .. len], len, 1, postfix);
59805991
auto v = new AST.VarDeclaration(scanloc, null, id, new AST.ExpInitializer(scanloc, e), STC.manifest);
5981-
addVar(v);
5992+
addSym(v);
59825993
++p;
59835994
continue;
59845995
}
@@ -6014,7 +6025,7 @@ final class CParser(AST) : Parser!AST
60146025
AST.TemplateParameters* tpl = new AST.TemplateParameters();
60156026
AST.Expression constraint = null;
60166027
auto tempdecl = new AST.TemplateDeclaration(exp.loc, id, tpl, constraint, decldefs, false);
6017-
addVar(tempdecl);
6028+
addSym(tempdecl);
60186029
++p;
60196030
continue;
60206031
}
@@ -6105,7 +6116,7 @@ final class CParser(AST) : Parser!AST
61056116
AST.Dsymbols* decldefs = new AST.Dsymbols();
61066117
decldefs.push(fd);
61076118
auto tempdecl = new AST.TemplateDeclaration(exp.loc, id, tpl, null, decldefs, false);
6108-
addVar(tempdecl);
6119+
addSym(tempdecl);
61096120

61106121
++p;
61116122
continue;
@@ -6116,13 +6127,31 @@ final class CParser(AST) : Parser!AST
61166127
}
61176128
}
61186129
}
6130+
else if (p[0 .. 6] == "#undef")
6131+
{
6132+
p += 6;
6133+
nextToken();
6134+
//printf("undef %s\n", token.toChars());
6135+
if (token.value == TOK.identifier)
6136+
removeSym(token.ident);
6137+
}
61196138
// scan to end of line
61206139
while (*p)
61216140
++p;
61226141
++p; // advance to start of next line
61236142
scanloc.linnum = scanloc.linnum + 1;
61246143
}
61256144

6145+
if (newSymbols.length)
6146+
{
6147+
assert(symbols, "symbols is null");
6148+
symbols.reserve(newSymbols.length);
6149+
6150+
foreach (sym; newSymbols)
6151+
if (sym) // undefined entries are null
6152+
symbols.push(sym);
6153+
}
6154+
61266155
scanloc = scanlocSave;
61276156
eSink = save;
61286157
defines = buf;

dmd/traits.d

+1-1
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ Expression semanticTraits(TraitsExp e, Scope* sc)
12451245
// @@@DEPRECATION 2.100.2
12461246
if (auto td = s.isTemplateDeclaration())
12471247
{
1248-
if (td.overnext || td.overroot)
1248+
if (td.overnext)
12491249
{
12501250
deprecation(e.loc, "`__traits(getAttributes)` may only be used for individual functions, not the overload set `%s`", td.ident.toChars());
12511251
deprecationSupplemental(e.loc, "the result of `__traits(getOverloads)` may be used to select the desired function to extract attributes from");

packaging/reggae_version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5260790492c465eedde921080952ea34bb14c524
1+
9a67d1a1f863c676f30b06ac606b34a792abebdd

tests/dmd/compilable/test24479.d

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// https://issues.dlang.org/show_bug.cgi?id=24479
2+
3+
/*
4+
TEST_OUTPUT:
5+
---
6+
1
7+
2
8+
---
9+
*/
10+
11+
struct S
12+
{
13+
@1
14+
S opBinary(string op: "-")(S rhs) const pure nothrow @nogc
15+
{
16+
return rhs;
17+
}
18+
@2
19+
S opBinary(string op: "*")(S dur) const pure nothrow @nogc
20+
{
21+
return dur;
22+
}
23+
}
24+
25+
private enum hasExternalUDA(alias A) = is(A == External) || is(typeof(A) == External);
26+
27+
void foo()
28+
{
29+
static foreach (t; __traits(getOverloads, S, "opBinary", true))
30+
static foreach(attr; __traits(getAttributes, t))
31+
pragma(msg, attr);
32+
33+
static assert(__traits(getOverloads, S, "opBinary", true).length == 2);
34+
alias A = __traits(getAttributes, __traits(getOverloads, S, "opBinary", true)[1]);
35+
}

tests/dmd/compilable/test24505.c

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// https://issues.dlang.org/show_bug.cgi?id=24505
2+
3+
// PERMUTE_ARGS:
4+
5+
struct stat { int x; };
6+
7+
void __stat(int x, int y);
8+
#define stat(x, y) __stat(x, y)
9+
10+
// reversed order:
11+
#define stat2(x, y) __stat(x, y)
12+
struct stat2 { int x; };
13+
14+
#undef stat
15+
#undef stat2

0 commit comments

Comments
 (0)