Skip to content

Commit 40716be

Browse files
authored
Merge pull request #4784 from kinke/merge_stable
Merge upstream stable
2 parents bc2e9f9 + a6e3267 commit 40716be

File tree

8 files changed

+62
-6
lines changed

8 files changed

+62
-6
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.110.0](https://dlang.org/changelog/2.110.0.html). (#4707, #4737, #4749, #4768)
4+
- Frontend, druntime and Phobos are at version [2.110.0](https://dlang.org/changelog/2.110.0.html). (#4707, #4737, #4749, #4768, #4784)
55
- LLVM for prebuilt packages bumped to v18.1.8 (incl. macOS arm64). (#4712)
66
- Android: NDK for prebuilt package bumped from r26d to r27. (#4711)
77
- ldc2.conf: %%ldcconfigpath%% placeholder added - specifies the directory where current configuration file is located. (#4717)

dmd/expressionsem.d

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14999,6 +14999,27 @@ bool checkSharedAccess(Expression e, Scope* sc, bool returnRef = false)
1499914999
{
1500015000
return false;
1500115001
}
15002+
else if (sc._module.ident == Id.atomic && sc._module.parent !is null)
15003+
{
15004+
// Allow core.internal.atomic, it is an compiler implementation for a given platform module.
15005+
// It is then exposed by other modules such as core.atomic and core.stdc.atomic.
15006+
// This is available as long as druntime is on the import path and the platform supports that operation.
15007+
15008+
// https://issues.dlang.org/show_bug.cgi?id=24846
15009+
15010+
Package parent = sc._module.parent.isPackage();
15011+
if (parent !is null)
15012+
{
15013+
// This can be easily converted over to apply to core.atomic and core.internal.atomic
15014+
if (parent.ident == Id.internal)
15015+
{
15016+
parent = parent.parent.isPackage();
15017+
15018+
if (parent !is null && parent.ident == Id.core && parent.parent is null)
15019+
return false;
15020+
}
15021+
}
15022+
}
1500215023

1500315024
//printf("checkSharedAccess() `%s` returnRef: %d\n", e.toChars(), returnRef);
1500415025

dmd/frontend.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8606,6 +8606,7 @@ struct Id final
86068606
static Identifier* va_start;
86078607
static Identifier* std;
86088608
static Identifier* core;
8609+
static Identifier* internal;
86098610
static Identifier* config;
86108611
static Identifier* c_complex_float;
86118612
static Identifier* c_complex_double;

dmd/id.d

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ immutable Msgtable[] msgtable =
389389
// Builtin functions
390390
{ "std" },
391391
{ "core" },
392+
{ "internal" },
392393
{ "config" },
393394
{ "c_complex_float" },
394395
{ "c_complex_double" },

dmd/lexer.d

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,6 +1556,8 @@ class Lexer
15561556
if (ndigits != 2 && !utf_isValidDchar(v))
15571557
{
15581558
error(loc, "invalid UTF character \\U%08x", v);
1559+
if (v >= 0xD800 && v <= 0xDFFF)
1560+
errorSupplemental("The code unit is a UTF-16 surrogate, is the escape UTF-16 not a Unicode code point?");
15591561
v = '?'; // recover with valid UTF character
15601562
}
15611563
}
@@ -3172,6 +3174,11 @@ version (IN_LLVM) { /* *always* map C `long double` literals to D `real` ones */
31723174
eSink.error(loc, format, args);
31733175
}
31743176

3177+
void errorSupplemental(T...)(const(char)* format, T args)
3178+
{
3179+
eSink.errorSupplemental(token.loc, format, args);
3180+
}
3181+
31753182
void deprecation(T...)(const ref Loc loc, const(char)* format, T args)
31763183
{
31773184
eSink.deprecation(loc, format, args);
@@ -3675,6 +3682,7 @@ unittest
36753682
import core.stdc.stdarg;
36763683

36773684
string expected;
3685+
string expectedSupplemental;
36783686
bool gotError;
36793687

36803688
void error(const ref Loc loc, const(char)* format, ...)
@@ -3687,13 +3695,25 @@ unittest
36873695
va_end(ap);
36883696
assert(expected == actual);
36893697
}
3698+
3699+
void errorSupplemental(const ref Loc loc, const(char)* format, ...)
3700+
{
3701+
gotError = true;
3702+
char[128] buffer = void;
3703+
va_list ap;
3704+
va_start(ap, format);
3705+
auto actual = buffer[0 .. vsnprintf(buffer.ptr, buffer.length, format, ap)];
3706+
va_end(ap);
3707+
assert(expectedSupplemental == actual);
3708+
}
36903709
}
36913710

36923711
ErrorSinkTest errorSink = new ErrorSinkTest;
36933712

3694-
void test(string sequence, string expectedError, dchar expectedReturnValue, uint expectedScanLength, bool Ccompile = false)
3713+
void test2(string sequence, string[2] expectedError, dchar expectedReturnValue, uint expectedScanLength, bool Ccompile = false)
36953714
{
3696-
errorSink.expected = expectedError;
3715+
errorSink.expected = expectedError[0];
3716+
errorSink.expectedSupplemental = expectedError[1];
36973717
errorSink.gotError = false;
36983718
auto p = cast(const(char)*)sequence.ptr;
36993719
Lexer lexer = new Lexer(errorSink);
@@ -3706,6 +3726,11 @@ unittest
37063726
assert(expectedScanLength == actualScanLength);
37073727
}
37083728

3729+
void test(string sequence, string expectedError, dchar expectedReturnValue, uint expectedScanLength, bool Ccompile = false)
3730+
{
3731+
test2(sequence, [expectedError, null], expectedReturnValue, expectedScanLength, Ccompile);
3732+
}
3733+
37093734
test("c", `undefined escape sequence \c`, 'c', 1);
37103735
test("!", `undefined escape sequence \!`, '!', 1);
37113736
test("&quot;", `undefined escape sequence \&`, '&', 1, true);
@@ -3724,8 +3749,6 @@ unittest
37243749
test("U0001f6" , `escape hex sequence has 6 hex digits instead of 8`, 0x0001f6, 7);
37253750
test("U0001f60", `escape hex sequence has 7 hex digits instead of 8`, 0x0001f60, 8);
37263751

3727-
test("ud800" , `invalid UTF character \U0000d800`, '?', 5);
3728-
test("udfff" , `invalid UTF character \U0000dfff`, '?', 5);
37293752
test("U00110000", `invalid UTF character \U00110000`, '?', 9);
37303753

37313754
test("xg0" , `undefined escape hex sequence \xg`, 'g', 2);
@@ -3737,6 +3760,9 @@ unittest
37373760
test("&quot", `unterminated named entity &quot;`, '?', 5);
37383761

37393762
test("400", `escape octal sequence \400 is larger than \377`, 0x100, 3);
3763+
3764+
test2("uD800", [`invalid UTF character \U0000d800`, `The code unit is a UTF-16 surrogate, is the escape UTF-16 not a Unicode code point?`], '?', 5);
3765+
test2("uDFFF", [`invalid UTF character \U0000dfff`, `The code unit is a UTF-16 surrogate, is the escape UTF-16 not a Unicode code point?`], '?', 5);
37403766
}
37413767

37423768
unittest

tests/dmd/compilable/atomic_store_2_shared_classes.d renamed to tests/dmd/compilable/atomic_loadstore_shared_classes.d

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ class Foo
55
{
66
}
77

8+
shared Foo toLoad;
9+
810
void oops()
911
{
1012
auto f0 = new shared Foo;
1113
auto f1 = new shared Foo;
1214
atomicStore(f0, f1);
15+
16+
// https://issues.dlang.org/show_bug.cgi?id=24846
17+
shared(Foo) f2 = atomicLoad(toLoad);
1318
}

tests/dmd/compilable/stdcheaders.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323

2424
#ifndef __APPLE__ // /Applications/Xcode-14.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/tgmath.h(39): Error: named parameter required before `...`
2525
#include <math.h>
26+
#ifndef _MSC_VER // C:\Program Files (x86)\Windows Kits\10\include\10.0.26100.0\ucrt\corecrt_math.h(93): Error: reinterpretation through overlapped field `f` is not allowed in CTFE
2627
float x = NAN;
2728
#endif
29+
#endif
2830

2931
#ifndef _MSC_VER // setjmp.h(51): Error: missing tag `identifier` after `struct
3032
#include <setjmp.h>

0 commit comments

Comments
 (0)