Skip to content

Commit 9a8335c

Browse files
authored
Merge pull request #3089 from WalterBright/_Generic
ImportC: _Generic
2 parents a39c156 + ecf6768 commit 9a8335c

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

spec/importc.dd

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,27 @@ $(H2 $(LNAME2 limitations, Limitations))
151151
$(P The `_Atomic` type-qualifier (C11 6.7.3) is ignored.
152152
To do atomic operations, use an externally compiled function for that, or the inline assembler.)
153153

154+
$(H3 $(LNAME2 compatible_types, Compatible Types))
155+
156+
$(P $(I Compatible Types) (C11 6.7.2) are identical types in ImportC.)
157+
158+
$(H3 $(LNAME2 same_only_different, Same only Different Types))
159+
160+
$(P On some platforms, C `long` and `unsigned long` are the same size as `int` and `unsigned int`, respectively.
161+
On other platforms, C `long` and `unsigned long` are the same size as `long long` and `unsigned long long`.
162+
`long double` and `long double _Complex` can be same size as `double` and `double _Complex`.
163+
In ImportC, these types that are the same size and signed-ness are treated as the same types.
164+
)
165+
166+
$(H3 $(LNAME2 _generic, _Generic))
167+
168+
$(P $(B Generic selection) expressions (C11 6.5.1.1) differ from ImportC.
169+
The types in $(LINK2 #same_only_different, Same only Different Types) are
170+
indistinguishable in the $(I type-name) parts of $(I generic-association).
171+
Instead of giving an error for duplicate types per C11 6.5.1.1-2, ImportC
172+
will select the first compatible $(I type-name) in the $(I generic-assoc-list).
173+
)
174+
154175

155176
$(H2 $(LNAME2 extensions, Extensions))
156177

@@ -190,10 +211,10 @@ $(H2 $(LNAME2 gnu-clang-extensions, Gnu and Clang Extensions))
190211
not part of the function's type. In D, a function that never returns
191212
has the return type `noreturn`. The difference can be seen with the
192213
code:)
193-
---
214+
$(CCODE
194215
attribute((noreturn)) int foo();
195216
size_t x = sizeof(foo());
196-
---
217+
)
197218
$(P This code is accepted by `gcc`, but makes no sense for D. Hence,
198219
although it works in ImportC, it is not representable as D code,
199220
meaning one must use judgement in creating a .di file to interface

0 commit comments

Comments
 (0)