2165 Commits

Author SHA1 Message Date
Ashwin Kishin Banwari
1830b87090
[NFC] [C++] [Modules] Mark P2115 as implemented and add test (#147489)
This is already implemented. Proposal:
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2115r0.html
2025-07-08 18:36:53 +08:00
Ashwin Kishin Banwari
48ff068c52
[NFC] [C++] [Modules] Mark P2788 as implemented and add test (#147138)
This is already implemented.
2025-07-08 10:01:08 +08:00
Ashwin Kishin Banwari
e427bd55a8
[NFC] [C++] [Modules] Mark P2615 as implemented and add test (#147135)
This is already implemented. See godbolt:
https://godbolt.org/z/1ra4Ka8od
2025-07-08 10:00:55 +08:00
Ashwin Kishin Banwari
84be78524d
[NFC] [C++] [Modules] Mark P1811 as implemented and add test (#146993)
This is already implemented. See godbolt:
https://godbolt.org/z/7x3arqj3G
2025-07-08 09:54:33 +08:00
Ashwin Kishin Banwari
ca0b56639c
[NFC] [C++] [Modules] Mark P1979 as implemented and add test (#146841)
Proposal
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1979r0.html
appears to already be implemented as of Clang17. See:
https://godbolt.org/z/h59Mvzq6P
2025-07-03 19:03:39 +08:00
Ashwin Banwari
2599a9aeb5
[clang] [modules] Implement P3618R0: Allow attaching main to the global module (#146461)
Remove the prior warning for attaching extern "C++" to main.
2025-07-02 09:52:10 +08:00
Corentin Jabot
c69f97cb95 [Clang] Add WG21 papers from the Sofia meeting to the status page 2025-06-21 11:17:19 +03:00
Corentin Jabot
c8009797d3
[Clang] Implement CWG2496 (#142975)
https://cplusplus.github.io/CWG/issues/2496.html

We failed to diagnose the following in C++23 mode

```
struct S {
    virtual void f(); // expected-note {{previous declaration is here}}
};

struct T : S {
    virtual void f() &;
};
```
2025-06-09 21:16:57 +02:00
Guillot Tony
b896d262eb
[C23][N3006] Documented behavior of underspecified object declarations (#140911)
This PR is documenting the behavior of Clang towards underspecified
object declarations in C23 as advised by @AaronBallman.
2025-06-09 11:02:20 -04:00
Imad Aldij
bc931318a2
[Clang] Implement CWG2517 Useless restriction on use of parameter in constraint-expression (#132919)
Remove `[expr.prim.req.nested]` check which restrict that local
parameters in constraint-expressions can only appear as unevaluated
operands. This change makes the treatment of examples like `requires`
expressions and other constant expression contexts uniform, consistent
with the adoption of P2280.

References: https://cplusplus.github.io/CWG/issues/2517.html
Fixes  #132825

---------

Co-authored-by: cor3ntin <corentinjabot@gmail.com>
2025-06-07 11:31:04 +02:00
Younan Zhang
e04e140adb
[Clang] Reapply CWG2369 "Ordering between constraints and substitution" (#122423)
The previous approach broke code generation for the MS ABI due to an
unintended code path during constraint substitution. This time we
address the issue by inspecting the evaluation contexts and thereby
avoiding that code path.

This reapplies 96eced624 (#102857).
2025-06-02 17:10:07 +08:00
Aaron Ballman
7548cec16f
[www][docs] Remove last mentions of IRC (#139076)
It's the end of an era. The IRC channel was previously where the
community gathered to discuss technical topics but is now a ghost town
where the primary activity is moderators (me) kickbanning the same
individual dozens of times a day for CoC violations and the secondary
activity is telling the occasional person to come to Discord for help.
The number of people engaging on IRC for the community's intended
purposes seems to be roughly one person a month.

So this removes all remaining mentions of IRC from our documentation so
that it no longer appears to be an "official" channel for communicating
with the community. It also removes IRC handles from the various
maintainers lists, since those would stand out as confusing
anachronisms.

The IRC channel topic already recommends people come to the Discord
server. There is no way to "shut down" an IRC channel such that it no
longer exists, so the channel will continue to exist on OFTC, but will
be unmoderated.

(This was previously discussed in https://discourse.llvm.org/c/llvm/5
but some mentions persisted.)
2025-05-08 09:40:33 -04:00
cor3ntin
300d4026f7
[Clang] Implement the core language parts of P2786 - Trivial relocation (#127636)
This adds

- The parsing of `trivially_relocatable_if_eligible`,
`replaceable_if_eligible` keywords
- `__builtin_trivially_relocate`, implemented in terms of memmove. In
the future this should
- Add the appropriate start/end lifetime markers that llvm does not have
(`start_lifetime_as`)
     - Add support for ptrauth when that's upstreamed

- the `__builtin_is_cpp_trivially_relocatable` and
`__builtin_is_replaceable` traits


Fixes #127609
2025-05-06 14:13:32 +02:00
cor3ntin
1101b76732
[Clang] Implement CWG3005 Function parameters should never be name-independent (#138245)
We already attempted to implement this (it was the intent of the paper),
in that parameters were never considered name-independent. However, we
failed to check that any previously found parameter declaration was also
name-independent.

Note that, as worded, the current resolution is insufficient (I wrote to
CWG with better wording), but there is some consensus on the design
outcome.

Fixes #136373
2025-05-02 20:56:28 +02:00
Aaron Ballman
a4ceac7e3e
[C23] Implement WG14 N3037 (#132939)
This changes the type compatibility rules so that it is permitted to
redefine tag types within the same TU so long as they are equivalent
definitions.

It is intentionally not being exposed as an extension in older C
language modes. GCC does not do so and the feature doesn't seem
compelling enough to warrant it.
2025-05-02 09:19:21 -04:00
Vlad Serebrennikov
1444951432 [clang] Update cxx_dr_status.html 2025-04-26 07:02:02 +03:00
offsetof
9604bdf118
[clang] Allow parentheses around CTAD declarators (#132829)
Fixes #39811
2025-04-11 08:47:07 +02:00
Aaron Ballman
5c8ba28c75
[C11] Implement WG14 N1285 (temporary lifetimes) (#133472)
This feature largely models the same behavior as in C++11. It is
technically a breaking change between C99 and C11, so the paper is not
being backported to older language modes.

One difference between C++ and C is that things which are rvalues in C
are often lvalues in C++ (such as the result of a ternary operator or a
comma operator).

Fixes #96486
2025-04-10 08:12:14 -04:00
Vlad Serebrennikov
70a20757e8 [clang] Update C++ DR status page 2025-04-05 10:45:51 +03:00
Aaron Ballman
66b540d861
[C11] Claim conformance to WG14 N1518 (#133749)
This paper introduced ranges of valid start and continuation characters
for identifiers. C23 made further changes to these sets.
2025-04-01 11:45:56 -04:00
Aaron Ballman
00c43ae235
[C2y] Implement WG14 N3369 and N3469 (_Countof) (#133125)
C2y adds the `_Countof` operator which returns the number of elements in
an array. As with `sizeof`, `_Countof` either accepts a parenthesized
type name or an expression. Its operand must be (of) an array type. When
passed a constant-size array operand, the operator is a constant
expression which is valid for use as an integer constant expression.

This is being exposed as an extension in earlier C language modes, but
not in C++. C++ already has `std::extent` and `std::size` to cover these
needs, so the operator doesn't seem to get the user enough benefit to
warrant carrying this as an extension.

Fixes #102836
2025-03-27 13:23:16 -04:00
Aaron Ballman
85c54a519f
[Docs] Document freestanding requirements (#132232)
This adds some initial documentation about freestanding requirements for
Clang. The most critical part of the documentation is spelling out that
a conforming freestanding C Standard Library is required; Clang will not
be providing the headers for <string.h> in C23 which expose a number of
symbols in freestanding mode.

The docs also make it clear that in addition to a conforming
freestanding C standard library, the library must provide some
additional symbols which LLVM requires.

These docs are not comprehensive, this is just getting the bare bones in
place so that they can be expanded later.

This also updates the C status page to make it clear that we don't have
anything to do for WG14 N2524 which adds string interfaces to
freestanding mode.
2025-03-27 13:17:05 -04:00
Vlad Serebrennikov
5159911a7c [clang][NFC] Update C++ DR status page 2025-03-25 19:21:09 +04:00
Aaron Ballman
c65fa9163e
[C23] Fix compound literals within function prototype (#132097)
WG14 N2819 clarified that a compound literal within a function prototype
has a lifetime similar to that of a local variable within the function,
not a file scope variable.
2025-03-20 08:03:52 -04:00
Vlad Serebrennikov
f157365a0b [clang][NFC] Bump latest release number for C++ DR status page 2025-03-20 01:58:55 +03:00
Vlad Serebrennikov
bdca412681
[clang] Auto-detect which newline style to use for cxx_dr_status.html (#132045)
Aaron reported that `make_cxx_dr_status` replaces all newlines in
`cxx_dr_status.html`, which makes for a huge diff. On Windows, we can't
be compatible with all `autocrlf` modes at once, so this patch adds
autodetection of newline style using the existing file, if one is
present (which should be the case for all reasonable use cases).
2025-03-20 00:11:38 +04:00
Aaron Ballman
5497709756 Update C++ DR status page 2025-03-19 11:01:51 -04:00
Vlad Serebrennikov
a21dd255ad
[clang] Enforce UTF-8 in make_cxx_dr_status (#131816)
Otherwise Windows users have troubles with lexer tests that use emojis.
2025-03-19 01:46:48 +04:00
Vlad Serebrennikov
2203caf860
[clang] Update C++ DR status page (#131812)
CWG472 is one of the CWG issues that were assigned to Mike Miller with
`drafting` status, but recently got back to `open`, because Mike is no
longer active in CWG. Nothing to be done here, except for changing the
status.

CWG1432 was recently reopened after a CWG reflector discussion. I
changed the status to claim that we test for the previous resolution.
2025-03-19 01:44:42 +04:00
Aaron Ballman
9cf46fb230
[C2y] Add octal prefixes, deprecate unprefixed octals (#131626)
WG14 N3353 added support for 0o and 0O as octal literal prefixes. It
also deprecates use of octal literals without a prefix, except for the
literal 0.

This feature is being exposed as an extension in older C language modes
as well as in all C++ language modes.
2025-03-18 07:28:59 -04:00
Aaron Ballman
cbbcc3d13b
[C2y] Claim conformance to WG14 N3460 (#131196)
This moves some Annex G requirements for complex numbers into the main
body of the standard.
2025-03-14 12:37:07 -04:00
Aaron Ballman
5af5fb0555 [C2y] Claim conformance to WG14 N3482
This paper makes it a constraint violation (instead of UB) to call
va_start from a function with a fixed (non-variadic) parameter list.
This is something Clang has always diagnosed as an error.
2025-03-13 13:59:17 -04:00
Aaron Ballman
ab53e1c8e5
[C2y] Claim conformance to WG14 N3363 (#130980)
This paper clarifies two things:
  * a call to va_start must be within the body of a variadic function,
  * the va_list arguments must be lvalues

Clang has correctly diagnosed the first point since Clang 5.0. Clang
generally diagnoses the second point, except for va_copy. However, the
second point is not a constraint violation, so a diagnostic is not
strictly required. That said, it would be good for us to properly
diagnose va_copy.
2025-03-12 14:38:54 -04:00
Aaron Ballman
1d89d7d5d7
[Docs] Explain how to propose an extension in Clang (#130803)
We have a list of criteria for proposing an extension in Clang, but we
do not have any documentation about how to propose an extension. This
adds some basic documentation about how we run RFCs in Clang, as well as
adds a list of Clang Area Team members in support of the process.

It could be argued that this should be documented for the entire LLVM
Project, however, other parts of the project have different rules for
proposing extensions. (Extending libc++ is a different proposition than
extending LLVM, than extending MLIR, than extending Clang, etc.) We may
want to introduce high-level documentation for the LLVM Project, but
that is a bigger project and we already have the documentation in Clang
about criteria for extensions. So it seems reasonable to add some
lightweight documentation specific to Clang until we determine what to
do at the whole project level.
2025-03-12 08:02:44 -04:00
Aaron Ballman
456fa47bab [C2y] Claim conformance to WG14 N3505
This paper clarified that conditional inclusion in the preprocessor
requires the integer constant expression to be comprised only of
integer and character literals, punctuators, or implementation-defined
tokens.

This is something Clang has always required.
2025-03-11 15:04:11 -04:00
Aaron Ballman
14176d1084 [C2y] Remove WG14 N3459 from the C status page
Only changes 1 and 2 were adopted in Graz and those are both editorial
changes which don't impact the behavior of compilers, so there's no
need to track this paper.
2025-03-11 14:49:51 -04:00
Younan Zhang
f4218753ad
[Clang] Implement P0963R3 "Structured binding declaration as a condition" (#130228)
This implements the R2 semantics of P0963.

The R1 semantics, as outlined in the paper, were introduced in Clang 6.
In addition to that, the paper proposes swapping the evaluation order of
condition expressions and the initialization of binding declarations
(i.e. std::tuple-like decompositions).
2025-03-11 15:41:56 +08:00
Aaron Ballman
51850db4bf [C2y] Claim conformance to WG14 N3451
This paper allows initialization of anonymous structures and unions via
braced initializers, which is something Clang has supported since
forever.
2025-03-10 15:25:59 -04:00
Eli Black
3c71f716a9
[docs] Remove Visual Studio 2017 references and bump VS 2019 to VS 2022 (#70759)
The docs say that Visual Studio 2019 16.7 or later is required to build
clang but reference VS 2017.

* Remove references to VS 2017
* Update instructions to use VS 2022, since that's the current version
available for download from MS' website
* The path to VS 2022 executables is `Program Files` instead of `Program
Files (x86)`, as VS 2022 is 64-bit
2025-03-10 18:56:08 +00:00
Aaron Ballman
8c130b11cb Update the C status page for N3409
This was implemented in b19ed9c0435c5f7c89cba40285df3a1395a782fd but I
forgot to update the website at the same time.
2025-03-07 15:22:28 -05:00
Aaron Ballman
0ea02e7721 [C2y] Claim nonconformance to WG14 N3410
This paper made it a constraint violation for the same identifier
within a TU to have both internal and external linkage. It was
previously UB.

Clang does not correctly diagnose the constraint in some cases,
documented in the added test case.
2025-03-07 15:15:53 -05:00
Aaron Ballman
d1bd1c7e82 [C2y] Claim conformance to WG14 N3496
This was a clarification for C23's N2412, primarily about the
BOOL_WIDTH macro. It should expand to the number of bits in the value
representation, not the object representation. Clang 20 implements the
correct value.
2025-03-07 09:51:33 -05:00
Aaron Ballman
40ee5a0bcc [C2y] Claim conformance to WG14 N3481
This paper made it a constraint violation to have an incomplete type
during lvalue conversion. Previously, this was undefined behavior.

Clang has always diagnosed this for non-void incomplete types. However,
Clang does allow derefencing a void pointer (with a diagnostic, so we
still meet the conformance requirements), but not for a value
computation.
2025-03-07 09:37:15 -05:00
Aaron Ballman
5b3f50ead1 [C2y] Claim nonconformance to WG14 N3418
This paper makes it a constraint violation to form a UCN via token
concatenation. Clang does not conform to it and the paper goes in the
opposite direction of where C++ went with P2621R3 which was adopted for
C++26.
2025-03-07 08:58:33 -05:00
Aaron Ballman
9fc3310798
[C2y] Implement WG14 N3411 (#130180)
This paper (https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3411.pdf)
allows a source file to end without a newline. Clang has supported this
as a conforming extension for a long time, so this suppresses the
diagnotic in C2y mode but continues to diagnose as an extension in
earlier language modes. It also continues to diagnose if the user passes
-Wnewline-eof explicitly.
2025-03-07 08:34:22 -05:00
Aaron Ballman
2c8b824ff5 [C2y] Claim conformance to WG14 N3478
This paper made it a constraint violation for a TU to end with an
unterminated multiline comment. This is something Clang has always
diagnosed as an error.
2025-03-07 08:31:56 -05:00
Yanzuo Liu
d933882ed3
[Clang] Add test for CWG2285 "Issues with structured bindings" (#126421)
The resolution of [CWG2285](https://wg21.link/cwg2285) adds the point of
declaration of a structured binding, and was implemented in
bdb84f374c
.

Drive-by changes: modify comment and diagnostic messages mentioned in
CWG2285.
2025-03-07 07:16:51 +01:00
Aaron Ballman
f3effc2400 [C2y] Claim conformance to N3347
This paper made it a constraint violation to have a tentative
definition with internal linkage which is not completed by the end of
the translation unit.

This has been diagnosed as an error since at least Clang 3.0, so no
changes are needed.
2025-03-06 16:21:40 -05:00
Aaron Ballman
9a0e652ec7 [www] Update the C++ status pages for Clang 20 2025-03-06 16:06:51 -05:00
Aaron Ballman
22eab44aae [www] Update for Clang 20 release 2025-03-06 16:04:02 -05:00