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 stable #17069

Merged
merged 27 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6a8ce7c
Document template instance duplication status as part of its field do…
rikkimax Jul 2, 2024
7ab98b9
Fix Bugzilla 24599 - Wrongly elided TypeInfo emission (#15868)
kinke Jul 2, 2024
48a8883
Reorganize backend build files to match target and make more similar …
rikkimax Jul 8, 2024
4636872
Remove redundant suggestions on linker errors (#16711)
dkorpel Jul 16, 2024
cf618a6
Fix bugzilla 24337 - Segfault when printing an int[] cast from a stri…
dkorpel Jul 22, 2024
76a48f3
Add BitFieldStyle.Gcc_Clang_ARM
kinke Jul 21, 2024
5ca4593
[refactor to `TargetC.contributesToAggregateAlignment(BitFieldDeclara…
kinke Jul 22, 2024
29a3418
Fix Bugzilla Issue 24687 - [REG2.110] Cannot cast string-imports to s…
RazvanN7 Aug 5, 2024
e643a07
Also make deprecationSupplemental adhere to error limit (#16779)
dkorpel Aug 13, 2024
636f4d3
Fix bugzilla 24699 - [REG2.108] No short-circuit evaluation of mixing…
dkorpel Aug 13, 2024
96d630c
Fix bugzilla 24731 - IFTI cannot handle integer expressions (#16822)
dkorpel Aug 31, 2024
219b4f0
Fix Bugzilla Issue 24760 - ICE on variadic after default argument
RazvanN7 Sep 11, 2024
f420f98
Fix bugzilla 24790 - -vcg-ast ICE on lowered assign exp (#16914)
dkorpel Oct 3, 2024
e0259d9
Fix bugzilla 24764 - ICE when -vcg-ast prints imported invariant (#16…
dkorpel Oct 3, 2024
3f48f53
Fix bugzilla 24431 - dmd -vcg-ast crashes printing failed template in…
dkorpel Oct 3, 2024
e093a6f
[importc.h] #define __typeof__ typeof
thewilsonator Oct 7, 2024
b97828f
Fix bugzilla issue 24812 - Incorrect highlighting when diagnosing an …
thewilsonator Oct 14, 2024
d0eb6bb
Fix bugzilla 24832 - Segfault in hex string (#17024)
dkorpel Oct 24, 2024
735193c
fix bugzilla Issue 24819 - Optimizer changes result of float calculat…
WalterBright Oct 24, 2024
2a63416
Bugzilla 24700 - Don't search for mscoff .dp$B section over and over …
dkorpel Aug 14, 2024
b11b3f3
Fix bugzilla issue 24841 - UTF-16 surrogates when used as an escape o…
rikkimax Nov 2, 2024
a7c85ec
Fix bugzilla issue 24846 - atomicLoad does not work for class argumen…
rikkimax Nov 7, 2024
3aaf7bf
GitHub Actions: Bump macos-12 jobs to macos-13 (#17063)
kinke Nov 14, 2024
72b2fbe
Merge remote-tracking branch 'origin/stable' into merge_stable
kinke Nov 16, 2024
cbcd5b5
[mergefix]
kinke Nov 16, 2024
c58e2a7
compilable/stdcheaders.c: Work around unsupported NAN in new WinSDK h…
kinke Nov 16, 2024
33e8782
Merge remote-tracking branch 'origin/stable' into merge_stable
kinke Nov 16, 2024
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
14 changes: 6 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ jobs:
# os: macos-13
# host_dmd: dmd
# coverage: true
- job_name: macOS 12 x64, DMD (bootstrap)
os: macos-12
- job_name: macOS 13 x64, DMD (bootstrap)
os: macos-13
xcode: '14.3.1' # work around 'ld: multiple errors: symbol count from symbol table and dynamic symbol table differ' with old bootstrap compiler
# de-facto bootstrap version on OSX
# See: https://github.com/dlang/dmd/pull/13890
host_dmd: dmd-2.099.1
Expand Down Expand Up @@ -100,12 +101,9 @@ jobs:
if: runner.os != 'Windows'
run: ${{ runner.os == 'macOS' && 'ci/cirrusci.sh' || 'sudo -E ci/cirrusci.sh' }}

# NOTE: Linker ICEs with Xcode 15.0.1 (default version on macos-13)
# * https://issues.dlang.org/show_bug.cgi?id=24407
# Remove this step if the default gets changed to 15.1 in actions/runner-images.
- name: 'macOS 13: Switch to Xcode v15.1'
if: matrix.os == 'macos-13'
run: sudo xcode-select -switch /Applications/Xcode_15.1.app
- name: 'macOS: Switch Xcode version if required'
if: runner.os == 'macOS' && matrix.xcode
run: sudo xcode-select -switch /Applications/Xcode_${{ matrix.xcode }}.app

- name: 'Posix: Install host compiler'
if: runner.os != 'Windows'
Expand Down
32 changes: 18 additions & 14 deletions .github/workflows/runnable_cxx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ jobs:
# very few PRs actually benefit from this.
fail-fast: false
matrix:
os: [ macOS-12, ubuntu-20.04, windows-2019 ]
os: [ macos-13, ubuntu-20.04, windows-2019 ]

target: [
# Versions of clang earlier than 11 are not available on 20.04, but are on macOS-12
# Versions of clang earlier than 11 are not available on 20.04, but are on macOS 13
clang-13.0.0, clang-12.0.0, clang-11.0.0, clang-10.0.0, clang-9.0.0, clang-8.0.0,
# For g++, we test the oldest compiler on Ubuntu 20.04, which is GCC-9
g++-11, g++-10, g++-9,
Expand All @@ -81,13 +81,13 @@ jobs:
- { os: ubuntu-20.04, target: msvc-2015 }
- { os: ubuntu-20.04, target: msvc-2013 }
# OSX only supports clang
- { os: macOS-12, target: g++-11 }
- { os: macOS-12, target: g++-10 }
- { os: macOS-12, target: g++-9 }
- { os: macOS-12, target: msvc-2019 }
- { os: macOS-12, target: msvc-2017 }
- { os: macOS-12, target: msvc-2015 }
- { os: macOS-12, target: msvc-2013 }
- { os: macos-13, target: g++-11 }
- { os: macos-13, target: g++-10 }
- { os: macos-13, target: g++-9 }
- { os: macos-13, target: msvc-2019 }
- { os: macos-13, target: msvc-2017 }
- { os: macos-13, target: msvc-2015 }
- { os: macos-13, target: msvc-2013 }
# We don't test g++ on Windows as DMD only mangles for MSVC
- { os: windows-2019, target: g++-11 }
- { os: windows-2019, target: g++-10 }
Expand Down Expand Up @@ -126,13 +126,13 @@ jobs:
- { target: g++-9, compiler: g++, cxx-version: 9.4.0, major: 9 }
# Platform boilerplate
- { os: ubuntu-20.04, arch: x86_64-linux-gnu-ubuntu-20.04 }
- { os: macOS-12, arch: x86_64-apple-darwin }
- { os: macos-13, arch: x86_64-apple-darwin }
# Clang 9.0.0 have a different arch for OSX
- { os: macOS-12, target: clang-9.0.0, arch: x86_64-darwin-apple }
- { os: macos-13, target: clang-9.0.0, arch: x86_64-darwin-apple }
# Those targets will generate artifacts that can be used by other testers
- { storeArtifacts: false }
- { os: ubuntu-20.04, target: g++-9, storeArtifacts: true }
- { os: macOS-12, target: clang-9.0.0, storeArtifacts: true }
- { os: macos-13, target: clang-9.0.0, storeArtifacts: true }
#- { os: windows-2019, target: msvc-2019, storeArtifacts: true }

# We're using the latest available images at the time of this commit.
Expand Down Expand Up @@ -209,7 +209,7 @@ jobs:
# On OSX, the system header are installed via `xcode-select` and not distributed with clang
# Since some part of the testsuite rely on CC and CXX being only a binary (not a command),
# and config files where only introduced from 6.0.0, use a wrapper script.
if [ "${{ matrix.os }}" == "macOS-12" ]; then
if [ "${{ matrix.os }}" == "macos-13" ]; then
# Note: heredoc shouldn't be indented
cat << 'EOF' > ${TMP_CC}-wrapper
#!/bin/bash
Expand All @@ -227,11 +227,15 @@ jobs:
chmod +x ${TMP_CC}-wrapper ${TMP_CC}++-wrapper
fi

- name: 'macOS 13: Switch to Xcode v14.3.1' # to work around '-macosx_version_min has been renamed to -macos_version_min' with some clang versions
if: matrix.os == 'macos-13'
run: sudo xcode-select -switch /Applications/Xcode_14.3.1.app

- name: '[Posix] Setup environment variables'
if: matrix.compiler == 'clang' && runner.os != 'Windows'
run: |
TMP_CC='${{ github.workspace }}/clang+llvm-${{ matrix.cxx-version }}-${{ matrix.arch }}/bin/clang'
if [ "${{ matrix.os }}" == "macOS-12" ]; then
if [ "${{ matrix.os }}" == "macos-13" ]; then
echo "CC=${TMP_CC}-wrapper" >> $GITHUB_ENV
echo "CXX=${TMP_CC}++-wrapper" >> $GITHUB_ENV
echo "SDKROOT=$(xcrun --show-sdk-path)" >> $GITHUB_ENV
Expand Down
12 changes: 6 additions & 6 deletions ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ The auto tester tests DMD on various Posix platforms.
**Config**: [azure-pipelines.yml](https://github.com/dlang/dmd/blob/master/.github/workflows/runnable_cxx.yml)

**Checks**:
- C++ interop tests / Run (macOS-12, clang-13.0.0)
- C++ interop tests / Run (macOS-12, clang-12.0.0)
- C++ interop tests / Run (macOS-12, clang-11.0.0)
- C++ interop tests / Run (macOS-12, clang-10.0.0)
- C++ interop tests / Run (macOS-12, clang-9.0.0)
- C++ interop tests / Run (macOS-12, clang-8.0.0)
- C++ interop tests / Run (macos-13, clang-13.0.0)
- C++ interop tests / Run (macos-13, clang-12.0.0)
- C++ interop tests / Run (macos-13, clang-11.0.0)
- C++ interop tests / Run (macos-13, clang-10.0.0)
- C++ interop tests / Run (macos-13, clang-9.0.0)
- C++ interop tests / Run (macos-13, clang-8.0.0)
- C++ interop tests / Run (ubuntu-20.04, clang-13.0.0)
- C++ interop tests / Run (ubuntu-20.04, clang-12.0.0)
- C++ interop tests / Run (ubuntu-20.04, clang-11.0.0)
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dmd/dcast.d
Original file line number Diff line number Diff line change
Expand Up @@ -2335,7 +2335,7 @@ Expression castTo(Expression e, Scope* sc, Type t, Type att = null)
Type tb = t.toBasetype();
Type typeb = e.type.toBasetype();

if (e.hexString && !e.committed)
if (e.hexString && !e.committed && tb.nextOf().isIntegral)
{
const szx = cast(ubyte) tb.nextOf().size();
if (szx != se.sz && (e.len % szx) == 0)
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dmd/dinterpret.d
Original file line number Diff line number Diff line change
Expand Up @@ -6132,7 +6132,7 @@
{
auto se = e1.isStringExp();
// Allow casting a hex string literal to short[], int[] or long[]
if (se && se.hexString && se.postfix == StringExp.NoPostfix)
if (se && se.hexString && se.postfix == StringExp.NoPostfix && e.to.nextOf().isIntegral)

Check warning on line 6135 in compiler/src/dmd/dinterpret.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/dinterpret.d#L6135

Added line #L6135 was not covered by tests
{
const sz = cast(size_t) e.to.nextOf().size;
if ((se.len % sz) != 0)
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dmd/enumsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@

if (ed.members.length == 0)
{
.error(ed.loc, "%s `%s enum `%s` must have at least one member", ed.kind, ed.toPrettyChars, ed.toChars());
.error(ed.loc, "%s `%s` enum `%s` must have at least one member", ed.kind, ed.toPrettyChars, ed.toChars());

Check warning on line 188 in compiler/src/dmd/enumsem.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/enumsem.d#L188

Added line #L188 was not covered by tests
ed.errors = true;
ed.semanticRun = PASS.semanticdone;
return;
Expand Down
21 changes: 21 additions & 0 deletions compiler/src/dmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -15067,6 +15067,27 @@ bool checkSharedAccess(Expression e, Scope* sc, bool returnRef = false)
{
return false;
}
else if (sc._module.ident == Id.atomic && sc._module.parent !is null)
{
// Allow core.internal.atomic, it is an compiler implementation for a given platform module.
// It is then exposed by other modules such as core.atomic and core.stdc.atomic.
// This is available as long as druntime is on the import path and the platform supports that operation.

// https://issues.dlang.org/show_bug.cgi?id=24846

Package parent = sc._module.parent.isPackage();
if (parent !is null)
{
// This can be easily converted over to apply to core.atomic and core.internal.atomic
if (parent.ident == Id.internal)
{
parent = parent.parent.isPackage();

if (parent !is null && parent.ident == Id.core && parent.parent is null)
return false;
}
}
}

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

Expand Down
1 change: 1 addition & 0 deletions compiler/src/dmd/frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -8836,6 +8836,7 @@ struct Id final
static Identifier* va_start;
static Identifier* std;
static Identifier* core;
static Identifier* internal;
static Identifier* config;
static Identifier* c_complex_float;
static Identifier* c_complex_double;
Expand Down
1 change: 1 addition & 0 deletions compiler/src/dmd/id.d
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ immutable Msgtable[] msgtable =
// Builtin functions
{ "std" },
{ "core" },
{ "internal" },
{ "config" },
{ "c_complex_float" },
{ "c_complex_double" },
Expand Down
34 changes: 30 additions & 4 deletions compiler/src/dmd/lexer.d
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,8 @@ class Lexer
if (ndigits != 2 && !utf_isValidDchar(v))
{
error(loc, "invalid UTF character \\U%08x", v);
if (v >= 0xD800 && v <= 0xDFFF)
errorSupplemental("The code unit is a UTF-16 surrogate, is the escape UTF-16 not a Unicode code point?");
v = '?'; // recover with valid UTF character
}
}
Expand Down Expand Up @@ -3168,6 +3170,11 @@ class Lexer
eSink.error(loc, format, args);
}

void errorSupplemental(T...)(const(char)* format, T args)
{
eSink.errorSupplemental(token.loc, format, args);
}

void deprecation(T...)(const ref Loc loc, const(char)* format, T args)
{
eSink.deprecation(loc, format, args);
Expand Down Expand Up @@ -3671,6 +3678,7 @@ unittest
import core.stdc.stdarg;

string expected;
string expectedSupplemental;
bool gotError;

void error(const ref Loc loc, const(char)* format, ...)
Expand All @@ -3683,13 +3691,25 @@ unittest
va_end(ap);
assert(expected == actual);
}

void errorSupplemental(const ref Loc loc, const(char)* format, ...)
{
gotError = true;
char[128] buffer = void;
va_list ap;
va_start(ap, format);
auto actual = buffer[0 .. vsnprintf(buffer.ptr, buffer.length, format, ap)];
va_end(ap);
assert(expectedSupplemental == actual);
}
}

