Commit graph

40528 commits

Author SHA1 Message Date
fossdd
81dd72b2a3
druntime: add support for musl RISCV64 (#21213)
Based on https://git.musl-libc.org/cgit/musl/tree/arch/riscv64/bits?h=v1.2.5
2025-04-12 18:01:30 +08:00
Dennis
09864e4c35
backend: Remove void initialization from code vars (#21206)
Co-authored-by: Dennis Korpel <dennis@sarc.nl>
2025-04-11 18:37:20 +08:00
Nicholas Wilson
5fdf5f3c68
[NFC] outline class function semantic analysis out of funcDeclarationSemantic (#21182)
This closes over several `goto`s whose target labels are now contained completely within the outlined code.
2025-04-11 16:38:16 +08:00
drpriver
493cd034a9
ImportC: va_arg fails in working C code (#21186)
Fixes https://github.com/dlang/dmd/issues/20423

Ultimate cause of this issue was that va_arg was being shadowed
by the collected template-like macros. As va_arg is not a normal
function (it takes a type as a parameter), this interfered with
the cparser's rewrite of va_arg to a call to the single argument
template version in core.stdc.stdarg.
2025-04-11 05:10:31 +08:00
drpriver
e9984553e6
Fix 20334: ImportC: enums created from string literal #defines don’t implicitly convert to const(char)* in D. (#21193)
Fixes: https://github.com/dlang/dmd/issues/20334

After preprocessing, #defines in C code that are just string literals
are converted into D enums. As these are collected for use in D code,
they should behave like D string literals and not C string literals.
2025-04-11 05:08:10 +08:00
Walter Bright
81cd0b26ef
fixes for assignaddrc() and cmpval() (#21195) 2025-04-10 15:59:53 +08:00
Walter Bright
52cb9fdc1b
re-enable RM.load check (#21196) 2025-04-10 15:59:10 +08:00
drpriver
a0bf0f368a
ImportC: allow _Alignof expression (#21181)
Resolves https://github.com/dlang/dmd/issues/20434

Allowing this gnu/clang extension actually removes lines of code as
we can unify the parsing and semantics of `_Alignof` and `sizeof`
and have the normal D machinery handle the difference later.
2025-04-10 07:20:50 +08:00
drpriver
93b0317cc3
Retry read() syscall on EINTR (#21188)
The read() syscall can get interrupted by a signal, in which case
you can just retry the read call instead of failing with an error.
This is most noticeable if you run the compiler in a debugger.
2025-04-10 07:18:49 +08:00
drpriver
74cdfed9d6
ImportC: improve error message for size_t (#21187)
Resolves: https://github.com/dlang/dmd/issues/20414

Add some hints for common missing includes.
2025-04-10 07:16:54 +08:00
drpriver
ca2f90d1fc
ImportC: can't access members in static array (#21185)
Fixes https://github.com/dlang/dmd/issues/20472

Arrays in C implicitly convert to a pointer to their first member,
so do the implicit conversion when using them in an arrow member lookup.
2025-04-09 17:58:14 +08:00
drpriver
7dd0506aaf
Fix #21150 - ImportC: alignment value expected, not _Alignof (#21180)
The gnu attribute aligned() allows specifying the alignment of an entire
struct, mostly as a syntatic convenience. This attribute allows
compile-time integer expressions, but the parser was trying to evaluate them
ahead of time by checking for an integer literal. Instead we need to
preserve the expression and defer it to a later semantic stage.
Accomplish this by emulating the behavior by specifying the alignment of
the first member of the struct.

I didn't change how __declspec(align(#)) parses as from the
documentation it seems to only allow integer literals. Some light
testing with cl.exe gives syntax errors when trying to use _Alignof() in
that position.
2025-04-09 10:59:26 +08:00
Matthew Qiu
69b2b10aef
Extracted Dsymbol.hasPointers to visitor in dsymbolsem (#21140) 2025-04-08 16:20:01 +08:00
Matthew Qiu
857d4a64c8
Moved OverDeclaration.isUnique to funcsem (#21174) 2025-04-08 15:42:52 +08:00
Walter Bright
c1eeb9b170
do not use TYucent for struct copies (#21175) 2025-04-08 15:41:31 +08:00
Nayaab Zameer
a52d7f0e36
Moved the _isZeroInit function out from dstruct.d into dsymbolsem.d (#21172) 2025-04-08 07:34:52 +08:00
Walter Bright
b2926b6b2a
detail optimize switch compares (#21163) 2025-04-07 14:09:34 +08:00
Abul Hossain Khan
a03aa271f8
Improve override suggestions to exclude final methods (#21138) 2025-04-07 14:09:25 +08:00
Walter Bright
63ed7154b7
get switch statements to work (#21159) 2025-04-06 09:17:35 -07:00
Iain Buclaw
8bce4f5a1a
dmd: Remove all public C++ functions (#21149)
These are all exposed under a dmd namespace (#16155)
2025-04-05 09:08:43 +08:00
Matthew Qiu
d48bdb8f78
Extracted AggregateDeclaration.finalizeSize into a visitor in dsymbolsem (#21139) 2025-04-05 09:08:06 +08:00
Walter Bright
b5b84fb102
add exe2.c exe3.c Import C test files (#21146) 2025-04-04 16:58:48 -07:00
Walter Bright
22ce24ea07
operands reversed in float conversions (#21145) 2025-04-04 16:11:17 -07:00
Walter Bright
14ec3e1c36
load floating point constant error (#21136) 2025-04-04 09:29:33 -07:00
Matthew Qiu
3106359a2b
Extracted ClassDeclaration.isAbstract to dsymbolsem (#21131) 2025-04-02 16:37:36 +08:00
Walter Bright
d7dce783a7
more problems with type conversions (#21135) 2025-04-02 00:30:55 -07:00
Walter Bright
0b3975f265
convert prolog_saveregs/restoreregs for AArch64 (#21134) 2025-04-01 20:19:39 -07:00
Walter Bright
0b29c8a5bd
start on prolog_saveregs() and epilog_restoreregs() (#21130) 2025-04-01 16:02:46 +08:00
Walter Bright
dd2fc8c8bb
load floating point with * operator (#21129) 2025-04-01 16:01:56 +08:00
Samrendra Pratap Singh
869266c2ef
Improve error message when cl.exe is missing on Windows (#21120) 2025-04-01 07:15:15 +08:00
Walter Bright
bd670444c7
redundate add of Voffset, disassembler correction (#21128) 2025-04-01 06:57:54 +08:00
Dennis
4d0934d37f
merge stable (#21127)
* bump VERSION to v2.110.0

* purge changelog

* bump VERSION to v2.111.0-beta.1

* Accept __rvalue attribute on ref functions; which will force the result to be treated as __rvalue. (#20946)

This is essential to implement `move`, `forward`, etc.

* memoryerror.d: Fix AnySupported version condition (#20983)

* Fix #20982 - wrong line number in iasmgcc (#20993)

* Move genCfunc to cxxfrontend (#20992)

* druntime: Fix compilation of rt.cover on Android (#21015)

* Expose SourceLoc to C++ interface (#20980)

* [stable] C++ header fixes for declaration, expression, and typinf (#21016)

Seen either from compilation errors or missing symbols at link time.

* C++ headers: Add 3 Declaration bitfield setters/getters required by LDC

* druntime: Add module declaration to rt.invariant, to prevent conflicts with user-provided invariant.d (#21017)

* Fix #21020 - Indexing a *cast* AA yields no lvalue anymore (#21029)

* Add C++23 to CppStdRevision enum (#21043)

* Improve UFCS/property error message (#21046)

* bump VERSION to v2.111.0-rc.1

* Fix #21045 - import __stdin causes compilation to pause while reading from stdin (#21047)

Moves the special handling of reading from stdin out of the semantic
routines to the DMD driver itself. All references to `__stdin.d` have
also been removed from the frontend implementation.

* Update source code and coverage links (#21111)

* Fix #21024 - Optimize x^^c expressions (#21082)

* Fix #21024 - Optimize x^^c expressions

Reason for the *magic* constraint c<8 on inlining x^^c:

https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86_64/fpu/e_powl.S;h=47f129f34d368d7c67b8e5f2462b36b0bebb7621;hb=HEAD#l136

* Fix poor assumption about expression state

* Restrict optimization to floating point expressions

* Generalize optimization to any scalar data type

* Fix segfault on x^^c where x is a single member anonymous enum

DMD segfaulted on compiling the unittests in std/algorithm/sorting.o, the
unittest that caused the segfault can be reduced to:

    enum real Two = 2.0;
    auto _ = Two^^3;

I'm not sure why copying the anonymous enum into a `const` variable causes
the compiler to segfault.

* Add tests to x^^c inlining optimization

* Fix missing type for e1 ^^ -1 to 1 / e1 rewrite

* Move rewrites from constant folding to expression semantic and restrict them to [-1, 2]

* Improve error message for the x^^2 rewrite.

Before:
    ex.d(4): Error: can implicitly convert expression `(const const(double) __powtmp2 = x + 5.0;) , __powtmp2 * ...` of type `double` to `int`
        int y = ( x + 5 ) ^^ 2;
                ^
and after:
    ex.d(4): Error: cannot implicitly convert expression `(x + 5.0) ^^ 2L` of type `double` to `int`
        int y = ( x + 5 ) ^^ 2;
                ^

* Update C++ frontend header to match change in `CommaExp`

* Address code review feedback

Co-authored-by: Dennis Korpel <dkorpel@gmail.com>

---------

Co-authored-by: Dennis Korpel <dkorpel@gmail.com>

* Revert "Fix #21024 - Optimize x^^c expressions (#21082)" (#21114)

This reverts commit fa1f860e4b.

* bump VERSION to v2.111.0

* purge changelog

* Strip trailing newline off sarif version

---------

Co-authored-by: Manu Evans <turkeyman@gmail.com>
Co-authored-by: Martin Kinkelin <kinke@users.noreply.github.com>
Co-authored-by: Iain Buclaw <ibuclaw@gdcproject.org>
Co-authored-by: Martin Kinkelin <noone@nowhere.com>
Co-authored-by: Fares A. Bakhit <faresa.bakhit@gmail.com>
2025-03-31 15:54:53 +02:00
Walter Bright
c78c240d37
improve formatting of disassembly output (#21123) 2025-03-30 21:18:18 -07:00
Walter Bright
6656cd920c
partially implement cdstreq() (#21117) 2025-03-30 20:12:13 +08:00
Iain Buclaw
5c9c91a651 pow: Ensure side effects are evaluated in e1^^0 rewrite 2025-03-29 21:39:12 +01:00
Dennis
95fdc47f5f
Fix #21024 - Optimize x^^c expressions (#21082) (#21115)
* Fix #21024 - Optimize x^^c expressions

Reason for the *magic* constraint c<8 on inlining x^^c:

https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86_64/fpu/e_powl.S;h=47f129f34d368d7c67b8e5f2462b36b0bebb7621;hb=HEAD#l136

* Fix poor assumption about expression state

* Restrict optimization to floating point expressions

* Generalize optimization to any scalar data type

* Fix segfault on x^^c where x is a single member anonymous enum

DMD segfaulted on compiling the unittests in std/algorithm/sorting.o, the
unittest that caused the segfault can be reduced to:

    enum real Two = 2.0;
    auto _ = Two^^3;

I'm not sure why copying the anonymous enum into a `const` variable causes
the compiler to segfault.

* Add tests to x^^c inlining optimization

* Fix missing type for e1 ^^ -1 to 1 / e1 rewrite

* Move rewrites from constant folding to expression semantic and restrict them to [-1, 2]

* Improve error message for the x^^2 rewrite.

Before:
    ex.d(4): Error: can implicitly convert expression `(const const(double) __powtmp2 = x + 5.0;) , __powtmp2 * ...` of type `double` to `int`
        int y = ( x + 5 ) ^^ 2;
                ^
and after:
    ex.d(4): Error: cannot implicitly convert expression `(x + 5.0) ^^ 2L` of type `double` to `int`
        int y = ( x + 5 ) ^^ 2;
                ^

* Update C++ frontend header to match change in `CommaExp`

* Address code review feedback



---------

Co-authored-by: Fares A. Bakhit <faresa.bakhit@gmail.com>
2025-03-29 13:57:10 +01:00
Dennis
c3923870ee
Improve linker error suggestions (#21109)
- Newer versions of ld already demangle D symbols, recognize those as D symbols instead of C.
- Don't suggest -i if it's already used
- Add special hint for missing std/core symbols when using betterC
- Simplify unittest to string compare the full error text instead of trying to half-parse the sentences
2025-03-29 11:48:17 +01:00
Dennis
712cc9bf36
backend: Remove some void/unsafe initialization (#21107)
* backend: Remove some void/unsafe initialization

* Remove isZeroInit checks since bootstrap compiler lacks that trait
2025-03-29 11:47:58 +01:00
Rainer Schuetze
13d0a42ad5
Fix #21105: Is-expressions should not generate unnecessary code for lowerings (#21106)
treat as if compiling with __traits(compiles)
2025-03-29 08:36:10 +08:00
Dennis
cfa763d301
Turn macro translations into template functions (#21108) 2025-03-29 06:31:49 +08:00
Walter Bright
ce15cb9c65
errors in cdpost() (#21103) 2025-03-28 14:57:02 +01:00
Abul Hossain Khan
228f8dbcea
Improve fix: #20867 ICE on final switch forward referencing its enum. (#21097)
* Mark C enums as semantic2done to prevent segfaults in final switch

* Added corresponding test case
2025-03-28 10:13:12 +01:00
Walter Bright
21cfefc9d1
in codelem(), use AArc64 register masks (#21101) 2025-03-28 03:58:53 +08:00
Walter Bright
001893d99c
size_t was wrong, sign extension omitted (#21093) 2025-03-27 16:20:38 +08:00
Walter Bright
653658faad
neglected to generate code for cdeq() (#21090) 2025-03-27 07:20:05 +08:00
Abul Hossain Khan
ce91ddca22
Optimize Loc Lookups (#21088) 2025-03-27 03:32:01 +08:00
Nick Treleaven
13b0745e33
Fix error when struct initializer isn't accepted (#21086)
* Fix error when struct initializer isn't accepted

* Rename StructDeclaration.hasRegularCtor parameter to ignoreDisabled

checkDisabled detected disabled ctors when it was false, which was
confusing!

* Update tests
2025-03-26 11:28:07 +01:00
Dennis
3142290b6f
Improve 'no property' error suggestions for pointers (#21087) 2025-03-26 15:43:36 +08:00
Samrendra Pratap Singh
c26b03fba2
Fix dlang#18262 - Fix expected error message for enum auto-increment (#21067)
* Fix dlang#18262 - Resolved special enum case and other conflicts

* Fix dlang#18262 - Resolved Special Enum case and failing test.

* Fix dlang#18262 - Resolved special enum case and other failing tests
2025-03-25 18:25:34 +08:00
Martin Kinkelin
b390c7ec13 [druntime] core.int128: Add 64-bit mul() overload and optimize via inline asm on x86_64 2025-03-25 16:12:24 +08:00