Commit graph

2257 commits

Author SHA1 Message Date
Corentin Jabot
2f6ec89938
[Clang] Implement P3658R1 (#212131)
As a DR in all C++ language modes.
Because we already supported the feature this is only modifying the
extensions warnings.
2026-07-28 07:46:23 +02:00
AZero13
41a5357e38
[clang][Sema] Allow abstract declarators to specify cv-qualified function types as per CWG1417 (#209836)
Abstract declarator contexts (specifically `DeclaratorContext::TypeName`) now properly bypass this restricted rule, allowing cv-qualified function types in `__typeof__` while maintaining restrictions in other contexts like `typeid`, `sizeof`, C-style casts, and `new` expressions per CWG1417.
2026-07-27 10:26:24 -07:00
Vlad Serebrennikov
a744ab39c4
[clang] Update C++ DR status page (#212210)
On top of updating the status page, this PR updates the `latest_release`
constant to 22 and fixes a small `cwg_index.html` parsing issue that
arose during the update.
2026-07-27 10:04:09 +00:00
Timm Baeder
4b66bacd1f
[clang][ExprConst] Support virtual bases in C++26 (#204289)
Add support for virtual bases in constant expressions (P3533R2) to both the current constant interpreter as well as the bytecode interpreter.
2026-07-15 15:08:31 +02:00
Hans Wennborg
04aa50715c
Revert "[Clang] Allow devirtualization involving array subscripts with constant indices when the pointee type is known [CWG1504] (#207540) (#209596)
It caused miscompiles, see discussion on the PR.

This reverts commit ee24ac00d8.
2026-07-14 22:10:27 +02:00
Muhammad Bassiouni
226b0b59bf
[Clang][C2y] Add support for if declarations (N3356 paper) (#198244)
Add support for _if declarations_ in `C2y` mode by exploiting existing
C++ code.

The only new changes to the code is narrowing the code path to `C` mode
and introduce new errors and warnings for some pitfalls with the syntax
and what is expected from the standard and old language modes.

It should be noted that the first clause in the standard paper can only
be declaration. This means we can't allow expression statement in the
first clause of the condition, and that's the goal of the new
warnings/errors. Also this is different from C++ grammar.
2026-07-14 22:16:31 +03:00
AZero13
ee24ac00d8
[Clang] Allow devirtualization involving array subscripts with constant indices when the pointee type is known [CWG1504] (#207540)
By C++17 [expr.add]/6, if the array element type and the pointee type
are not similar, behavior is undefined.
2026-07-13 14:52:50 +00:00
Sirraide
d09048a464
[Clang] [C++26] Expansion Statements (P1306R5) (#169680)
This implements C++26's expansion statements, i.e.
[P1306R5](https://wg21.link/P1306R5).

An expansion statement is implemented using a number of new AST
nodes. Since an expansion statement is a template, we need it to be
a dependent DeclContext, but only nodes that inherit from Decl can
be DeclContexts, for which reason this introduces a CXXExpansionStmtDecl.
This holds a synthesised constant template parameter used as the
expansion index as well as a 'CXXExpansionStmtPattern' and a
'CXXExpansionStmtInstantiation.

These two AST nodes are similar to the semantic vs syntactic form
of an InitListExpr: the 'Pattern' represents an unexpanded expansion
statement, and the resulting AST after expansion is stored in an
'Instantiation'.

Since expansion statements require us to perform template instantiation
*inside* a function without instantiating the rest of a function, I had to
remove a number of assertions in the template instantiation engine (e.g.
the assertion that a function parameter must always have an instantiation 
by the time we encounter a DeclRefExpr to it no longer holds).

For more implementation details, see the corresponding doc comments
in DeclTemplate.h and StmtCXX.h.

There is some follow up work to be done after this lands, which is
tracked in #207776.
2026-07-11 00:01:08 +02:00
Vlad Serebrennikov
c1d66b5356
[clang] Update C++ DR status page (#208641) 2026-07-10 08:39:08 +00:00
Sirraide
1381ef49fc
[Clang] Add flags and lang option for C++2d (#203992)
This adds diagnostic groups, command-line options, a language option,
and various other things required to support `-std=c++2d`. I haven’t
touched e.g. clang-tidy or clang-format, as I’m not really familiar w/
either. This is only meant to add the most necessary parts to support
C++29 mode.

I grepped for `CPlusPlus26`/`C++26`/`C++2c` and updated all places I
could find where we need to handle every language mode in some way or
another.

This patch is roughly based on b763d6a4ed.
2026-07-03 21:37:02 +00:00
Vlad Serebrennikov
130d6c3cdd
[clang] Add test for CWG3088 about macros defining special identifiers (#189309)
This PR adds a test for
[CWG3088](https://cplusplus.github.io/CWG/issues/3088.html) "Clarify
macro treatment of identifiers with special meaning".

[[cpp.replace.general] paragraph
9](https://eel.is/c++draft/cpp.replace.general#9) reads as follows:
> A translation unit shall not `#define` or `#undef` macro names
lexically identical to keywords, to the identifiers listed in Table
[4](https://eel.is/c++draft/lex.name#tab:lex.name.special), or to the
[_attribute-token_](https://eel.is/c++draft/dcl.attr.grammar#nt:attribute-token)s
described in [[dcl.attr]](https://eel.is/c++draft/dcl.attr), except that
the macro names `likely` and `unlikely` may be defined as function-like
macros and may be
undefined[.](https://eel.is/c++draft/cpp.replace.general#9.sentence-1)
>
> [Note [1](https://eel.is/c++draft/cpp.replace.general#note-1): An
alternative token ([[lex.digraph]](https://eel.is/c++draft/lex.digraph))
is not an identifier, even when its spelling consists entirely of
letters and
underscores[.](https://eel.is/c++draft/cpp.replace.general#9.sentence-2)
Therefore it is not possible to define a macro whose name is the same as
that of an alternative
token[.](https://eel.is/c++draft/cpp.replace.general#9.sentence-3)
— end note]

Since C++98 and up until
[P2843R3](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2843r3.pdf)
"Preprocessing is never undefined", which was voted into C++26 **not**
as a DR, this rule has been living as [macro.names]/2 in library
introduction, but that paper made it a part of the core language.

I believe that formally:
- we should not diagnose anything before C++26 if the standard library
is not used, and
- we should diagnose everything in C++26 and newer modes.

But in practice we've been diagnosing everything except for attributes
in all language modes with some exceptions that are likely bugs.
2026-07-02 21:10:36 +00:00
Jan Schultke
b385e9f625
[clang] Implement P3733R1 (#203944)
In all C++ language modes, as a DR
2026-07-02 11:49:59 +02:00
Jan Schultke
8cdf6346f4
[clang] Add test for CWG3129 (#206335)
Adds a test for [CWG3129](https://wg21.link/CWG3129) "Clarify which floating-point-literals are valid".

Clang has supported floating-point literals with overly tiny or huge
exponents since 3.0, with only a warning emitted.
2026-06-29 00:48:05 +04:00
Vlad Serebrennikov
3f52675682
[clang] Update C++ DR status page (#205342)
The post-Brno draft will not be out for three more weeks, but Brno
updates for Core issues statuses are already trickling in.

Notably, [CWG507](https://cplusplus.github.io/CWG/issues/507.html)
"Ambiguity with built-in binary operator candidates for class object
convertible to built-in type", which used to be marked as a duplicate of
[CWG260](https://cplusplus.github.io/CWG/issues/260.html) "User-defined
conversions and built-in `operator=`", is open again, presumably because
it contains an example that goes beyond the scope of CWG260. Relatively
recent CWG thread that might be related (WG21 access required):
[link](https://lists.isocpp.org/core/2025/08/18478.php).
2026-06-23 13:58:02 +00:00
Corentin Jabot
76e120e0bd
[Clang][NFC] Add the list C++ papers approved in Brno by WG21 (#203685) 2026-06-13 09:53:20 +02:00
Aaron Ballman
9f34092cbd
[C23] Combine two proposals on C status tracking page (#200239)
N2601 is what added Annex H for the interchange and extended floating
point types.

N2844 removed default argument promotions for the types in Annex H.

So these two proposals really do go together.
2026-05-29 07:15:58 -04:00
Gábor Tóthvári
35a10827d0
[analyzer][NFC] Merge the class LocationContext into StackFrame (#198211)
This commit implements the final parts of the roadmap described in issue
#190973 by merging the class `LocationContext` into the class
`StackFrame` and replacing `LocationContext` with `StackFrame`
throughout the analyzer.
2026-05-28 16:26:53 +00:00
Vlad Serebrennikov
055a4ba0b2
[clang] Update C++ DR status page (#200053)
Updates from 2026-05-19 CWG telecon.
2026-05-27 21:36:27 +00:00
Matthias Wippich
27249aa2d8
[clang] Implement CWG3135 - constexpr structured bindings with prvalues from tuples (#191880)
This patch implements
[CWG3135](https://cplusplus.github.io/CWG/issues/3135.html). This has
been accepted into C++26 at the Croydon meeting through [CWG Motion
3](https://github.com/cplusplus/draft/issues/8824).

This change has not been designated a defect report. However, there was
recently some discussion about this designation and GCC implements it as
DR. Therefore, this is treated as DR regardless.
2026-05-21 22:16:40 +08:00
Petr Hosek
4979904f7e
Revert "Reapply [Clang] Implement P2843R3 - Preprocessing is never undefined" (#198641)
Reverts llvm/llvm-project#196989 since it broke LLVM libc, see
https://github.com/llvm/llvm-project/pull/196989#issuecomment-4490816018
for details.
2026-05-19 18:14:53 -05:00
Yihan Wang
22e8c55ccf
Reapply [Clang] Implement P2843R3 - Preprocessing is never undefined (#196989)
This PR reapply https://github.com/llvm/llvm-project/pull/192073, and
make most `-pedantic` warnings default on.

---
This PR marks [P2843R3 - Preprocessing is never
undefined](https://wg21.link/P2843) as implemented and add tests.

Fixes https://github.com/llvm/llvm-project/issues/145658

---------

Signed-off-by: yronglin <yronglin777@gmail.com>
2026-05-20 01:06:02 +08:00
Vlad Serebrennikov
661aae4343
[clang] Add tests for some of CWG issues resolved in Croydon (2026-03) (#189299)
This PR adds tests for the following Core issues:
- [CWG2765](https://cplusplus.github.io/CWG/issues/2765.html) "Address
comparisons between potentially non-unique objects during constant
evaluation";
- [CWG2966](https://cplusplus.github.io/CWG/issues/2966.html) "Alignment
and value representation of `std::nullptr_t`";
- [CWG3035](https://cplusplus.github.io/CWG/issues/3035.html) "Lambda
expressions in anonymous unions";
- [CWG3128](https://cplusplus.github.io/CWG/issues/3128.html)
"Potentially-throwing unevaluated operands";
- [CWG3151](https://cplusplus.github.io/CWG/issues/3151.html) "Closure
types that are `final`";
- [CWG3156](https://cplusplus.github.io/CWG/issues/3156.html) "Handling
of deleted functions in unevaluated _lambda-captures_".

Additionally, the following Core issues are marked as "N/A", because I
don't think they can be tested:
- [CWG2660](https://cplusplus.github.io/CWG/issues/2660.html) "Confusing
term "this parameter"";
- [CWG2983](https://cplusplus.github.io/CWG/issues/2983.html) "Non-type
template parameters are not variables";
- [CWG2992](https://cplusplus.github.io/CWG/issues/2992.html) "Labels do
not have names";
- [CWG3058](https://cplusplus.github.io/CWG/issues/3058.html) ""Program
point" is not defined";
- [CWG3172](https://cplusplus.github.io/CWG/issues/3172.html) "Reference
to wrong placeholder".

-------

[P4160R0](https://wg21.link/p4160r0) "Core Language Working Group
"ready" Issues for the March, 2026 meeting" is what was voted in.
Individual Core issues pages linked above also contain up-to-date
resolutions.
2026-05-18 16:15:15 +04:00
Victor Chernyakin
68a1a83c9d
Revert "[clang][NFC] Mark CWG717 as implemented and add a test (#197732)" (#198074)
As reported in #197930, these new tests fail on the
`arm64-apple-darwin-unknown` target. There's not a consensus yet on how
to fix the breakage, so revert it until we can decide.
2026-05-16 08:11:59 +00:00
Victor Chernyakin
f4528cc84f
[clang][NFC] Mark CWG717 as implemented and add a test (#197732)
[CWG717](https://wg21.link/cwg717) allows applying `thread_local` to
`extern` block-scope variables and static data members. Clang implements
this since 3.3: https://godbolt.org/z/sx4nc3qqe
2026-05-14 17:17:55 +00:00
Victor Chernyakin
c0792f37be
[clang][NFC] Mark CWG941 as implemented and add a test (#197202)
[CWG941](https://wg21.link/cwg941) allowed specializing deleted function
templates. Clang accepted this between 2.7 and 2.9, regressed and
started emitting redefinition errors between 3.0 and 3.8, then went back
to accepting in 3.9: https://godbolt.org/z/GKnf9je7j. I've marked it as
implemented since 3.9.
2026-05-12 15:07:54 -07:00
Victor Chernyakin
a9d11f9405
[clang][NFC] Mark CWG730 as implemented and add a test (#197186)
[CWG730](https://wg21.link/cwg730) clarifies that it's allowed to
specialize templates that are members of a non-template class. Clang
implements this since 2.7: https://godbolt.org/z/bWzb766rz
2026-05-12 20:56:28 +00:00
Yihan Wang
1e44c0b7bf
[NFC][clang] Mark P3868R1 as implemented (#197181)
This feature was already implemented by
https://github.com/llvm/llvm-project/issues/153641.

---------

Signed-off-by: yronglin <yronglin777@gmail.com>
2026-05-12 13:43:33 +00:00
Victor Chernyakin
3473ceaadc
[clang][NFC] Mark CWG743 and CWG950 as implemented and add tests (#197015)
[CWG743](https://wg21.link/cwg743) allows using `decltype` in a
*nested-name-specifier*, i.e.: `decltype(foo)::type`.
[CWG950](https://wg21.link/cwg950) allows using it as a
*base-specifier*, i.e.: `struct B : decltype(foo)`. Both these DRs were
resolved by [N3049](https://wg21.link/n3049).


Clang supports both of these since 3.1: https://godbolt.org/z/aohPs5zaa
2026-05-12 13:28:13 +00:00
Victor Chernyakin
bd0aad5531
[clang][NFC] Mark CWG988 as implemented and add a test (#196889)
[CWG988](https://wg21.link/cwg988) specifies that reference collapsing
is performed when trying to form a reference to a `decltype`. Clang
implements this since 2.7: https://godbolt.org/z/vYzKbv8x7 (and I
checked a few versions after that to make sure there were no
regressions).
2026-05-11 07:43:45 -07:00
Vlad Serebrennikov
7c9f1d2128
[clang] Update cxx_dr_status.html (#196702)
Updates from 2026-05-08 CWG telecon.
2026-05-09 08:49:56 +00:00
Victor Chernyakin
dc78a52815
[clang][NFC] Mark CWG1336 as implemented and add a test (#196000)
[CWG1336](https://wg21.link/cwg1336) clarifies that, as long as it isn't
explicit, a constructor is still a converting constructor even if it has
multiple arguments. Clang seems to implement this since 3.1:
https://godbolt.org/z/919zdMd3h (I checked a few versions following 3.1
as well, and didn't notice any regressions).
2026-05-06 07:02:40 -07:00
Victor Chernyakin
8a26ecc0b7
[clang][NFC] Mark CWG2785 as implemented and add a test (#195547)
[CWG2785](https://wg21.link/cwg2785) clarifies that a
*requires-expression* is never type-dependent, it always has type
`bool`. That means that in a snippet like this:
```cpp
void g(void *);

template <typename T>
void f() {
  g(requires { T(); });
}
```
The call to `g` should be diagnosed as invalid (`bool` is not
convertible to `void *`) even if the template is never instantiated.
Clang does the right thing since version 10:
https://godbolt.org/z/s61rEbsfz
2026-05-04 10:16:45 -07:00
Victor Chernyakin
7608c5f25b
[clang][NFC] Mark CWG2629 as implemented and add a test (#195490)
This is ill-formed:
```cpp
switch (0.0) {}
```
Before [CWG2629](https://wg21.link/cwg2629) though, this was allowed:
```cpp
switch (double d = 0.0) {} // Value of 'd' is implicitly converted to an integer
```
Clang however has always rejected both: https://godbolt.org/z/GYc4hhrnz
2026-05-03 13:21:24 -07:00
Victor Chernyakin
a671e79590
[clang] Implement CWG2413 (implicit typename in conversion operators) (#195207)
Link: [CWG2413](https://wg21.link/cwg2413). This DR was resolved by
[P1787R6](https://wg21.link/P1787R6) by adding the following wording to
[[temp.res.general]/4](https://eel.is/c++draft/temp.res.general#4):

> A [type-only
context](https://eel.is/c++draft/temp.res.general#def:context,type-only)
is defined as follows: A qualified or unqualified name is said to be in
a type-only context if it is the terminal name of
> - ...
> - a [type-specifier](https://eel.is/c++draft/dcl.type.general#nt:type-specifier) of a
>   - ...
> - [conversion-type-id](https://eel.is/c++draft/class.conv.fct#nt:conversion-type-id),

Towards #54150.
2026-05-01 18:59:27 -07:00
Victor Chernyakin
1adabd603a
[clang][NFC] Update the DR list (#195213)
Just ran `make_cxx_dr_status` to bring in the latest DRs.
2026-05-01 07:41:27 -07:00
Victor Chernyakin
c46ed7084e
[clang][NFC] Mark CWG2780 as implemented and add a test (#195127)
[CWG2780](https://wg21.link/cwg2780) allows `reinterpret_cast`ing to a
reference-to-function type. Clang already supports this:
https://godbolt.org/z/c37hsvKnn
2026-05-01 07:40:42 -07:00
Victor Chernyakin
89133afd5e
[clang][NFC] Mark CWG2807 as implemented and add a test (#194755)
CWG2807 (https://wg21.link/cwg2807): One part of the standard correctly
said destructors can't be `consteval`, but another incorrectly said they
can be.

Clang diagnosed this in 9.0, for some reason started accepting it in
10.0, then went back to diagnosing in 11.0:
https://godbolt.org/z/6sWTYT38M. I've marked it as implemented since
11.0.

The issue that prompted the DR: #65665
2026-04-29 03:00:59 -07:00
Victor Chernyakin
3b832a0c54
[clang][NFC] Mark CWG2810 as implemented and add a test (#194683)
CWG2810 (https://cplusplus.github.io/CWG/issues/2810.html) just removes
some wording that could be misinterpreted as saying "a compiler must not
emit any warnings in uninstantiated templates". Clang has never
misinterpreted it that way, so we don't need to do anything here.
2026-04-28 14:14:38 -07:00
Corentin Jabot
94e0fd0988
[Clang] No longer advertise support for coroutines on x86 windows. (#193456)
There are a large number of long standing issues with coroutines on
x86_32 windows as discussed here

https://github.com/llvm/llvm-project/issues/59382

- #59382
- #58556
- #58543
- #56989
- #193161
- #136481

As such this patches
  - No longer defines `__cpp_impl_coroutine` on that platform
  - Warn when using coroutines on that platform

The reason to not plainly error is that it would break too much valid
valid code, ie there are people who probably use coroutines sucessfully.

And we also want to keep testing on that platform, up until the point we
were to pull support completely.

Hopefully this is all temporary and someone will feel compelled to
improve the situation enough that we can unceremoniously revert this
patch.
2026-04-27 12:30:03 +02:00
Vlad Serebrennikov
6443e9b8a5
[clang] Tests for CWG1670 and CWG1878: auto in conversion functions (#187850)
This PR adds tests for
[CWG1670](https://cplusplus.github.io/CWG/issues/1670.html) "`auto` as
_conversion-type-id_" and
[CWG1878](https://cplusplus.github.io/CWG/issues/1878.html) "`operator
auto` template". The long and short of it is that placeholder type
specifier (`auto`) cannot be used to declare conversion function or
conversion function template. We've always diagnosed template case but
not non-template case.
2026-04-25 11:39:00 +04:00
Corentin Jabot
a7368c3b48
[NFC][Clang][docs] Clarify the status of P1949R7 (unicode identifiers) (#193483)
Clang does not check identifiers are NFC-normalized, which the standard
requires.
2026-04-24 07:27:28 +02:00
h-vetinari
47523f7f07
[clang][docs] open details of C++{17,14,11} implementation by default (#193141)
Before
b9c0e590f1
switched the C++ status page to a reverse chronological order, it made
sense to avoid wasting vertical space for already-implemented standards.
After that switch, it would make sense however to unfold them by
default.

This is for example why I had opened #61426, because CRTL+F did not show
P0588 on the status page[^1]. But not just for this paper, I think the
ease of finding papers is a good argument for folding out those tables.

[^1]: together with the fact that other status pages
([example](https://en.cppreference.com/cpp/compiler_support/20)) have
sorted this paper under C++20 rather than C++11.
2026-04-23 10:21:58 -04:00
Aaron Ballman
6fcc4d701d
Revert "[Clang] Diagnose UB and emit error when identifier has both internal and external linkage" (#193462)
Reverts llvm/llvm-project#192116

See comments at
https://github.com/llvm/llvm-project/pull/192116#pullrequestreview-4153002566
2026-04-22 11:15:13 +00:00
Aditya Medhane
1e2175ec4d
[Clang] Diagnose UB and emit error when identifier has both internal and external linkage (#192116)
C11 6.2.2p7 says if the same identifier appears with both internal and
external linkage in a translation unit, the behavior is undefined.

This patch adds a check in `Sema::MergeVarDecl` that uses
`LookupResult::isShadowed()` to detect when a block-scope `extern` found
a file-scope `static` through a shadow, and emits an error.

Fixes #54215
2026-04-21 15:05:27 -04:00
Vlad Serebrennikov
63ae74b78a
[clang] Update C++ DR status page (#192768)
Now that Croydon motions are reflected in `cwg_index.html`.
2026-04-18 05:50:42 +00:00
StefanPaulet
c872a64173
[clang] Add diagnostic for friend declaration of closure type member (#191419)
Clang allows friend declarations of closure type members, which is
disallowed per CWG 1780 (Issue #26540).

Added a new diagnostic when the friend declaration targets a member of a
`CXXRecordDecl` that is a lambda.

---------

Co-authored-by: Corentin Jabot <corentinjabot@gmail.com>
2026-04-17 13:40:45 +02:00
gulfemsavrun
b104dab739
Revert "[Clang] Implement P2843R3 - Preprocessing is never undefined" (#192532)
Reverts llvm/llvm-project#192073 

Reason for revert: This change caused build failures on Windows when
compiling libcxx.
2026-04-16 21:05:32 +00:00
yronglin
42e0cdf2fc
[Clang] Implement P2843R3 - Preprocessing is never undefined (#192073)
This PR marks [P2843R3 - Preprocessing is never
undefined](https://wg21.link/P2843) as implemented and add tests.

Fixes https://github.com/llvm/llvm-project/issues/145658

---------

Signed-off-by: yronglin <yronglin777@gmail.com>
2026-04-16 19:40:35 +08:00
Corentin Jabot
54ae11d3f0
[Clang][NFC] Mark 3106 as implemented. (#192256)
This was a wording clarification, but we add a test nonetheless.
2026-04-15 15:01:46 +00:00
h-vetinari
d32e0d35ea
[clang][docs] mark v22 as released (#191612)
The following features are now released and should be marked as such:

Named loops, v3 -> e4a1b5f

_COUNTER pre-defiend macro: -> df1d786

Allow calling static inline within extern inline: -> 8e60adc
2026-04-13 16:29:37 -07:00