[clang][C++20] P0960R3 and P1975R0: Allow initializing aggregates from a parenthesize...
authorAlan Zhao <ayzhao@google.com>
Mon, 3 Oct 2022 17:46:46 +0000 (10:46 -0700)
committerAlan Zhao <ayzhao@google.com>
Wed, 14 Dec 2022 15:54:15 +0000 (07:54 -0800)
commit40c52159d3ee337dbed14e4c73b5616ea354c337
tree1dcf0103adeefd635ed25879ec3a09690bf3cbca
parentc165b0553a96394b9bbf3984782703cdae99821d
[clang][C++20] P0960R3 and P1975R0: Allow initializing aggregates from a parenthesized list of values

This patch implements P0960R3, which allows initialization of aggregates
via parentheses.

As an example:

```
struct S { int i, j; };
S s1(1, 1);

int arr1[2](1, 2);
```

This patch also implements P1975R0, which fixes the wording of P0960R3
for single-argument parenthesized lists so that statements like the
following are allowed:

```
S s2(1);
S s3 = static_cast<S>(1);
S s4 = (S)1;

int (&&arr2)[] = static_cast<int[]>(1);
int (&&arr3)[2] = static_cast<int[2]>(1);
```

This patch was originally authored by @0x59616e and completed by
@ayzhao.

Fixes #54040, Fixes #54041

Co-authored-by: Sheng <ox59616e@gmail.com>
Full write up : https://discourse.llvm.org/t/c-20-rfc-suggestion-desired-regarding-the-implementation-of-p0960r3/63744

Reviewed By: ilya-biryukov

Differential Revision: https://reviews.llvm.org/D129531
42 files changed:
clang/docs/ReleaseNotes.rst
clang/include/clang-c/Index.h
clang/include/clang/AST/ASTNodeTraverser.h
clang/include/clang/AST/ComputeDependence.h
clang/include/clang/AST/Decl.h
clang/include/clang/AST/ExprCXX.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/StmtNodes.td
clang/include/clang/Sema/Initialization.h
clang/include/clang/Serialization/ASTBitCodes.h
clang/lib/AST/ComputeDependence.cpp
clang/lib/AST/Expr.cpp
clang/lib/AST/ExprCXX.cpp
clang/lib/AST/ExprClassification.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/JSONNodeDumper.cpp
clang/lib/AST/StmtPrinter.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/AST/TextNodeDumper.cpp
clang/lib/CodeGen/CGExprAgg.cpp
clang/lib/Frontend/InitPreprocessor.cpp
clang/lib/Sema/SemaCast.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaExceptionSpec.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp
clang/test/CodeGen/paren-list-agg-init.cpp [new file with mode: 0644]
clang/test/Lexer/cxx-features.cpp
clang/test/PCH/cxx_paren_init.cpp [new file with mode: 0644]
clang/test/PCH/cxx_paren_init.h [new file with mode: 0644]
clang/test/SemaCXX/cxx2a-explicit-bool.cpp
clang/test/SemaCXX/paren-list-agg-init.cpp [new file with mode: 0644]
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/CXCursor.cpp
clang/www/cxx_status.html