ErrorSinkTest errorSink = new ErrorSinkTest;

void test(string sequence, string expectedError, dchar expectedReturnValue, uint expectedScanLength, bool Ccompile = false)
void test2(string sequence, string[2] expectedError, dchar expectedReturnValue, uint expectedScanLength, bool Ccompile = false)
{
errorSink.expected = expectedError;
errorSink.expected = expectedError[0];
errorSink.expectedSupplemental = expectedError[1];
errorSink.gotError = false;
auto p = cast(const(char)*)sequence.ptr;
Lexer lexer = new Lexer(errorSink);
Expand All @@ -3702,6 +3722,11 @@ unittest
assert(expectedScanLength == actualScanLength);
}

void test(string sequence, string expectedError, dchar expectedReturnValue, uint expectedScanLength, bool Ccompile = false)
{
test2(sequence, [expectedError, null], expectedReturnValue, expectedScanLength, Ccompile);
}

test("c", `undefined escape sequence \c`, 'c', 1);
test("!", `undefined escape sequence \!`, '!', 1);
test("&quot;", `undefined escape sequence \&`, '&', 1, true);
Expand All @@ -3720,8 +3745,6 @@ unittest
test("U0001f6" , `escape hex sequence has 6 hex digits instead of 8`, 0x0001f6, 7);
test("U0001f60", `escape hex sequence has 7 hex digits instead of 8`, 0x0001f60, 8);

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

