Commit Graph

1619 Commits

Author SHA1 Message Date
Aaron Ballman 313f9cd81d Update statuses and add tests for C89 DRs
This mostly finishes the DRs for C89, though there are still a few
outliers which remain. It also corrects some of the statuses of DRs
where it's not clear if it was fully resolved by the committee or not.

As a drive-by, it also adds -fsyntax-only to the tests which are
verifying diagnostic results. This was previously missed by accident.
2022-06-28 10:29:20 -04:00
Javier Alvarez 5ea341d7c4 [clang] Fix trivially copyable for copy constructor and copy assignment operator
From [class.copy.ctor]:

```
A non-template constructor for class X is a copy constructor if its first
parameter is of type X&, const X&, volatile X& or const volatile X&, and
either there are no other parameters or else all other parameters have
default arguments (9.3.4.7).

A copy/move constructor for class X is trivial if it is not user-provided and if:
- class X has no virtual functions (11.7.3) and no virtual base classes (11.7.2), and
- the constructor selected to copy/move each direct base class subobject is trivial, and
- or each non-static data member of X that is of class type (or array thereof),
  the constructor selected to copy/move that member is trivial;

otherwise the copy/move constructor is non-trivial.
```

So `T(T&) = default`; should be trivial assuming that the previous
provisions are met.

This works in GCC, but not in Clang at the moment:
https://godbolt.org/z/fTGe71b6P

Reviewed By: royjacobson

Differential Revision: https://reviews.llvm.org/D127593
2022-06-17 10:35:01 +03:00
Aaron Ballman 10822857b7 Rolling back tests for WG14 DR145
Several build bots are failing with surprising behavior, so it's less
clear whether we do or don't implement this DR properly.

