Skip to content

Commit 1d6d2da

Browse files
committed
Merge remote-tracking branch 'origin/main' into vpinst-with-type
2 parents 39d388a + 8bdcd0a commit 1d6d2da

File tree

64 files changed

+1795
-507
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1795
-507
lines changed

clang/Maintainers.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ OpenBSD driver
159159
| Brad Smith
160160
| brad\@comstyle.com (email), brad (Phabricator), brad0 (GitHub)
161161
162+
Offloading driver
163+
~~~~~~~~~~~~~~~~~
164+
| Joseph Huber
165+
| joseph.huber\@amd.com (email), jhuber6 (GitHub)
166+
162167

163168
Driver parts not covered by someone else
164169
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

clang/docs/CommandGuide/clang.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,10 @@ Language Selection and Mode Options
262262
.. option:: -ffreestanding
263263

264264
Indicate that the file should be compiled for a freestanding, not a hosted,
265-
environment. Note that it is assumed that a freestanding environment will
266-
additionally provide `memcpy`, `memmove`, `memset` and `memcmp`
267-
implementations, as these are needed for efficient codegen for many programs.
265+
environment. Note that a freestanding build still requires linking against a C
266+
Standard Library which supports the freestanding interfaces for the specified
267+
language mode and target environment. This includes functions like `memcpy`,
268+
`memmove`, and `memset`.
268269

269270
.. option:: -fno-builtin
270271

clang/docs/LanguageExtensions.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,6 +1594,22 @@ C11 ``_Thread_local``
15941594
Use ``__has_feature(c_thread_local)`` or ``__has_extension(c_thread_local)``
15951595
to determine if support for ``_Thread_local`` variables is enabled.
15961596

1597+
C2y
1598+
---
1599+
1600+
The features listed below are part of the C2y standard. As a result, all these
1601+
features are enabled with the ``-std=c2y`` or ``-std=gnu2y`` option when
1602+
compiling C code.
1603+
1604+
C2y ``_Countof``
1605+
^^^^^^^^^^^^^^^^
1606+
1607+
Use ``__has_feature(c_countof)`` (in C2y or later mode) or
1608+
``__has_extension(c_countof)`` (in C23 or earlier mode) to determine if support
1609+
for the ``_Countof`` operator is enabled. This feature is not available in C++
1610+
mode.
1611+
1612+
15971613
Modules
15981614
-------
15991615

@@ -1653,6 +1669,7 @@ Array & element qualification (N2607) C
16531669
Attributes (N2335) C23 C89
16541670
``#embed`` (N3017) C23 C89, C++
16551671
Octal literals prefixed with ``0o`` or ``0O`` C2y C89, C++
1672+
``_Countof`` (N3369, N3469) C2y C89
16561673
============================================= ================================ ============= =============
16571674

16581675
Builtin type aliases

clang/docs/ReleaseNotes.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@ C2y Feature Support
141141
paper also introduced octal and hexadecimal delimited escape sequences (e.g.,
142142
``"\x{12}\o{12}"``) which are also supported as an extension in older C
143143
language modes.
144+
- Implemented `WG14 N3369 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3369.pdf>`_
145+
which introduces the ``_Lengthof`` operator, and `WG14 N3469 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3469.htm>`_
146+
which renamed ``_Lengthof`` to ``_Countof``. This feature is implemented as
147+
a conforming extension in earlier C language modes, but not in C++ language
148+
modes (``std::extent`` and ``std::size`` already provide the same
149+
functionality but with more granularity). The feature can be tested via
150+
``__has_feature(c_countof)`` or ``__has_extension(c_countof)``.
144151

