[clang] Reland parenthesized aggregate init patches
authorAlan Zhao <ayzhao@google.com>
Wed, 4 Jan 2023 23:12:00 +0000 (15:12 -0800)
committerAlan Zhao <ayzhao@google.com>
Thu, 12 Jan 2023 17:58:15 +0000 (09:58 -0800)
commit95a4c0c83554c025ef709a6805e67233d0dedba0
tree26a4aefbb2ab9ade7f32529a630b8e8341f63459
parent81f57b6b994907267e981e09c1789529ec0a91c9
[clang] Reland parenthesized aggregate init patches

This commit relands the patches for implementing P0960R3 and P1975R0,
which describe initializing aggregates via a parenthesized list.

The relanded commits are:

40c52159d3ee - P0960R3 and P1975R0: Allow initializing aggregates from
  a parenthesized list of values
c77a91bb7ba7 - Remove overly restrictive aggregate paren init logic
32d7aae04fdb - Fix a clang crash on invalid code in C++20 mode

This patch also fixes a crash in the original implementation.
Previously, if the input tried to call an implicitly deleted copy or
move constructor of a union, we would then try to initialize the union
by initializing it's first element with a reference to a union. This
behavior is incorrect (we should fail to initialize) and if the type of
the first element has a constructor with a single template typename
parameter, then Clang will explode. This patch fixes that issue by
checking that constructor overload resolution did not result in a
deleted function before attempting parenthesized aggregate
initialization.

Additionally, this patch also includes D140159, which contains some
minor fixes made in response to code review comments in the original
implementation that were made after that patch was submitted.

Co-authored-by: Sheng <ox59616e@gmail.com>
Fixes #54040, Fixes #59675

Reviewed By: ilya-biryukov

Differential Revision: https://reviews.llvm.org/D141546
43 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/test/SemaCXX/recovery-expr-type.cpp
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/CXCursor.cpp
clang/www/cxx_status.html