[all-commits] [llvm/llvm-project] 40c521: [clang][C++20] P0960R3 and P1975R0: Allow initiali...

Alan Zhao via All-commits all-commits at lists.llvm.org
Wed Dec 14 07:54:28 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 40c52159d3ee337dbed14e4c73b5616ea354c337
      https://github.com/llvm/llvm-project/commit/40c52159d3ee337dbed14e4c73b5616ea354c337
  Author: Alan Zhao <ayzhao at google.com>
  Date:   2022-12-14 (Wed, 14 Dec 2022)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang-c/Index.h
    M clang/include/clang/AST/ASTNodeTraverser.h
    M clang/include/clang/AST/ComputeDependence.h
    M clang/include/clang/AST/Decl.h
    M clang/include/clang/AST/ExprCXX.h
    M clang/include/clang/AST/RecursiveASTVisitor.h
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/include/clang/Basic/StmtNodes.td
    M clang/include/clang/Sema/Initialization.h
    M clang/include/clang/Serialization/ASTBitCodes.h
    M clang/lib/AST/ComputeDependence.cpp
    M clang/lib/AST/Expr.cpp
    M clang/lib/AST/ExprCXX.cpp
    M clang/lib/AST/ExprClassification.cpp
    M clang/lib/AST/ExprConstant.cpp
    M clang/lib/AST/ItaniumMangle.cpp
    M clang/lib/AST/JSONNodeDumper.cpp
    M clang/lib/AST/StmtPrinter.cpp
    M clang/lib/AST/StmtProfile.cpp
    M clang/lib/AST/TextNodeDumper.cpp
    M clang/lib/CodeGen/CGExprAgg.cpp
    M clang/lib/Frontend/InitPreprocessor.cpp
    M clang/lib/Sema/SemaCast.cpp
    M clang/lib/Sema/SemaDecl.cpp
    M clang/lib/Sema/SemaExceptionSpec.cpp
    M clang/lib/Sema/SemaInit.cpp
    M clang/lib/Sema/TreeTransform.h
    M clang/lib/Serialization/ASTReaderStmt.cpp
    M clang/lib/Serialization/ASTWriter.cpp
    M clang/lib/Serialization/ASTWriterStmt.cpp
    M clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
    M clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp
    A clang/test/CodeGen/paren-list-agg-init.cpp
    M clang/test/Lexer/cxx-features.cpp
    A clang/test/PCH/cxx_paren_init.cpp
    A clang/test/PCH/cxx_paren_init.h
    M clang/test/SemaCXX/cxx2a-explicit-bool.cpp
    A clang/test/SemaCXX/paren-list-agg-init.cpp
    M clang/tools/libclang/CIndex.cpp
    M clang/tools/libclang/CXCursor.cpp
    M clang/www/cxx_status.html

  Log Message:
  -----------
  [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 at 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




More information about the All-commits mailing list