145152
C23 Feature Support
146153
^^^^^^^^^^^^^^^^^^^
@@ -363,7 +370,8 @@ Bug Fixes to C++ Support
363370
- Fixed a Clang regression in C++20 mode where unresolved dependent call expressions were created inside non-dependent contexts (#GH122892)
364371
- Clang now emits the ``-Wunused-variable`` warning when some structured bindings are unused
365372
and the ``[[maybe_unused]]`` attribute is not applied. (#GH125810)
366-
- Clang now issues an error when placement new is used to modify a const-qualified variable
373+
- Clang no longer crashes when establishing subsumption between some constraint expressions. (#GH122581)
374+
- Clang now issues an error when placement new is used to modify a const-qualified variable
367375
in a ``constexpr`` function. (#GH131432)
368376

369377
Bug Fixes to AST Handling

clang/docs/UsersManual.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,35 @@ inputs. Here is some example of ``$``-prefixed options:
10731073
Language and Target-Independent Features
10741074
========================================
10751075

1076+
Freestanding Builds
1077+
-------------------
1078+
Passing the ``-ffreestanding`` flag causes Clang to build for a freestanding
1079+
(rather than a hosted) environment. The flag has the following effects:
1080+
1081+
* the ``__STDC_HOSTED__`` predefined macro will expand to ``0``,
1082+
* builtin functions are disabled by default (``-fno-builtins``),
1083+
* unwind tables are disabled by default
1084+
(``fno-asynchronous-unwind-tables -fno-unwind-tables``), and
1085+
* does not treat the global ``main`` function as a special function.
1086+
1087+
An implementation of the following runtime library functions must always be
1088+
provided with the usual semantics, as Clang will generate calls to them:
1089+
1090+
* ``memcpy``,
1091+
* ``memmove``, and
1092+
* ``memset``.
1093+
1094+
Clang does not, by itself, provide a full "conforming freestanding
1095+
implementation". If you wish to have a conforming freestanding implementation,
1096+
you must provide a freestanding C library. While Clang provides some of the
1097+
required header files, it does not provide all of them, nor any library
1098+
implementations.
1099+
1100+
Conversely, when ``-ffreestanding`` is specified, Clang does not require you to
1101+
provide a conforming freestanding implementation library. Clang will not make
1102+
any assumptions as to the availability or semantics of standard-library
1103+
functions other than those mentioned above.
1104+
10761105
Controlling Errors and Warnings
10771106
-------------------------------
10781107

clang/include/clang/AST/Stmt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ class alignas(void *) Stmt {
531531
unsigned : NumExprBits;
532532

533533
LLVM_PREFERRED_TYPE(UnaryExprOrTypeTrait)
534-
unsigned Kind : 3;
534+
unsigned Kind : 4;
535535
LLVM_PREFERRED_TYPE(bool)
536536
unsigned IsType : 1; // true if operand is a type, false if an expression.
537537
};

clang/include/clang/AST/Type.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3812,6 +3812,19 @@ class IncompleteArrayType : public ArrayType {
38123812
/// ++x;
38133813
/// int Z[x];
38143814
/// }
3815+
///
3816+
/// FIXME: Even constant array types might be represented by a
3817+
/// VariableArrayType, as in:
3818+
///
3819+
/// void func(int n) {
3820+
/// int array[7][n];
3821+
/// }
3822+
///
3823+
/// Even though 'array' is a constant-size array of seven elements of type
3824+
/// variable-length array of size 'n', it will be represented as a
3825+
/// VariableArrayType whose 'SizeExpr' is an IntegerLiteral whose value is 7.
3826+
/// Instead, this should be a ConstantArrayType whose element is a
3827+
/// VariableArrayType, which models the type better.
38153828
class VariableArrayType : public ArrayType {
38163829
friend class ASTContext; // ASTContext creates these.
38173830

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,17 @@ def ext_c99_feature : Extension<
171171
"'%0' is a C99 extension">, InGroup<C99>;
172172
def ext_c11_feature : Extension<
173173
"'%0' is a C11 extension">, InGroup<C11>;
174+
def ext_c2y_feature : Extension<
175+
"'%0' is a C2y extension">, InGroup<C2y>;
174176
def warn_c11_compat_keyword : Warning<
175177
"'%0' is incompatible with C standards before C11">,
176178
InGroup<CPre11Compat>, DefaultIgnore;
177179
def warn_c23_compat_keyword : Warning<
178180
"'%0' is incompatible with C standards before C23">,
179181
InGroup<CPre23Compat>, DefaultIgnore;
182+
def warn_c2y_compat_keyword : Warning<
183+
"'%0' is incompatible with C standards before C2y">,
184+
InGroup<CPre2yCompat>, DefaultIgnore;
180185

181186
def err_c11_noreturn_misplaced : Error<
182187
"'_Noreturn' keyword must precede function declarator">;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7022,6 +7022,8 @@ def err_sizeof_alignof_typeof_bitfield : Error<
70227022
"bit-field">;
70237023
def err_alignof_member_of_incomplete_type : Error<
70247024
"invalid application of 'alignof' to a field of a class still being defined">;
7025+
def err_countof_arg_not_array_type : Error<
7026+
"'_Countof' requires an argument of array type; %0 invalid">;
70257027
def err_vecstep_non_scalar_vector_type : Error<
70267028
"'vec_step' requires built-in scalar or vector type, %0 invalid">;
70277029
def err_offsetof_incomplete_type : Error<

clang/include/clang/Basic/Features.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ FEATURE(c_static_assert, LangOpts.C11)
166166
FEATURE(c_thread_local, LangOpts.C11 &&PP.getTargetInfo().isTLSSupported())
167167
// C23 features
168168
FEATURE(c_fixed_enum, LangOpts.C23)
169+
// C2y features
170+
FEATURE(c_countof, LangOpts.C2y)
169171
// C++11 features
170172
FEATURE(cxx_access_control_sfinae, LangOpts.CPlusPlus11)
171173
FEATURE(cxx_alias_templates, LangOpts.CPlusPlus11)
@@ -274,6 +276,8 @@ EXTENSION(c_thread_local, PP.getTargetInfo().isTLSSupported())
274276
// C23 features supported by other languages as extensions
275277
EXTENSION(c_attributes, true)
276278
EXTENSION(c_fixed_enum, true)
279+
// C2y features supported by other languages as extensions
280+
EXTENSION(c_countof, !LangOpts.C2y && !LangOpts.CPlusPlus)
277281
// C++11 features supported by other languages as extensions.
278282
EXTENSION(cxx_atomic, LangOpts.CPlusPlus)
279283
EXTENSION(cxx_default_function_template_args, LangOpts.CPlusPlus)

clang/include/clang/Basic/TokenKinds.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,8 @@ KEYWORD(__func__ , KEYALL)
349349
KEYWORD(__objc_yes , KEYALL)
350350
KEYWORD(__objc_no , KEYALL)
351351

352+
// C2y
353+
UNARY_EXPR_OR_TYPE_TRAIT(_Countof, CountOf, KEYNOCXX)
352354

353355
// C++ 2.11p1: Keywords.
354356
KEYWORD(asm , KEYCXX|KEYGNU)

0 commit comments

Comments
 (0)