Skip to content

Commit c248fc1

Browse files
authored
[Clang] Document some of the implementation-defined keywords (llvm#84591)
1 parent 7abf440 commit c248fc1

File tree

1 file changed

+108
-11
lines changed

1 file changed

+108
-11
lines changed

clang/docs/LanguageExtensions.rst

Lines changed: 108 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,114 @@ __datasizeof
434434
``__datasizeof`` behaves like ``sizeof``, except that it returns the size of the
435435
type ignoring tail padding.
436436

437+
_BitInt, _ExtInt
438+
----------------
439+
440+
Clang supports the C23 ``_BitInt(N)`` feature as an extension in older C modes
441+
and in C++. This type was previously implemented in Clang with the same
442+
semantics, but spelled ``_ExtInt(N)``. This spelling has been deprecated in
443+
favor of the standard type.
444+
445+
Note: the ABI for ``_BitInt(N)`` is still in the process of being stabilized,
446+
so this type should not yet be used in interfaces that require ABI stability.
447+
448+
C keywords supported in all language modes
449+
------------------------------------------
450+
451+
Clang supports ``_Alignas``, ``_Alignof``, ``_Atomic``, ``_Complex``,
452+
``_Generic``, ``_Imaginary``, ``_Noreturn``, ``_Static_assert``,
453+
``_Thread_local``, and ``_Float16`` in all language modes with the C semantics.
454+
455+
__alignof, __alignof__
456+
----------------------
457+
458+
``__alignof`` and ``__alignof__`` return, in contrast to ``_Alignof`` and
459+
``alignof``, the preferred alignment of a type. This may be larger than the
460+
required alignment for improved performance.
461+
462+
__extension__
463+
-------------
464+
465+
``__extension__`` suppresses extension diagnostics in the statement it is
466+
prepended to.
467+
468+
__auto_type
469+
-----------
470+
471+
``__auto_type`` behaves the same as ``auto`` in C++11 but is available in all
472+
language modes.
473+
474+
__imag, __imag__
475+
----------------
476+
477+
``__imag`` and ``__imag__`` can be used to get the imaginary part of a complex
478+
value.
479+
480+
__real, __real__
481+
----------------
482+
483+
``__real`` and ``__real__`` can be used to get the real part of a complex value.
484+
485+
__asm, __asm__
486+
--------------
487+
488+
``__asm`` and ``__asm__`` are alternate spellings for ``asm``, but available in
489+
all language modes.
490+
491+
__complex, __complex__
492+
----------------------
493+
494+
``__complex`` and ``__complex__`` are alternate spellings for ``_Complex``.
495+
496+
__const, __const__, __volatile, __volatile__, __restrict, __restrict__
497+
----------------------------------------------------------------------
498+
499+
These are alternate spellings for their non-underscore counterparts, but are
500+
available in all langauge modes.
501+
502+
__decltype
503+
----------
504+
505+
``__decltype`` is an alternate spelling for ``decltype``, but is also available
506+
in C++ modes before C++11.
507+
508+
__inline, __inline__
509+
--------------------
510+
511+
``__inline`` and ``__inline__`` are alternate spellings for ``inline``, but are
512+
available in all language modes.
513+
514+
__nullptr
515+
---------
516+
517+
``__nullptr`` is an alternate spelling for ``nullptr``, but is also available in
518+
C++ modes prior to C++11. Note that it's currently not availbale in C despite
519+
C23 having support for ``nullptr``.
520+
521+
__signed, __signed__
522+
--------------------
523+
524+
``__signed`` and ``__signed__`` are alternate spellings for ``signed``.
525+
``__unsigned`` and ``__unsigned__`` are **not** supported.
526+
527+
__typeof, __typeof__, __typeof_unqual, __typeof_unqual__
528+
--------------------------------------------------------
529+
530+
``__typeof`` and ``__typeof__`` are alternate spellings for ``typeof``, but are
531+
available in all langauge modes. These spellings result in the operand,
532+
retaining all qualifiers.
533+
534+
``__typeof_unqual`` and ``__typeof_unqual__`` are alternate spellings for the
535+
C23 ``typeof_unqual`` type specifier, but are available in all language modes.
536+
These spellings result in the type of the operand, stripping all qualifiers.
537+
538+
__char16_t, __char32_t
539+
----------------------
540+
541+
``__char16_t`` and ``__char32_t`` are alternate spellings for ``char16_t`` and
542+
``char32_t`` respectively, but are also available in C++ modes before C++11.
543+
They are only supported in C++. ``__char8_t`` is not available.
544+
437545
..
438546
FIXME: This should list all the keyword extensions
439547
@@ -5785,17 +5893,6 @@ Examples are:
57855893
# 60 "" 2 // return to "main.c"
57865894
# 1 "/usr/ancient/header.h" 1 4 // Enter an implicit extern "C" header
57875895
5788-
Extended Integer Types
5789-
======================
5790-
5791-
Clang supports the C23 ``_BitInt(N)`` feature as an extension in older C modes
5792-
and in C++. This type was previously implemented in Clang with the same
5793-
semantics, but spelled ``_ExtInt(N)``. This spelling has been deprecated in
5794-
favor of the standard type.
5795-
5796-
Note: the ABI for ``_BitInt(N)`` is still in the process of being stabilized,
5797-
so this type should not yet be used in interfaces that require ABI stability.
5798-
57995896
Intrinsics Support within Constant Expressions
58005897
==============================================
58015898

0 commit comments

Comments
 (0)