Hi! v8:
- Reformat (simplify) change-log entries. - Improve wording of documentation. - Add link to LLVM issue in commit message. I've added a GitHub issue in the LLVM project reporting about the existence of this patch set: <https://github.com/llvm/llvm-project/issues/102836> Have a lovely night! Alex Alejandro Colomar (3): gcc/: Rename array_type_nelts() => array_type_nelts_minus_one() Merge definitions of array_type_nelts_top() c: Add __lengthof__ operator gcc/c-family/c-common.cc | 26 ++++ gcc/c-family/c-common.def | 3 + gcc/c-family/c-common.h | 2 + gcc/c/c-decl.cc | 30 +++-- gcc/c/c-fold.cc | 7 +- gcc/c/c-parser.cc | 61 +++++++--- gcc/c/c-tree.h | 4 + gcc/c/c-typeck.cc | 118 ++++++++++++++++++- gcc/config/aarch64/aarch64.cc | 2 +- gcc/config/i386/i386.cc | 2 +- gcc/cp/cp-tree.h | 1 - gcc/cp/decl.cc | 2 +- gcc/cp/init.cc | 8 +- gcc/cp/lambda.cc | 3 +- gcc/cp/operators.def | 1 + gcc/cp/tree.cc | 13 -- gcc/doc/extend.texi | 31 +++++ gcc/expr.cc | 8 +- gcc/fortran/trans-array.cc | 2 +- gcc/fortran/trans-openmp.cc | 4 +- gcc/rust/backend/rust-tree.cc | 13 -- gcc/rust/backend/rust-tree.h | 2 - gcc/target.h | 3 + gcc/testsuite/gcc.dg/lengthof-compile.c | 115 ++++++++++++++++++ gcc/testsuite/gcc.dg/lengthof-vla.c | 46 ++++++++ gcc/testsuite/gcc.dg/lengthof.c | 150 ++++++++++++++++++++++++ gcc/tree.cc | 17 ++- gcc/tree.h | 3 +- 28 files changed, 598 insertions(+), 79 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/lengthof-compile.c create mode 100644 gcc/testsuite/gcc.dg/lengthof-vla.c create mode 100644 gcc/testsuite/gcc.dg/lengthof.c Range-diff against v7: 1: 8b68e250503 ! 1: a6aa38c9013 gcc/: Rename array_type_nelts() => array_type_nelts_minus_one() @@ Commit message gcc/ChangeLog: - * tree.cc (array_type_nelts): Rename function ... - (array_type_nelts_minus_one): ... to this name. The old name - was misleading. - * tree.h (array_type_nelts): Rename function ... - (array_type_nelts_minus_one): ... to this name. The old name - was misleading. + * tree.cc (array_type_nelts, array_type_nelts_minus_one): + * tree.h (array_type_nelts, array_type_nelts_minus_one): * expr.cc (count_type_elements): - Rename array_type_nelts() => array_type_nelts_minus_one() * config/aarch64/aarch64.cc - (pure_scalable_type_info::analyze_array): Likewise. - * config/i386/i386.cc (ix86_canonical_va_list_type): Likewise. + (pure_scalable_type_info::analyze_array): + * config/i386/i386.cc (ix86_canonical_va_list_type): + Rename array_type_nelts() => array_type_nelts_minus_one() + The old name was misleading. gcc/c/ChangeLog: * c-decl.cc (one_element_array_type_p, get_parm_array_spec): + * c-fold.cc (c_fold_array_ref): Rename array_type_nelts() => array_type_nelts_minus_one() - * c-fold.cc (c_fold_array_ref): Likewise. gcc/cp/ChangeLog: * decl.cc (reshape_init_array): + * init.cc + (build_zero_init_1): + (build_value_init_noctor): + (build_vec_init): + (build_delete): + * lambda.cc (add_capture): + * tree.cc (array_type_nelts_top): Rename array_type_nelts() => array_type_nelts_minus_one() - * init.cc (build_zero_init_1): Likewise. - (build_value_init_noctor): Likewise. - (build_vec_init): Likewise. - (build_delete): Likewise. - * lambda.cc (add_capture): Likewise. - * tree.cc (array_type_nelts_top): Likewise. gcc/fortran/ChangeLog: * trans-array.cc (structure_alloc_comps): + * trans-openmp.cc + (gfc_walk_alloc_comps): + (gfc_omp_clause_linear_ctor): Rename array_type_nelts() => array_type_nelts_minus_one() - * trans-openmp.cc (gfc_walk_alloc_comps): Likewise. - (gfc_omp_clause_linear_ctor): Likewise. gcc/rust/ChangeLog: 2: 21433097103 ! 2: 43300a17e4a Merge definitions of array_type_nelts_top() @@ Commit message gcc/ChangeLog: * tree.h (array_type_nelts_top): - * tree.cc (array_type_nelts_top): Define function (moved from - gcc/cp/). + * tree.cc (array_type_nelts_top): + Define function (moved from gcc/cp/). gcc/cp/ChangeLog: * cp-tree.h (array_type_nelts_top): - * tree.cc (array_type_nelts_top): Remove function (move - to gcc/). + * tree.cc (array_type_nelts_top): + Remove function (move to gcc/). gcc/rust/ChangeLog: * backend/rust-tree.h (array_type_nelts_top): - * backend/rust-tree.cc (array_type_nelts_top): Remove function. + * backend/rust-tree.cc (array_type_nelts_top): + Remove function. Signed-off-by: Alejandro Colomar <a...@kernel.org> 3: 4bd3837d09c ! 3: e6af87d54af c: Add __lengthof__ operator @@ Commit message Link: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2529.pdf Link: https://inbox.sourceware.org/gcc/m8s4oqy--...@tutanota.com/T/ + Link: https://github.com/llvm/llvm-project/issues/102836 Suggested-by: Xavier Del Campo Romero <xavi....@tutanota.com> Co-developed-by: Martin Uecker <uec...@tugraz.at> Signed-off-by: Alejandro Colomar <a...@kernel.org> @@ gcc/doc/extend.texi: If the operand of the @code{__alignof__} expression is a fu +The keyword @code{__lengthof__} determines the length of an array operand, +that is, the number of elements in the array. +Its syntax is similar to @code{sizeof}. -+The operand must be a complete array type or an expression of that type. ++The operand must be ++a parenthesized complete array type name ++or an expression of such a type. +For example: + +@smallexample @@ gcc/doc/extend.texi: If the operand of the @code{__alignof__} expression is a fu +__lengthof__ (int [7][3]); // returns 7 +@end smallexample + -+The operand is not evaluated -+if the top-level length designator is an integer constant expression -+(in this case, the operator results in an integer constant expression); -+and it is evaluated -+if the top-level length designator is not an integer constant expression -+(in this case, the operator results in a run-time value). ++The result of this operator is an integer constant expression, ++unless the top-level array is a variable-length array. ++The operand is only evaluated ++if the top-level array is a variable-length array. +For example: + +@smallexample -- 2.45.2
signature.asc
Description: PGP signature