test("xg0" , `undefined escape hex sequence \xg`, 'g', 2);
Expand All @@ -3733,6 +3756,9 @@ unittest
test("&quot", `unterminated named entity &quot;`, '?', 5);

test("400", `escape octal sequence \400 is larger than \377`, 0x100, 3);

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);
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);
}

unittest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ class Foo
{
}

shared Foo toLoad;

void oops()
{
auto f0 = new shared Foo;
auto f1 = new shared Foo;
atomicStore(f0, f1);

// https://issues.dlang.org/show_bug.cgi?id=24846
shared(Foo) f2 = atomicLoad(toLoad);
}
2 changes: 2 additions & 0 deletions compiler/test/compilable/stdcheaders.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@

#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 `...`
#include <math.h>
#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
float x = NAN;
#endif
#endif

#ifndef _MSC_VER // setjmp.h(51): Error: missing tag `identifier` after `struct
#include <setjmp.h>
Expand Down
7 changes: 7 additions & 0 deletions compiler/test/fail_compilation/diag24812.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
TEST_OUTPUT:
---
fail_compilation/diag24812.d(7): Error: enum `diag24812.Foo` enum `Foo` must have at least one member
---
*/
enum Foo {}
10 changes: 9 additions & 1 deletion compiler/test/fail_compilation/hexstring.d
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ fail_compilation/hexstring.d(39): perhaps remove postfix `c` from hex str
fail_compilation/hexstring.d(40): Error: hex string with `dstring` type needs to be multiple of 4 bytes, not 5
fail_compilation/hexstring.d(41): Error: cannot implicitly convert expression `x"11223344"d` of type `dstring` to `immutable(float[])`
fail_compilation/hexstring.d(42): Error: cannot implicitly convert expression `x"1122"w` of type `wstring` to `immutable(ubyte[])`
fail_compilation/hexstring.d(50): Error: array cast from `string` to `S[]` is not supported at compile time
fail_compilation/hexstring.d(28): Error: cannot implicitly convert expression `x"123F"` of type `string` to `ubyte[]`
---
*/
immutable ubyte[] s0 = x"123F";
static assert(s0[0] == 0x12);
static assert(s0[1] == 0x3F);
immutable byte[] s1 = x"123F";

enum E(X) = cast(X[]) x"AABBCCDD";
static assert(E!int[0] == 0xAABBCCDD);

Expand All @@ -40,3 +40,11 @@ immutable uint[] f11 = cast(immutable uint[]) x"AABBCCDD"c;
immutable uint[] f12 = x"1122334455"d;
immutable float[] f13 = x"11223344"d;
immutable ubyte[] f14 = x"1122"w;

// https://issues.dlang.org/show_bug.cgi?id=24832
struct S
{
ushort l0, l1, l2, l3, l4, l5;
}

immutable S[] returnValues = cast(S[]) x"FFFFFFFFFFFFFFFFFFFFFFFF";
1 change: 1 addition & 0 deletions druntime/src/importc.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#define __alignof _Alignof
#define __vector_size__ vector_size
#define __typeof typeof
#define __typeof__ typeof

/********************
* Clang nullability extension used by macOS headers.
Expand Down
Loading