https://lab.llvm.org/buildbot/#/builders/91/builds/10454
https://lab.llvm.org/buildbot/#/builders/109/builds/40668
https://lab.llvm.org/buildbot/#/builders/139/builds/23334
2022-06-15 15:37:14 -04:00
Aaron Ballman 61a649ca35 Update the status of more C DRs
This adds information for DRs 126 through 146.
2022-06-15 15:25:47 -04:00
Shivam Gupta a01579ad0a [NFC] Suggest Release mode in clang GettingStarted.html
This fix https://github.com/llvm/llvm-project/issues/23841.
Lots of beginners are not of aware of this option do suggesting it here
would be helpful.
2022-06-10 11:00:05 +05:30
Aaron Ballman 8e1a29ecab Use HTTPS links instead of HTTP ones in the C DR status page 2022-06-09 08:52:30 -04:00
Aaron Ballman f0a6a57330 Switch links to use https consistently
The WG14 website was recently updated to support SSL, and we might as
well make use of that.
2022-06-08 15:53:55 -04:00
Aaron Ballman b685426970 Add missing entries for Annex F and Annex H to the C status page 2022-06-08 15:53:54 -04:00
Aaron Ballman 98d4f0651a Correcting some links in the C status page
The paper titles were correct, but the document number and links were
incorrect (typo'ed numbers).
2022-06-08 08:52:31 -04:00
Aaron Ballman bf21cda7f2 Add the 2022 papers to the C status tracking page
This adds the papers from Feb 2022 (parts 1 and 2) and May 2022.
2022-06-08 07:42:39 -04:00
Aaron Ballman d46e7aecb4 Update the C2x status page from latest working draft
This adds the papers for the Jun, Sep, and Dec 2021 meetings. 2022
papers will be handled in a follow-up.
2022-06-07 15:53:47 -04:00
Aaron Ballman 3472b6eb0a Updating more entries in the C DR Status page
Adds test coverage or information for ~25 more C DRs.
2022-06-03 08:29:06 -04:00
Aaron Ballman 0b46121c41 Update more DR status information for C.
This adds new files to track DRs 100-199 and 400-499, but the file
contents are still a work in progress. It also updates the associated
status in the DR tracking page.
2022-06-02 09:32:44 -04:00
James Y Knight 997b072e10 C++ DR2394: Const-default-constructible for members.
Const class members may be initialized with a defaulted default
constructor under the same conditions it would be allowed for a const
object elsewhere.

Differential Revision: https://reviews.llvm.org/D126170
2022-05-25 14:20:11 -04:00
Aaron Ballman f96aa834d7 Test C DR conformance (part three of many)
This adds more of the tests for the first 100 DRs in C and updates
their status on the status page.
2022-05-25 08:18:16 -04:00
Aaron Ballman 202a4fde2b Test more C DR conformance (part two of many)
This continues the work started earlier at filling our the C DR status
page based on test coverage.
2022-05-22 13:37:30 -04:00
Aaron Ballman df46fb4055 Test C DR conformance (part one of many)
This starts to fill out the C DR status page with information
determined from tests. It also starts to add some test coverage for the
DRs we can add tests for (some are difficult as not all C DRs involve
questions about code and some DRs are about the behavior of linking
multiple TUs together).

Note: there is currently no automation for filling out the HTML page
from test coverage like there is for the C++ DRs, but this commit
attempts to use a similar comment style in case we want to add such a
script in the future.
2022-05-21 15:02:46 -04:00
Aaron Ballman ade5b55af5 Add a page to track C defect report status
We currently have a page for tracking defects against the C++ standard,
but we don't have the same information for the C standard. This starts
us down the path of being able to track that in a way our users can see.

There are *a lot* of entries marked as "Unknown". As we validate
Clang's behavior for a given DR by adding a test case for it, we can
slowly begin to improve this page over time.

This page is now linked from the existing C status page, which was
updated slightly as a result of these changes as well.

Note, unlike with the C++ defect report page, this content is not auto-
generated from a source document and is not automatically updated from
test comments. It may be worthwhile to automate the updates based on
our test coverage, but that can happen later.
2022-05-20 16:07:48 -04:00
Fangrui Song c79e6007ed Revert D119136 "[clang] Implement Change scope of lambda trailing-return-type" and its follow-up
This reverts commit 69dd89fdcb.
This reverts commit 04000c2f92.

The current states breaks libstdc++ usage (https://reviews.llvm.org/D119136#3455423).
The fixup has been reverted as it caused other valid code to be disallowed.
I think we should start from the clean state by reverting all relevant commits.
2022-04-20 10:57:12 -07:00
Aaron Ballman 9955f14aaf [C2x] Disallow functions without prototypes/functions with identifier lists
WG14 has elected to remove support for K&R C functions in C2x. The
feature was introduced into C89 already deprecated, so after this long
of a deprecation period, the committee has made an empty parameter list
mean the same thing in C as it means in C++: the function accepts no
arguments exactly as if the function were written with (void) as the
parameter list.

This patch implements WG14 N2841 No function declarators without
prototypes (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2841.htm)
and WG14 N2432 Remove support for function definitions with identifier
lists (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2432.pdf).

It also adds The -fno-knr-functions command line option to opt into
this behavior in other language modes.

Differential Revision: https://reviews.llvm.org/D123955
2022-04-20 13:28:15 -04:00
Timm Bäder 33ec653055 [clang][lexer] Allow u8 character literal prefixes in C2x
Implement N2418 for C2x.

Differential Revision: https://reviews.llvm.org/D119221
2022-04-19 09:57:51 +02:00
Corentin Jabot 04000c2f92 [clang] Implement Change scope of lambda trailing-return-type
Implement P2036R3.

Captured variables by copy (explicitely or not), are deduced
correctly at the point we know whether the lambda is mutable,
and ill-formed before that.

Up until now, the entire lambda declaration up to the start of the body would be parsed in the parent scope, such that capture would not be available to look up.

The scoping is changed to have an outer lambda scope, followed by the lambda prototype and body.

The lambda scope is necessary because there may be a template scope between the start of the lambda (to which we want to attach the captured variable) and the prototype scope.

We also need to introduce a declaration context to attach the captured variable to (and several parts of clang assume captures are handled from the call operator context), before we know the type of the call operator.

The order of operations is as follow:

* Parse the init capture in the lambda's parent scope

* Introduce a lambda scope

* Create the lambda class and call operator

* Add the init captures to the call operator context and the lambda scope. But the variables are not capured yet (because we don't know their type).
Instead, explicit  captures are stored in a temporary map that conserves the order of capture (for the purpose of having a stable order in the ast dumps).

* A flag is set on LambdaScopeInfo to indicate that we have not yet injected the captures.

* The parameters are parsed (in the parent context, as lambda mangling recurses in the parent context, we couldn't mangle a lambda that is attached to the context of a lambda whose type is not yet known).

* The lambda qualifiers are parsed, at this point We can switch (for the second time) inside the lambda context, unset the flag indicating that we have not parsed the lambda qualifiers,
record the lambda is mutable and capture the explicit variables.

* We can parse the rest of the lambda type, transform the lambda and call operator's types and also transform the call operator to a template function decl where necessary.

At this point, both captures and parameters can be injected in the body's scope. When trying to capture an implicit variable, if we are before the qualifiers of a lambda, we need to remember that the variables are still in the parent's context (rather than in the call operator's).

Reviewed By: aaron.ballman, #clang-language-wg, ChuanqiXu

Differential Revision: https://reviews.llvm.org/D119136
2022-04-15 16:50:52 +02:00
Richard Smith 836e610d93 Revert "[clang] Implement Change scope of lambda trailing-return-type"
This reverts commit c729d5be78.

This change breaks thread safety annotations on lambdas.
2022-04-13 21:34:08 -07:00
Corentin Jabot c729d5be78 [clang] Implement Change scope of lambda trailing-return-type
Implement P2036R3.

Captured variables by copy (explicitely or not), are deduced
correctly at the point we know whether the lambda is mutable,
and ill-formed before that.

Up until now, the entire lambda declaration up to the start
of the body would  be parsed in the parent scope, such that
captures would not be available to look up.

The scoping is changed to have an outer lambda scope,
followed by the lambda prototype and body.

The lambda scope is necessary because there may be a template scope
between the start of the lambda (to which we want to attach
the captured variable) and the prototype scope.

We also need to introduce a declaration context to attach the captured
variable to (and several parts of clang assume captures are handled from
the call operator context), before we know the type of the call operator.

The order of operations is as follow:

* Parse the init capture in the lambda's parent scope
* Introduce a lambda scope
* Create the lambda class and call operator
* Add the init captures to the call operator context and the lambda scope.
  But the variables are not capured yet (because we don't know their type).
  Instead, explicit  captures are stored in a temporary map that
  conserves the order of capture (for the purpose of having a stable order in the ast dumps).

* A flag is set on LambdaScopeInfo to indicate that we have not yet injected the captures.

* The parameters are parsed (in the parent context, as lambda mangling recurses in the parent context,
  we couldn't mangle a lambda that is attached to the context of a lambda whose type is not yet known).

* The lambda qualifiers are parsed, at this point,
  we can switch (for the second time) inside the lambda context,
  unset the flag indicating that we have not parsed the lambda qualifiers,
  record the lambda is mutable and capture the explicit variables.

* We can parse the rest of the lambda type, transform the lambda and call operator's types and also
  transform the call operator to a template function decl where necessary.

At this point, both captures and parameters can be injected in the body's scope.
When trying to capture an implicit variable, if we are before the qualifiers of a lambda,
we need to remember that the variables are still in the parent's context (rather than in the call operator's).

This is a recommit of adff142dc2 after a fix in d8d793f29b

Reviewed By: aaron.ballman, #clang-language-wg, ChuanqiXu

Differential Revision: https://reviews.llvm.org/D119136
2022-04-13 23:07:39 +02:00
Mehdi Amini 26eec9e9db Revert "[clang] Implement Change scope of lambda trailing-return-type"
This reverts commit adff142dc2.
This broke clang bootstrap: it made existing C++ code in LLVM invalid:

llvm/include/llvm/CodeGen/LiveInterval.h:630:53: error: captured variable 'Idx' cannot appear here
              [=](std::remove_reference_t<decltype(*Idx)> V,
                                                    ^
2022-04-13 19:35:13 +00:00
Corentin Jabot 925acfea88 [Clang] Fix html error in cxx_status.html [NFC] 2022-04-13 20:27:34 +02:00
Corentin Jabot adff142dc2 [clang] Implement Change scope of lambda trailing-return-type
Implement P2036R3.

Captured variables by copy (explicitely or not), are deduced
correctly at the point we know whether the lambda is mutable,
and ill-formed before that.

Up until now, the entire lambda declaration up to the start of the body would be parsed in the parent scope, such that capture would not be available to look up.

The scoping is changed to have an outer lambda scope, followed by the lambda prototype and body.

The lambda scope is necessary because there may be a template scope between the start of the lambda (to which we want to attach the captured variable) and the prototype scope.

We also need to introduce a declaration context to attach the captured variable to (and several parts of clang assume captures are handled from the call operator context), before we know the type of the call operator.

The order of operations is as follow:

* Parse the init capture in the lambda's parent scope

* Introduce a lambda scope

* Create the lambda class and call operator

* Add the init captures to the call operator context and the lambda scope. But the variables are not capured yet (because we don't know their type).
Instead, explicit  captures are stored in a temporary map that conserves the order of capture (for the purpose of having a stable order in the ast dumps).

* A flag is set on LambdaScopeInfo to indicate that we have not yet injected the captures.

* The parameters are parsed (in the parent context, as lambda mangling recurses in the parent context, we couldn't mangle a lambda that is attached to the context of a lambda whose type is not yet known).

* The lambda qualifiers are parsed, at this point We can switch (for the second time) inside the lambda context, unset the flag indicating that we have not parsed the lambda qualifiers,
record the lambda is mutable and capture the explicit variables.

* We can parse the rest of the lambda type, transform the lambda and call operator's types and also transform the call operator to a template function decl where necessary.

At this point, both captures and parameters can be injected in the body's scope. When trying to capture an implicit variable, if we are before the qualifiers of a lambda, we need to remember that the variables are still in the parent's context (rather than in the call operator's).

Reviewed By: aaron.ballman, #clang-language-wg, ChuanqiXu

Differential Revision: https://reviews.llvm.org/D119136
2022-04-13 20:00:03 +02:00
PoYao Chang 50b1faf5c1 [Clang] CWG 1394: Incomplete types as parameters of deleted functions
According to CWG 1394 and C++20 [dcl.fct.def.general]p2,
Clang should not diagnose incomplete types if function body is "= delete;".
For example:
```
struct Incomplete;
Incomplete f(Incomplete) = delete; // well-formed
```

Also close https://github.com/llvm/llvm-project/issues/52802

Differential Revision: https://reviews.llvm.org/D122981
2022-04-12 11:10:10 +08:00
Nathan Sidwell 54c50336e4 [clang] Document p1703 not needed
We list p1703 as unimplemented, but it is subsumed by p1857.

Reviewed By: tbaeder

Differential Revision: https://reviews.llvm.org/D123120
2022-04-05 06:54:31 -07:00
Shivam 83bde93cef
resolve typo in the manual. 2022-04-01 03:15:17 +05:30
Markus Böck e59335e891 [clang][DR] Add test for DR1227 and mark it as complete
DR: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1227

This DR has been implemented in Clang as far back as I could check. This patch simply adds a test and comment to mark it as complete.

Differential Revision: https://reviews.llvm.org/D122682
2022-03-30 09:25:52 +02:00
Markus Böck c1e614c8eb [clang][DR] Test and mark DR1305 as complete
DR: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1305

This DR has always been implemented in all clang versions as far back as I could go. This patch basically just adds a test with the needed comments to mark it as complete.

Differential Revision: https://reviews.llvm.org/D122674
2022-03-29 20:45:49 +02:00
Markus Böck 984554f846 [clang][DR] Test and mark DR1479 as complete
DR: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1479

Clang has implemented this DR as far back as I could go on compiler explorer (3.0). This patch simply adds a test case and needed comments for the update script to mark it as complete.

Differential Revision: https://reviews.llvm.org/D122620
2022-03-29 09:28:32 +02:00
Erich Keane 281b7eeb14 Update www_status/add test for P1972:
This seems to have been implemented/supported correctly back in Clang
10, so update the documentation and add the test from the paper.
2022-03-28 06:31:04 -07:00
Corentin Jabot 3784e8ccfb [Clang] Fix Unevaluated Lambdas
Unlike other types, when lambdas are instanciated,
they are recreated from scratch.
When an unevaluated lambdas appear in the type of a function,
parameter it is instanciated in the wrong declaration context,
as parameters are transformed before the function.

To support lambda in function parameters, we try to
compute whether they are dependant without looking at the
declaration context.

This is a short term stopgap solution to avoid clang
iceing. A better fix might be to inject some kind of
transparent declaration with correctly computed dependency
for function parameters, variable templates, etc.

Fixes https://github.com/llvm/llvm-project/issues/50376
Fixes https://github.com/llvm/llvm-project/issues/51414
Fixes https://github.com/llvm/llvm-project/issues/51416
Fixes https://github.com/llvm/llvm-project/issues/51641
Fixes https://github.com/llvm/llvm-project/issues/54296

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D121532
2022-03-25 19:16:45 +01:00
Danny Mösch a749e3295d Replace links to archived mailing lists by links to Discourse forums 2022-03-23 10:10:20 -04:00
Aaron Ballman b26466d001 Update the C and C++ status pages now that Clang 14 is out 2022-03-23 07:59:52 -04:00
Corentin Jabot 683e83c56f [Clang][C++2b] P2242R3: Non-literal variables [...] in constexpr
Allow goto, labelled statements as well as `static`, `thread_local`, and
non-literal variables in `constexpr` functions.

As specified. for all of the above (except labelled statements) constant
evaluation of the construct still fails.

For `constexpr` bodies, the proposal is implemented with diagnostics as
a language extension in older language modes. For determination of
whether a lambda body satisfies the requirements for a constexpr
function, the proposal is implemented only in C++2b mode to retain the
semantics of older modes for programs conforming to them.

Reviewed By: aaron.ballman, hubert.reinterpretcast, erichkeane

Differential Revision: https://reviews.llvm.org/D111400
2022-03-22 19:51:19 +01:00
Vlad Serebrennikov a603f566db [clang] CWG 2354: prohibit alignas for enums
Reviewed By: aaron.ballman, erichkeane

Differential Revision: https://reviews.llvm.org/D121723
2022-03-16 15:48:18 +08:00
Zhihao Yuan 136b293129
[c++2b] Implement P0849R8 auto(x)
https://wg21.link/p0849

Reviewed By: aaron.ballman, erichkeane

Differential Revision: https://reviews.llvm.org/D113393
2022-02-28 19:21:08 -06:00
Timm Bäder 02571f86bb [clang][www] Port make_cxx_dr_status script to Python3
And run it to re-generate the cxx_dr_status.html

Differential Revision: https://reviews.llvm.org/D120313
2022-02-22 15:47:43 +01:00
Balazs Benics 5e0be95fce [analyzer][docs][NFC] Fix some broken links and some cosmetic changes
- We should report bugs to the GitHub Issues
- We should advocate using Discourse instead of the superseded cfe-dev
  mailing list.

There are a couple of other cosmetic changes such as preferring `using`
instead of `typedef` and quoting the `-analyze-function` parameter's
payload for escaping the braces.

Thanks @loic-joly-sonarsource for reporting this on Discord!

Reviewed By: NoQ, Szelethus

Differential Revision: https://reviews.llvm.org/D119245
2022-02-09 10:22:28 +01:00
Richard Smith dc8f4e118d [cxx_status] Add a couple of Feb 2022 library papers that need compiler support. 2022-02-08 17:25:52 -08:00
Corentin Jabot c151225096 [C++2b] Implement multidimentional subscript operator
Implement P2128R6 in C++23 mode.

Unlike GCC's implementation, this doesn't try to recover when a user
meant to use a comma expression.

Because the syntax changes meaning in C++23, the patch is *NOT*
implemented as an extension. Instead, declaring an array with not
exactly 1 parameter is an error in older languages modes. There is an
off-by-default extension warning in C++23 mode.

Unlike the standard, we supports default arguments;

Ie, we assume, based on conversations in WG21, that the proposed
resolution to CWG2507 will be accepted.

We allow arrays OpenMP sections and C++23 multidimensional array to
coexist:

[a , b] multi dimensional array
[a : b] open mp section
[a, b: c] // error

The rest of the patch is relatively straight forward: we take care to
support an arbitrary number of arguments everywhere.
2022-02-08 12:10:47 -05:00
Corentin Jabot 3c17f3955c Add core papers adopted at the february plenary.
2 papers are added to the status page, one targeting
C++23, the other added to the batch of C++20 concept papers.
2022-02-08 09:13:04 -05:00
Aaron Ballman bf7d9970ba Support the *_WIDTH macros in limits.h and stdint.h
This completes the implementation of
WG14 N2412 (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2412.pdf),
which standardizes C on a twos complement representation for integer
types. The only work that remained there was to define the correct
macros in the standard headers, which this patch does.
2022-01-13 11:46:34 -05:00
Chuanqi Xu bbce75e352 Update Bug report URL to Github Issues
Although we moved to Github Issues. The bug report message refers to
Bugzilla still. This patch tries to update these URLs.

Reviewed By: MaskRay, Quuxplusone, jhenderson, libunwind, libc++

Differential Revision: https://reviews.llvm.org/D116351
2022-01-06 17:33:25 +08:00
Nathan Sidwell 5fbe21a774 [clang] p2085 out-of-class comparison operator defaulting
This implements p2085, allowing out-of-class defaulting of comparison
operators, primarily so they need not be inline, IIUC intent. this was
mostly straigh forward, but required reimplementing
Sema::CheckExplicitlyDefaultedComparison, as now there's a case where
we have no a priori clue as to what class a defaulted comparison may
be for. We have to inspect the parameter types to find out. Eg:

class X { ... };
bool operator==(X, X) = default;

Thus reimplemented the parameter type checking, and added 'is this a
friend' functionality for the above case.

Reviewed By: mizvekov

Differential Revision: https://reviews.llvm.org/D104478
2021-12-16 07:22:46 -08:00
Chuanqi Xu 5653d127d7 [docs] Give the reason why the support for coroutine is partial
This helps user to know what level of support there
is (roughly) for coroutine feature.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D115778
2021-12-15 21:01:46 +08:00
Aaron Ballman 1feb8ab0d3 Update the status of N2412 in C (we do not implement large parts of it) 2021-12-06 13:14:13 -05:00