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 #16534

Merged
merged 8 commits into from
May 27, 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 VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.109.0-beta.1
v2.109.0-rc.1
6 changes: 3 additions & 3 deletions changelog/dmd.deprecation-limit.dd
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ void main()

$(CONSOLE
> dmd -verrors=3 app.d
app.d(7): Deprecation: function `deprecationlimit.x` is deprecated
app.d(8): Deprecation: function `deprecationlimit.x` is deprecated
app.d(9): Deprecation: function `deprecationlimit.x` is deprecated
app.d(7): Deprecation: function `app.f` is deprecated
app.d(8): Deprecation: function `app.f` is deprecated
app.d(9): Deprecation: function `app.f` is deprecated
1 deprecation warning omitted, use `-verrors=0` to show all
)
12 changes: 12 additions & 0 deletions changelog/dmd.foreach-array-index-type.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
`foreach` on a dynamic array can have an index type smaller than `size_t`

The array length is known at compile-time for the following cases:

* The array is a literal
* The array is a slice expression whose upper bound is known at
compile-time

For an array `a`, the index type can be any integer type `I` where
`a.length <= I.max`.

Other cases [are not implemented](https://issues.dlang.org/show_bug.cgi?id=24542) yet.
47 changes: 41 additions & 6 deletions compiler/src/dmd/backend/machobj.d
Original file line number Diff line number Diff line change
Expand Up @@ -2898,7 +2898,7 @@
}

/// Holds an operating system version or a SDK version.
immutable struct Version
struct Version
{
///
int major;
Expand All @@ -2910,7 +2910,7 @@
int build;

/// Returns: `true` if the version is valid
bool isValid() pure nothrow @nogc @safe
bool isValid() pure nothrow @nogc @safe inout
{
return major >= 10 && major < 100 &&
minor >= 0 && minor < 100 &&
Expand Down Expand Up @@ -2979,17 +2979,52 @@
* Returns: the converted `Version`.
*/
@trusted
Version toVersion(const char* str) @nogc
Version toVersion(const(char)* str) @nogc
{
import core.stdc.stdio : sscanf;

if (!str)
return Version();

const str_len = strlen(str);
if (str_len < 1)
return Version();

Check warning on line 2989 in compiler/src/dmd/backend/machobj.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/machobj.d#L2989

Added line #L2989 was not covered by tests

if (strspn(str, "0123456789.") != str_len)
return Version();

Check warning on line 2992 in compiler/src/dmd/backend/machobj.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/machobj.d#L2992

Added line #L2992 was not covered by tests

if (!isdigit(str[0]) || !isdigit(str[str_len - 1]))
return Version();

Version version_;
const(char)* endptr;

with (version_)
str.sscanf("%d.%d.%d", &major, &minor, &build);
{
major = cast(int)strtoul(str, &endptr, 10);
str = endptr + ((*endptr == '.') ? 1 : 0);

if (*str == '.')
return Version();

minor = cast(int)strtoul(str, &endptr, 10);
str = endptr + ((*endptr == '.') ? 1 : 0);

build = cast(int)strtoul(str, &endptr, 10);
if (*endptr != '\0')
return Version();

Check warning on line 3013 in compiler/src/dmd/backend/machobj.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/machobj.d#L3013

Added line #L3013 was not covered by tests
}

return version_;
}

unittest
{
assert(toVersion("10") == Version(10, 0, 0));
assert(toVersion("10.10") == Version(10, 10, 0));
assert(toVersion("10.10.1") == Version(10, 10, 1));
assert(toVersion("10.000010.1") == Version(10, 10, 1));
assert(toVersion("10.010.001") == Version(10, 10, 1));
assert(toVersion("000010.10.00001") == Version(10, 10, 1));
assert(toVersion(".9.1") == Version(0, 0, 0));
assert(toVersion("10..9") == Version(0, 0, 0));
assert(toVersion("10.10.") == Version(0, 0, 0));
}
4 changes: 2 additions & 2 deletions compiler/src/dmd/cli.d
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ dmd -cov -unittest myprog.d
$(LI $(I UAX31): UAX31)
$(LI $(I c99): C99)
$(LI $(I c11): C11)
$(LI $(I all): All, the least restrictive set, which comes all others (default))
$(LI $(I all): All, the least restrictive set, which comes with all others (default))
)`
),
Option("identifiers-importc=<table>",
Expand All @@ -483,7 +483,7 @@ dmd -cov -unittest myprog.d
$(LI $(I UAX31): UAX31)
$(LI $(I c99): C99)
$(LI $(I c11): C11 (default))
$(LI $(I all): All, the least restrictive set, which comes all others)
$(LI $(I all): All, the least restrictive set, which comes with all others)
)`
),
Option("ignore",
Expand Down
8 changes: 7 additions & 1 deletion druntime/src/importc.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,18 @@ typedef unsigned long long __uint64_t;
* Obsolete detritus
*/
#define __cdecl
#define __pascal

/*********************
* DMC-specific extensions, https://digitalmars.com/ctg/pointers16.html
*/
#ifdef __DMC__
#define __ss
#define __cs
#define __far
#define __near
#define __handle
#define __pascal
#endif

/****************************
* __extension__ is a GNU C extension. It suppresses warnings
Expand Down
13 changes: 8 additions & 5 deletions druntime/test/exceptions/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
include ../common.mak

DIFF:=diff
SED:=sed
GDB:=gdb

TESTS=stderr_msg unittest_assert invalid_memory_operation unknown_gc static_dtor \
future_message refcounted rt_trap_exceptions_drt catch_in_finally \
message_with_null
Expand All @@ -9,7 +13,10 @@ ifeq ($(OS)-$(BUILD),linux-debug)
LINE_TRACE_DFLAGS:=-L--export-dynamic
endif
ifeq ($(OS),linux)
TESTS+=rt_trap_exceptions_drt_gdb
# Only add this test if gdb is available.
ifneq (, $(shell which $(GDB)))
TESTS+=rt_trap_exceptions_drt_gdb
endif
endif
ifeq ($(OS)-$(BUILD),freebsd-debug)
TESTS+=line_trace line_trace_21656 long_backtrace_trunc cpp_demangle
Expand All @@ -31,10 +38,6 @@ ifeq ($(BUILD),debug)
TESTS+=assert_fail
endif

DIFF:=diff
SED:=sed
GDB:=gdb

.PHONY: all clean
all: $(addprefix $(ROOT)/,$(addsuffix .done,$(TESTS)))

Expand Down
Loading