Commit graph

460 commits

Author SHA1 Message Date
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
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
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
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
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
Paul Backus
7c95446800
Don't parse lambda as UDA without parentheses (#21009)
This brings the compiler's behavior in line with the language spec.

Fixes dlang/dlang.org#4137
2025-03-17 08:31:39 +08:00
Dennis Korpel
5375db4f76 Merge branch 'stable' into merge-stable 2025-03-05 11:03:30 +01:00
Walter Bright
73158d8a78 add Placement New 2025-03-03 16:23:02 +10:00
Dennis
2c304a4377
Fix #20929 - #line directives mess up -verrors=context (#20930) 2025-02-28 23:47:26 +01:00
Walter Bright
beef42ebb4
fix #20912 lexing problem with #define // comments (#20914) 2025-02-25 17:34:19 +08:00
Dennis
1d8658d722
Fix #20889 - ImportC: Usage of typedef types decays to original type (#20904) 2025-02-20 15:01:09 +01:00
Dennis
34cf3a9503
Fix #20894 (#20895)
- pragma(msg) interprets printf format specifiers
2025-02-19 13:42:21 +08:00
Dennis
9f33f031f0
Rephrase "no identifier for declarator" parse error (#20872) 2025-02-16 08:09:43 +08:00
Steven Schveighoffer
935d72a79e Remove unnecessary NoPointersBitmapPayload template. 2025-02-08 03:52:29 +01:00
Dennis
f4558fe0fd
Move toChars overrides to hdrgen.d (#20804) 2025-01-30 23:25:37 +01:00
Dennis
bfbac11136
Don't expose internal names in errors (#20803) 2025-01-30 21:49:50 +08:00
Dennis
096c9c1528
Make delete an identifier instead of keyword (#20745) 2025-01-21 23:33:50 +01:00
Dennis
2a627016f6
Disallow initializing fields with themself (#20696) 2025-01-21 05:49:24 +08:00
Dennis
ac9e8a5a70
Fix bypassing nothrow in debug statements (#20720)
* Fix bypassing nothrow in debug statements

* Fix debug walking null statements
2025-01-17 01:50:17 +01:00
Walter Bright
10eb368c1b fix #20686 infer attributes for generated functions 2025-01-12 19:29:12 +08:00
Walter Bright
eb8418a772
build default move constructors (#20634) 2025-01-10 11:19:29 -08:00
Paul Backus
99b4a5dc76 Revert "Enable -preview=fieldwise by default"
This reverts commit 6a7bd45a8e.

PR #17495 was originally merged in an incomplete state. Since there are
non-trivial obstacles to completing it, revert the incomplete changes
instead.

See PR #20670 for more information.
2025-01-09 13:38:03 -05:00
Royal Simpson Pinto
45e4a09a3e
feat(errors): enable verrors=context globally (#20576)
Signed-off-by: royalpinto007 <royalpinto007@gmail.com>
2025-01-03 05:17:59 +08:00
Quirin F. Schroll
3f90de47c1
Fixes #20587 - Add align(default) (#20589) 2024-12-30 13:02:14 +08:00
Walter Bright
cc21914461
fix #20614 Add __traits(hasMoveConstructor, type) (#20615) 2024-12-28 22:02:47 -08:00
Royal Simpson Pinto
59883ab71e
feat(errors): implement verrors=simple to skip context printing (#20566)
Signed-off-by: royalpinto007 <royalpinto007@gmail.com>
2024-12-18 11:53:37 +08:00
Walter Bright
a99a3894be
add __rvalue(expression) builtin (#17050) 2024-12-15 12:13:28 -08:00
Paul Backus
6a7bd45a8e Enable -preview=fieldwise by default
Introduced in PR #9331, this was changed from a normal bug fix to a
-preview switch because enabling it triggered a suprious "statement is
not reachable" warning in Phobos. That warning has since been removed
(in PR #15568).
2024-12-08 21:19:17 +01:00
Nick Treleaven
a7f6b04a0c
Don't allow short constructor with non-void expression except this() and super() (#17489) 2024-12-08 17:21:42 +08:00
Dennis Korpel
869ed9c6b9 Fix bugzilla 24891 - Two scope attributes emitted as part of .di generation 2024-12-05 15:03:54 +01:00
Dennis Korpel
56eb579a45 Allow shortened method syntax for constructors 2024-12-04 12:16:44 +01:00
Dennis Korpel
bfae7828a9 Cache TypeIdExp::semantic 2024-12-03 23:10:11 +01:00
Dennis Korpel
1a44210ffb Fix bugzilla 24883 - Speculative template overload error escapes with -preview=rvaluerefparam 2024-11-29 08:36:13 +01:00
Walter Bright
347c883586
Implement Safer D (#17044) 2024-11-27 22:59:29 -08:00
Dennis Korpel
519d388498 Fix bugzilla 24845 - Compiler error when trying to assign to an AA value of an enum instance 2024-11-25 22:54:52 +01:00
Artha
0c09587bd7
Strip one space in /// comments 2024-11-25 08:17:24 +01:00
Dennis
1039b0e93d
Update compiler/test/compilable/ddoc24871.d 2024-11-22 15:17:09 +01:00
Artha
303d95f680
Fix bugzilla issue 24871 - DDoc strips indent in triple slash comments
Removes code in the lexer responsible for removing leading spaces in
triple slash doc comments.

This affects the test file for issue 14413; two more spaces appear, but
they are not significant in the HTML output.
2024-11-22 13:00:05 +01:00
Martin Kinkelin
33e87826df Merge remote-tracking branch 'origin/stable' into merge_stable 2024-11-16 23:31:02 +01:00
Martin Kinkelin
c58e2a766b compilable/stdcheaders.c: Work around unsupported NAN in new WinSDK headers
GitHub Actions upgraded the WinSDK in the latest image, and its NAN is
apparently not supported by ImportC anymore, breaking CI.
2024-11-16 22:08:33 +01:00
Martin Kinkelin
72b2fbe64a Merge remote-tracking branch 'origin/stable' into merge_stable
Conflicts:
	compiler/src/build.d
	compiler/src/dmd/dcast.d
	compiler/src/dmd/dtemplate.d
	compiler/src/dmd/expressionsem.d
2024-11-16 16:09:17 +01:00
Dennis Korpel
f6115f0335 Fix bugzilla 24855 - VRP fails to prevent overflow after division 2024-11-13 01:49:06 +01:00
royalpinto007
dc5f8db05c feat(errors): consolidate multiple sarif reports into a single report
Signed-off-by: royalpinto007 <royalpinto007@gmail.com>

fix(errors): buffer size

Signed-off-by: royalpinto007 <royalpinto007@gmail.com>

fix(errors): diagnostics array

Signed-off-by: royalpinto007 <royalpinto007@gmail.com>

fix(errors): repeated sarif blocks in errors.d and sarif.d

Signed-off-by: royalpinto007 <royalpinto007@gmail.com>

fix(errors): pre-commit checks

Signed-off-by: royalpinto007 <royalpinto007@gmail.com>

fix(errors): circleci build

Signed-off-by: royalpinto007 <royalpinto007@gmail.com>

fix(errors): Ddoc comments and docs

Signed-off-by: royalpinto007 <royalpinto007@gmail.com>

fix(errors): plugSink function by adding early return for empty diagnostics

Signed-off-by: royalpinto007 <royalpinto007@gmail.com>

fix(errors): remove unnecessary change

Signed-off-by: royalpinto007 <royalpinto007@gmail.com>

fix(errors): global array initialisation

Signed-off-by: royalpinto007 <royalpinto007@gmail.com>

fix(errors): separate formatting message

Signed-off-by: royalpinto007 <royalpinto007@gmail.com>

fix(errors): dDoc comments

Signed-off-by: royalpinto007 <royalpinto007@gmail.com>
2024-11-11 14:38:46 +08:00
Richard (Rikki) Andrew Cattermole
a7c85ec3be Fix bugzilla issue 24846 - atomicLoad does not work for class arguments with -preview=nosharedaccess 2024-11-11 05:39:57 +08:00
royalpinto007
7c8e8ec2e5 feat(errors): generate sarif report on successful execution
Signed-off-by: royalpinto007 <royalpinto007@gmail.com>

fix(errors): tests dDoc, implicit conversion

Signed-off-by: royalpinto007 <royalpinto007@gmail.com>

fix(errors): implicit conversion

Signed-off-by: royalpinto007 <royalpinto007@gmail.com>

fix(errors): brace, default parameters, invert if-else

Signed-off-by: royalpinto007 <royalpinto007@gmail.com>

fix(errors): pre commit checks

Signed-off-by: royalpinto007 <royalpinto007@gmail.com>

fix(errors): arguments

Signed-off-by: royalpinto007 <royalpinto007@gmail.com>

fix(errors): va_list

Signed-off-by: royalpinto007 <royalpinto007@gmail.com>

fix(errors): imports

Signed-off-by: royalpinto007 <royalpinto007@gmail.com>

fix(errors): imports

Signed-off-by: royalpinto007 <royalpinto007@gmail.com>

fix(errors): va_list

Signed-off-by: royalpinto007 <royalpinto007@gmail.com>

fix(errors): va_list

Signed-off-by: royalpinto007 <royalpinto007@gmail.com>

fix(errors): va_list passing

Signed-off-by: royalpinto007 <royalpinto007@gmail.com>

fix(tests): arg placement

Signed-off-by: royalpinto007 <royalpinto007@gmail.com>

fix(regex): Add custom regex-like parsing for version extraction

Signed-off-by: royalpinto007 <royalpinto007@gmail.com>

fix(regex): Add custom regex-like parsing

Signed-off-by: royalpinto007 <royalpinto007@gmail.com>

fix(regex): version with regex, remove custom regex parser

Signed-off-by: royalpinto007 <royalpinto007@gmail.com>
2024-11-06 23:36:30 +01:00
bangbangsheshotmedown
c1a753bca3
Fix bugzilla issue 24153 - Inliner breaks -betterC by requiring TypeInfo (#17049) 2024-11-03 15:35:32 +08:00
Ilya Yanok
ad9190104f dsymbolsem/InstMemberWalker: also visit generated structs' members
While updating children's `minst` only going over `members` is not
enough: structs may also have generated methods that are not in
`members`.

As a result, if a generated method instantiates a template, it gets a
poentially wrong `minst`, so can be omitted from the compilation result.

Fixes Bugzilla Issue 24830.
2024-10-24 00:40:15 +02:00
Nicholas Wilson
57c5b071af
Rebase stable6 (#16967)
* Document template instance duplication status as part of its field documentation. (#16643)

* Fix Bugzilla 24599 - Wrongly elided TypeInfo emission (#15868)

Reverting #14844, which caused such missing TypeInfos, *and* making
sure the special TypeInfo members are fully analyzed and ready for
codegen (otherwise hitting an assertion for the real-world project).

* Reorganize backend build files to match target and make more similar per line (#16672)

* Remove redundant suggestions on linker errors (#16711)

* Fix bugzilla 24337 - Segfault when printing an int[] cast from a string (#16729)

* Add BitFieldStyle.Gcc_Clang_ARM

Required for 32-bit ARM, and non-Apple 64-bit ARM targets.

The only difference to `Gcc_Clang` is that anonymous and 0-length
bit-fields do contribute to the aggregate alignment.

Caught by existing proper C interop tests in
runnable_cxx/testbitfields.d on such targets. The hardcoded bad tests
in runnable/{bitfieldsposix64.c,dbitfieldsposix64.d} however now fail
after the fix, on such targets again.

* [refactor to `TargetC.contributesToAggregateAlignment(BitFieldDeclaration)` hook]

* Fix Bugzilla Issue 24687 - [REG2.110] Cannot cast string-imports to select overload anymore

* Also make deprecationSupplemental adhere to error limit (#16779)

Co-authored-by: Dennis Korpel <dennis@sarc.nl>

* Fix bugzilla 24699 - [REG2.108] No short-circuit evaluation of mixing template bool argument

* Fix bugzilla 24731 - IFTI cannot handle integer expressions (#16822)

* Fix Bugzilla Issue 24760 - ICE on variadic after default argument

* Fix bugzilla 24790 - -vcg-ast ICE on lowered assign exp (#16914)

Co-authored-by: Dennis Korpel <dennis@sarc.nl>

* Fix bugzilla 24764 - ICE when -vcg-ast prints imported invariant (#16917)

Co-authored-by: Dennis Korpel <dennis@sarc.nl>

* Fix bugzilla 24431 - dmd -vcg-ast crashes printing failed template in… (#16916)

---------

Co-authored-by: Richard (Rikki) Andrew Cattermole <richard@cattermole.co.nz>
Co-authored-by: Martin Kinkelin <kinke@users.noreply.github.com>
Co-authored-by: Dennis <dkorpel@users.noreply.github.com>
Co-authored-by: Martin Kinkelin <mkinkelin@symmetryinvestments.com>
Co-authored-by: Martin Kinkelin <noone@nowhere.com>
Co-authored-by: RazvanN7 <razvan.nitu1305@gmail.com>
Co-authored-by: Dennis Korpel <dennis@sarc.nl>
Co-authored-by: Dennis Korpel <dkorpel@gmail.com>
2024-10-07 12:00:14 +03:00