Commit graph

40589 commits

Author SHA1 Message Date
Nick Treleaven
011c27165e
Fix wrong 'not an lvalue' error when assigning to sequence (#21260)
Fixes #21259.
2025-04-18 20:29:13 +08:00
Abul Hossain Khan
bc3c423fd7
Fix error location for binary operations to point at operator instead of first operand (#21253) 2025-04-18 07:24:30 +08:00
Walter Bright
93d2e53e94
fix offsets in prolog_saveregs/restoreregs (#21251) 2025-04-17 16:35:25 +08:00
Walter Bright
d6602a6b0f
fix #21203 Placement new does not count as initialization (#21243) 2025-04-16 15:14:46 +08:00
drpriver
1244ef260b
Fix #21241 - ImportC: wrong static function called after linking (#21242)
Fixes https://github.com/dlang/dmd/issues/21241

C Static functions were being given the same externally mangled
name as their identifier, which caused only one to be picked
when linking with linkers that supported that.

Additionally, the dmd glue code was only outputting one of these
static functions as a workaround for a different linker issue.

Solve this by giving C static functions a unique name (by using D
mangling) and adding an `isStatic()` check to the dmd glue hack.
2025-04-16 10:13:50 +08:00
drpriver
5fd0d29211
Fix #20502 - importc: macro conflicts with struct of same name (#21234)
Fixes https://github.com/dlang/dmd/issues/20502

Similar to VarDeclarations, don't let TemplateDeclarations from
C defines shadow a real symbol.
2025-04-16 07:27:33 +08:00
Matthew Qiu
e5de57e518
Moved Dsymbol.oneMembers to dsymbolsem (#21238) 2025-04-15 20:22:18 +08:00
Matthew Qiu
1fe1cac81b
Moved VarDeclaration.checkNestedReference to funcsem (#21237) 2025-04-15 19:46:48 +08:00
Matthew Qiu
c296cb1ec2
Moved _foreach and indirect dep getLocalClasses from dmodule to dsymbolsem (#21236) 2025-04-15 19:30:15 +08:00
Albert24GG
03c8f2723f
Templatize _d_arraysetcapacity hook (#21143) 2025-04-15 18:07:47 +08:00
Abhay Pratap
513293b0d8
dcast.d: Improve pointer conversion error messages (#21221) 2025-04-15 18:03:44 +08:00
drpriver
f4ca164257
Fix #20499 - [ImportC] typedef struct with name as a pointer cannot be used with struct name (#21232)
Fixes https://github.com/dlang/dmd/issues/20499
Fixes https://github.com/dlang/dmd/issues/20963

ImportC deferred declaring "tagged" types (structs/unions/enums)
until after it saw a possible typedef so that the identifier for
a typedef declaration like:

    typedef struct { int x; } Foo;

would give the struct the name Foo. In several circumstances,
this led to tagged types not being declared. Resolve this by
chasing down those circumstances.

Also, there were other circumstances where types weren't being
correctly declared which caused other issues. Lock those down.
2025-04-15 15:31:21 +08:00
Walter Bright
c30def82bd
fix ldr/str floating point registers (#21235) 2025-04-15 15:30:53 +08:00
Abul Hossain Khan
d0cf2c7117
Add Testcases For other Fixed issues (#21231) 2025-04-14 23:17:17 +02:00
drpriver
292019346b
Fix 21225: ImportC: macro interpreted as an enum conflicts with function (#21228)
Fixes https://github.com/dlang/dmd/issues/21225

Don't let C macro variable declarations shadow any symbol.
2025-04-14 16:37:38 +08:00
Abul Hossain Khan
d657667ff8
Report correct location for undefined identifiers in function return types (#21223) 2025-04-14 16:08:52 +08:00
Walter Bright
5fcca3e152
add floatPost() (#21227) 2025-04-14 14:35:36 +08:00
drpriver
8a8746f318
Fix 18127 - ImportC: redeclaration of struct in different translation unit doesn’t check compatibility (#21224)
Fixes: https://github.com/dlang/dmd/issues/18127

When merging struct definitions from different C imports, check that the
structs are actually compatible according to the C rules. If they are
not, issue an error.
2025-04-14 14:35:20 +08:00
Walter Bright
605fb8bf5b
change mscoffobj.d to more D style (#21218) 2025-04-12 22:25:38 -07:00
Walter Bright
f5ef1eb0da
upgrade obj_mangle2() to use OutBuffer (#21209) 2025-04-12 17:38:28 -07:00
Emily
b553068344
Changed author name to new one (#21217)
I have changed my name and would not like to have
anything public associated with my old name.

Signed-off-by: Emily <info@emy.sh>
2025-04-13 08:23:30 +08:00
drpriver
6c3860ef32
ImportC: Fix interaction of aligned and packed structs (#21204)
Previous iteration of this did not properly account for the interaction
of aligned and packed and would even segfault on a null access in such
a case. This version properly handles that interaction by aligning the
struct itself instead of the first member and not forcing the struct
alignment to 1 if it is packed.
2025-04-13 06:55:56 +08:00
Walter Bright
346a772985
fix #21161 placement new fails on default-init struct (#21212) 2025-04-12 20:21:01 +08:00
drpriver
d66ef6a26d
Fix #21210 - ImportC: Initializing struct containing array with = {0} fails (#21211)
Fixes https://github.com/dlang/dmd/issues/21210
2025-04-12 19:17:24 +08:00
Martin Kinkelin
ce6cef9762
Merge pull request #21202 from kinke/merge_stable
Merge stable
2025-04-12 13:04:54 +02:00
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
Martin Kinkelin
7d368925cc Merge remote-tracking branch 'origin/stable' 2025-04-12 11:55:36 +02:00
Sönke Ludwig
09ed02ce56
Fix segmentation fault on macOS 15.4 (#21176)
Strips off additional bits that are not part of the actual TLV key to avoid applications using DRuntime crashing during initialization.

Fixes #21126.
2025-04-12 11:53:18 +02:00
Martin Kinkelin
58d065f935 Merge remote-tracking branch 'origin/stable'
Conflicts:
	compiler/src/dmd/declaration.h
	compiler/src/dmd/frontend.h
	compiler/src/dmd/globals.h
	compiler/src/dmd/typesem.d
	compiler/src/tests/cxxfrontend.cc
	compiler/test/fail_compilation/fail347.d
2025-04-11 13:35:53 +02: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
Dennis
1b34fea478
Fix #21179 - Failure to convert const(T) to T after type is used in cast() (#21201) 2025-04-11 05:05:48 +08:00
Martin Kinkelin
bb25d82a3b
build.d: Fix dependencies on generated string-import files (#21192)
This is just a byproduct of taking a closer look at this code,
as part of investigating the recent CI failures on Windows, where
the VERSION and SYSCONFDIR.imp rules seem to run twice - and then
fail for the 2nd run, Windows complaining about another process using
the file. I guess that could be an Anti-malware process running right
after creating the file the first time. And both rules check the file
contents as part of their condition, so if the rule is processed twice,
we try to immediately read its contents after the write.

Each of these 2 auto-generated files is string-imported exactly once:

* `SYSCONFDIR.imp` in the driver's `dmd/dinifile.d` (and actually on
  Posix only)
* `VERSION` in the lexer's `dmd/globals.d`

I've revised the deps accordingly, which might avoid processing these
rules multiple times as a side-effect.
2025-04-11 05:03:54 +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
Dennis
0aee4697bd
Fix #21189 - wrong/missing error line when source file isn't regular (#21190) 2025-04-10 07:19:58 +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
3070fc288a
ImportC: undefined identifier _Float16 (#21184)
Fixes: https://github.com/dlang/dmd/issues/21183

The previous MR put the macro in a `#if linux` which meant it
didn't actually solve the problem of being unable to
`#include <math.h>` on macos. So put it in a better spot.

Also enable the test that includes that header for macos so that
it stays solved.
2025-04-09 14:05:05 +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
Iain Buclaw
51816cd01d fix #21153 - [REG 2.111.0] Infinite loop in isAliasThisTuple
Partially reverts the regressing change in 08901365d4. The "fixed"
refactoring should be applied to master/development branch.
2025-04-08 16:27:08 +02: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
Rainer Schuetze
ce16000c48
remove duplicate dependency on versionFile and sysconfDirFile, lexer already has it (#21164) 2025-04-08 07:12:12 +08:00