[all-commits] [llvm/llvm-project] c15122: [C++2b] Implement multidimentional subscript operator

Aaron Ballman via All-commits all-commits at lists.llvm.org
Tue Feb 8 09:11:07 PST 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c1512250960bd247519a9f959ad4af202402dcc4
  Author: Corentin Jabot <corentin.jabot at gmail.com>
  Date:   2022-02-08 (Tue, 08 Feb 2022)

  Changed paths:
    M clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/include/clang/Sema/Sema.h
    M clang/lib/AST/StmtPrinter.cpp
    M clang/lib/Frontend/InitPreprocessor.cpp
    M clang/lib/Parse/ParseExpr.cpp
    M clang/lib/Sema/SemaAccess.cpp
    M clang/lib/Sema/SemaDeclCXX.cpp
    M clang/lib/Sema/SemaExpr.cpp
    M clang/lib/Sema/SemaOverload.cpp
    M clang/lib/Sema/TreeTransform.h
    M clang/test/OpenMP/target_update_messages.cpp
    A clang/test/Parser/cxx2b-subscript.cpp
    A clang/test/SemaCXX/cxx2b-overloaded-operator.cpp
    M clang/test/SemaTemplate/instantiate-subscript.cpp
    M clang/www/cxx_status.html

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

[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.

More information about the All-commits mailing list