Fixes https://github.com/dlang/dmd/issues/21271
Redefine the compatibility macro in terms of C99's `_Pragma()`
instead of ignoring it. Clang and GCC will replace `_Pragma()`
with `#pragma` directives in the preprocessed output, while
cl.exe will actually convert it back to `__pragma()`.
This is still a better situation than before as ImportC partially
supports `__pragma()`.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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).